dotnet / dotnet/roslyn

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

Open
#73,302 1 comment 0 reactions 1 assignee Claimed by @genlu View on GitHub
Area-IDE Bug IntelliSense-Completion
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Intellisense-not-recognizes-extension-me/10648843)._

---
\[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(this IEnumerable items) { }

public static void ExtendTObject(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](https://github.com/dotnet/roslyn/assets/1408396/14294e40-d424-4d03-99b8-ee156762a7a2)

---
### Original Comments

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

(private comment, text removed)

---
### Original Solutions
(no solutions)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.