roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

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

Open vsfeedback opened this issue 1 year ago • 1 comments

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)

vsfeedback avatar May 02 '24 13:05 vsfeedback

This might have something to do with SymbolKey

genlu avatar May 02 '24 18:05 genlu