Automatically provide global using#516
Automatically provide global using#516kzu wants to merge 1 commit intospectreconsole:mainfrom kzu:global_usings
Conversation
The new C# 10 feature lights up automatically via the provided item group with the `Import` element. There's talk of a future opt-out (or opt-in?) MSBuild property to control these global usings, but the provided approach will work and integrate seamlessly with whatever the project/SDK configures. For reference, see dotnet/aspnetcore#32451. Note we provide the "legacy" MSBuild xmlns attribute so as not to break downlevel IDEs or legacy project files that happen to reference this package. Fixes #515
|
|
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
|
||
| <ItemGroup> | ||
| <Import Include="Spectre.Console" /> |
There was a problem hiding this comment.
Shouldn't this be Using? See: dotnet/sdk#19599
Also, how about respecting ImplicitUsings?
There was a problem hiding this comment.
Yep, should be using for next preview/stable.
WRT respecting the condition: https://twitter.com/kzu/status/1430001920022831110?s=19
It's rather pointless, but I can add that, sure.
Before any of that though, would be nice to know if there's even interest in merging this eventually ;-)
There was a problem hiding this comment.
The point of respecting the condition would be that if the user has set ImplicitUsings=false, they probably don't want Spectre.Console added to the Using item type. It's a way of saying "I don't want implicit usings coming from parts of the build that I can't see" while still having the ability to add usings directly in your project file.
There was a problem hiding this comment.
That's not how that property works. It turns off global usings from MSBuild items entirely. See https://twitter.com/kzu/status/1430001920022831110?s=19
There was a problem hiding this comment.
I'm not seeing what you're seeing? All I see is that it prevents the SDK from adding its default usings. The SDK will still generate a usings file if the Using item type is non-empty.
|
We've let this one hang out seeing where the .net world landed on global usings. Seems devs are handling the imports on their own and packages aren't including them. Plus tooling is becoming more common to assist those not familiar with the syntax. I'm gonna close this PR. Appreciate the thought, but just not a feature we want to push. |
The new C# 10 feature lights up automatically via the provided item group with the
Importelement.There's talk of a future opt-out (or opt-in?) MSBuild property to control these global usings, but the provided approach will work and integrate seamlessly with whatever the project/SDK configures.
For reference, see dotnet/aspnetcore#32451.
Note we provide the "legacy" MSBuild xmlns attribute so as not to break downlevel IDEs or legacy project files that happen to reference this package.
Fixes #515