dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.9k stars 4.01k forks source link

Lightbulbs to add usings blocked by similar namespaces #61880

Open dpugh opened 2 years ago

dpugh commented 2 years ago

Version Used: 32611.49.main

Steps to Reproduce: I’ve noticed that I’m not getting as many lightbulbs to add missing usings as I have before (this problem has probably been around a while but I just hit an egregious case today). See below for more details but expected an “add using” lightbulb to appear in this situation. Is my expectation wrong or did something break?

image

The error would be resolved with an added "using Microsoft.VisualStudio.IntelliCode.Core;" but that is apparently being blocked because there is also a "Microsoft.VisualStudio.Utilities" that is confounding the analyzer: image

Based on discussions with Cyrus/Jason it seems this is expected (but annoying) behavior because of the confounding namespace. That said, it would be nice if the added using was proposed as a suggestion since it would fix the problem.

CyrusNajmabadi commented 2 years ago

Note: this will only work in David's case, because he has usings inside a namespace, and so the new using will take precedence over the symbol found in the containing namespace.