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.

Automatically provide global using for Spectre.Console

See original GitHub issue

It’s (almost?) sure that someone referencing the package will right-away use its provided types.

With the new C# 10 global usings feature, it would be great if referencing the package automatically provided such global usings, so that a simple console top-level program could right-away be just:

AnsiConsole.WriteLine("Hello World!");

No added usings needed.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
phil-scott-78commented, Aug 20, 2021

I’m a little antsy about enabling this for people automatically. I always kinda feel when people add our package we are a guest in their solution, and turning this on feels like we are putting our feet up on the table uninvited.

2reactions
phil-scott-78commented, Aug 23, 2021

For small projects, sure. But of anything with any real meat we’d be bringing in a bunch of stuff in that namespace with names like Color, Decoration, Profile, and Capabilities project wide. And for many console applications only a handful of classes concern themselves with the reading and writing of the output, so these could easily start getting in the way. And that assumes we are the only nuget package that thinks we deserve an automatic global import. If this becomes a trend very quickly things start getting weird for consumers, and frankly I don’t want to be leading that charge 😃

Don’t get me wrong, it’s a feature I’m not against. And I’ve already begun investigating making static global usings better for a later version. I just want to make sure that when our project is added that we play nice in our user’s projects

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practices
Many of these items can be auto-detected by Spectre. Console. Some of these items can only be configured by the user and cannot...
Read more >
Global options for sub-commands #762
The logging example does a great job showing how global options such as --logLevel can be implemented. When attempting to use its approach...
Read more >
Console applications with Spectre.Console
Spectre.Console.Cli.Command<T> defines Execute method, it is a handler and called by CommandApp . The command is created ...
Read more >
Global Usings – A Look at New Language Features in C# 10
With C# 10 you can use global using directives that the compiler will ... This will let those namespaces be automatically imported in...
Read more >
Beautiful console applications with Spectre.Console
This library provides a rich markup language that lets you easily output text with different colors and styles such as bold, italic, and ......
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