question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot convert from 'Spectre.Console.Table' to 'string'

See original GitHub issue

The 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:open
  • Created a year ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
phil-scott-78commented, Sep 24, 2022

This is a good catch though I’ll update the docs tonight to include a reference to the new package

0reactions
patriksvenssoncommented, Sep 24, 2022

We split the Spectre.Console.Cli stuff into its own NuGet package for 0.45: https://www.nuget.org/packages/spectre.console.cli

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found