Cannot convert from 'Spectre.Console.Table' to 'string'
See original GitHub issueThe following code returns the error:
using Spectre.Console;
namespace NewProject.Services;
public class ContextService : IContextService
{
private readonly IRootService _rootService;
public ContextService(IRootService rootService)
{
_rootService = rootService ?? throw new ArgumentNullException(nameof(rootService));
}
public void List()
{
var root = _rootService.GetPath();
DirectoryInfo info = new DirectoryInfo(root);
var directories = info.EnumerateDirectories();
var table = new Table();
table.Border = TableBorder.SimpleHeavy;
table.AddColumn("Context");
table.AddColumn("Path");
foreach (var item in directories)
{
table.AddRow(item.Name, item.FullName);
}
AnsiConsole.Write(table); // Here is C:\Repos\NewProject\Services\ContextService.cs(36,27)
}
}
The build output:
C:\Repos\NewProject\Services\ContextService.cs(36,27): error CS1503: Argument 1: cannot convert from 'Spectre.Console.Table' to 'string' [C:\Repos\NewProject\NewProject.csproj]
The build failed. Fix the build errors and run again.
Could anyone help me?
Issue Analytics
- State:
- Created a year ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Issues · spectreconsole/spectre.console
A .NET library that makes it easier to create beautiful console applications. - Issues · spectreconsole/spectre.console.
Read more >Best Practices
Best practices when working with Spectre.Console and how to troubleshoot when things go wrong.
Read more >Markup
The Markup class allows you to output rich text to the console. Syntax. Console markup uses a syntax inspired by bbcode. If you...
Read more >Specifying Settings
The attribute has one parameter - a pipe delimited string with the list of argument names. The following rules apply: As many names...
Read more >Composing Commands
I can't configure commands in non-compatible ways, and if I want to add a new top-level add-package command (or move the command completely),...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a good catch though I’ll update the docs tonight to include a reference to the new package
We split the
Spectre.Console.Cli
stuff into its own NuGet package for 0.45: https://www.nuget.org/packages/spectre.console.cli