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.95k forks source link

"Conceptual" Search is required as C# syntax evolves #72955

Open vsfeedback opened 1 month ago

vsfeedback commented 1 month ago

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


With all the modern features of C# including expression simplification, searching for terms and pattern matching becomes naive and prevents you from being able to find code by intent easily.

For instance, consider searching for all the locations where "MyObject" is constructed such as "new MyObject". The problem here is that with expression simplification, often times the expression is written, and by default always suggested, as

MyObject instance = new()

While there are other ways of finding object instantiation using references or implementation, often it is much quicker to search on a "pattern". However in this case, instances of MyObject construction are missing in the search results due to not being a direct match of the exact terms as naively written.

In cases such as this, searching symantically or conceptually based on the intent of the search expression rather then on the exact terms would be prefered. In the case above, look for all instances of what appears to be instantiation of MyObject and match on all patterns possibly in C# to instantiate that type, including simplified expression forms.

Mabye this doesn't fit directly in the text search feature , but as C# evolves to become more functional and less verbose, and offering numerous ways of writing expressions differently with the same intent, searching by conceptual patterns rather then by directly comparing terms or characters will be needed.


Original Comments

Feedback Bot on 4/8/2024, 09:21 PM:

(private comment, text removed)

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

CyrusNajmabadi commented 1 month ago

@tmat sounds like something possibly covered by SemanticSearch. Having a snippet to show how to do this would be good :)