dotnet / dotnet/roslyn

Custom Grouping of methods and properties in IntelliSense

Open
#75,688 0 comments 0 reactions 1 assignee Claimed by @genlu View on GitHub
Area-IDE
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/Custom-Grouping-of-methods-and-propertie/10764524)._

---
Hi there,
I would like to have an ability, to create custom [Redacted] of methods and properties found in my class.
It is awesome, that you can now filter only properties, or only events, or only methods and so on…
That is very nice, but this would be like custom grouping of some class by my custom idea of separate functionality.
For example, some classes could have a lot of methods, and each one could be categorized as either:
1. Getter Methods / 2. Action Methods / 3. Verify Methods

So this is 1 example of my custom grouping.

Right now, I have 2 options:

1. Either prefix every method with these group name: (Get\_SomeMethod, Action\_OtherMethod, VerifyMethod)
2. Or create 3 classes just for grouping and call them Get, Action and Verify, and so when seeing IntelliSense I would just see these 3 properties, and when I choose 1 of them (let’s say Get) and write the dot, then I would see just those getter methods…

But both of these aproaches have drawbacks:

1. This approach is making methods names much longer when called, which is undesirable.
Only because I want a user of my class to easily use it, it makes the code unnecessarily longer and harder to read.
2. This approach is even slowing down the execution of the code, needing to first get some property instead of directly
call the desired method or property. It makes my code unnecessarily harder to create…

So, what I have in mind, is to use something like #region directive, it could be called whatever name you come up with, like #intellisenseRegion, or #intellisenseGroup or whatever, and when putting this new directive around some of my classes or methods, it would automatically tell the IntelliSense to use this custom grouping 😃

For example, I am now working on my little library on top of UIAutomation, and I have created a class called Button.
![image.png](https://aka.ms/dc/image?name=Bbb96aefe8ea046b7995f7d2699eb1a7f638640723942821597_20241009-140633-image.png&tid=bb96aefe8ea046b7995f7d2699eb1a7f638640723942821597)

As you see, I used #region to clearly group the available functionality by patterns that could be found on button.
If I could just switch #region directive to #intelliSense directive, and this would clearly be communicated to the user, that is all I want.

Now imagine those 2 currently available approaches:

1. The first one would look like this when called: someButton.InvokePattern\_Invoke()
2. The second one would look like this when called: someButton.InvokePattern.Invoke()

But I would like to just have it like this: someButton.Invoke()
And those groups would be only seen in IntelliSense.

So I hope it is very clear what I have in mind.
What do you think about this feature?
If you implement it, many many users in many many cases would be so happy to use it, I believe.

Thanks for your awesome work with Visual Studio 😃
Peter Hevesi
![image.png](https://aka.ms/dc/image?name=Bc9ee72b7763d4a72b8a0dd3bb1732181638640726554913644_20241009-141055-image.png&tid=c9ee72b7763d4a72b8a0dd3bb1732181638640726554913644)

---
### Original Comments

#### Feedback Bot on 10/9/2024, 11:35 PM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about a week on our next steps.

#### Peter Hevesi on 10/10/2024, 04:28 AM:

And it could also work in a way, in which I could make let’s say SomeMethod(string) into 1 IntelliSense group, but other method with the very same name but different parameters SomeMethod(DateOnly) could go into another IntelliSense group without any problem.

#### Peter Hevesi on 10/25/2024, 04:31 AM:

It would also allow to filter out the basic Object functionality (GetHashCode, ToString, GetType…) to belong it it’s own section, so it would finally not mix up with the functionality of the class itself, which would be super awesome 😃

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.