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.57k stars 3.96k forks source link

Intellisense not recognizes extension methods for generic classes from .NET Standard 2.0 references #73302

Open vsfeedback opened 2 weeks ago

vsfeedback commented 2 weeks ago

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


[severity:It’s more difficult to complete my work]
I have a .NET Standard 2.0 Library in which I have defined this extension class.

public static class MyExtension
{
  public static void ExtendEnumerable<T>(this IEnumerable<T> items) { }

  public static void ExtendTObject<T>(this T tObject) { }
}

There is a second .NET 8 project which references the .NET Standard 2.0 library. From whithin the .NET 8 project Intellisense doesn’t recognize ExtendEnumerable<> when the namespace is not already imported. It does tho recognizes ExtendObject<> and it also recognizes MyExtension class and imports the using properly.
Visual Studio option Text Editor > C# > Intellisense > Show items from unimported namespaces is enabled.

I provided a little sample project which contains the same extension class defined in 3 different frameworks. While ExtendTObject<> gets recognized correctly, ExtendEnumerable<> does so only for . NET6 and . NET8 libraries. See screenshot below:

B8487abafcd354e8094e20a1ec0e7ea6b638499749695837313_Screenshot_2024-04-29_093645


Original Comments

Feedback Bot on 4/29/2024, 03:59 AM:

(private comment, text removed)


Original Solutions

(no solutions)

genlu commented 2 weeks ago

This might have something to do with SymbolKey