Skip to content

Automatically provide global using#516

Closed
kzu wants to merge 1 commit intospectreconsole:mainfrom
kzu:global_usings
Closed

Automatically provide global using#516
kzu wants to merge 1 commit intospectreconsole:mainfrom
kzu:global_usings

Conversation

@kzu
Copy link
Contributor

@kzu kzu commented Aug 20, 2021

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

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
@CLAassistant
Copy link

CLAassistant commented Aug 20, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<Import Include="Spectre.Console" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Using? See: dotnet/sdk#19599

Also, how about respecting ImplicitUsings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ;-)

Copy link

@alexrp alexrp Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@phil-scott-78
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically provide global using for Spectre.Console

5 participants