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
19.02k stars 4.03k forks source link

Intellisense - more name suggestions for types implementing IEnumerable #52508

Closed vsfeedback closed 3 days ago

vsfeedback commented 3 years ago

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


I'm using C# in vanilla VS2019 Community 16.8.2, porting a project from .NET Framework 4.5.2 that I developed in vanilla VS2017 Community to .NET 5.0 (just in case Intellisense behaves differently depending on the target platform) and have run into an annoying issue with Intellisense. I've got a situation where I have an interface that inherits from IEnumerable<T>:

IQueryable<TQuery, TData> : IEnumerable<TData>
{
    void Query(TQuery, Action<TData>);
}

There are many concrete types that can be queried for one or more things, most of which are not primarily used for the purpose of querying --- this is just a useful abstraction for a separate problem.

VS2019 has this annoying feature of insisting that Foo : IQueryable<TQuery, Bar> should be named bars, presumably because it implements IEnumerable<Bar>, to the point of not offering me the option to name it foo (for class members, it suggests bars, Bars, GetBars()). This is even worse when I have types that are queryable for multiple TData, where the suggested name is not just annoying but can be completely incorrect for the context I'm using it in, offering me only the option to name it after the TData in the first interface (e.g. Foo : IQueryable<TQuery, Bar>, IQueryable<TQuery, Qux> only gets the suggested name bars).

VS2017 did not do this, only offering me to name it foo, a much more suitable default name --- but it would save a lot of time if Intellisense would suggest all of the above options.


Original Comments

Feedback Bot on 2/4/2021, 10:27 PM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.

Youssef1313 commented 3 years ago

Most likely it was me who introduced this change in https://github.com/dotnet/roslyn/pull/50212.

sharwell commented 3 years ago

@mikadumont can you add this to your list of issues for better suggested names?

CyrusNajmabadi commented 3 days ago

Closing out due to lack of broader feedback.