Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global using list missing using aliased global usings #76569

Open
vsfeedback opened this issue Dec 26, 2024 · 1 comment
Open

Global using list missing using aliased global usings #76569

vsfeedback opened this issue Dec 26, 2024 · 1 comment
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
Global usings with aliases do not show up in global using list

<ItemGroup>
	<Using Remove="System.Net.Http"/>
	<Using Include="NodaTime" Alias="MyTime"/>
</ItemGroup>

<ItemGroup>
		<PackageReference Include="NodaTime" Version="3.2.0" />
	</ItemGroup>

Save and build. Confirm that your alias is available (attach 1)

Click the glyph. MyTime is missing (attach 2)

I initially thought this was just via the project file, but further experimentation shows it also occurs with aliases in a global using in the project.

I really enjoy how excited folks get in talks when I show them this glyph. However, I also show that they can use aliases in project files, so this bug shows up. Please fix.


Original Comments

Feedback Bot on 11/24/2024, 08:43 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 26, 2024
@KathleenDollard
Copy link

It may be simpler to understand this with the following example. (For example, the removal of another global using is irrelevant). This is all in relation to the fantastic feature of showing global usings via a glyph at the top of the file. I believe I did something to turn this on, but cannot find the setting.

Image

There are three problems, in decreasing order of seriousness:

  • Adding an alias causes a global using to disappear from the list of global usings
  • You need to rebuild several times to get the list to update
  • Aliases do not appear

The first, and to a lesser degree the second, make the list appear unreliable.

Start a normal console app and paste this into the .csproj file:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<TargetFramework>net9.0</TargetFramework>
		<ImplicitUsings>enable</ImplicitUsings>
		<Nullable>enable</Nullable>
	</PropertyGroup>

	<ItemGroup>
		<Using Include="NodaTime"/>
		<Using Include="System.Linq" Alias="LinqStuff"/>
	</ItemGroup>

	<ItemGroup>
		<PackageReference Include="NodaTime" Version="3.2.0" />
	</ItemGroup>

</Project>

Note, that NodaTime does not have an alias.

Clicking the glyph at the top of the file to display global usings (fantastic feature) shows:

Image

Now, add an alias to NodaTime:

		<Using Include="NodaTime" Alias="JonsTime"/>

Rebuild a couple of times. Then the glyph fails to show NodaTime at all:

Image

@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Jan 1, 2025
@CyrusNajmabadi CyrusNajmabadi added Navigation-Inheritance Margin Inheritance margin and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants