-1

I need to restrict access to some of the methods in a class intellisense. I don't want this method to disappear completely from the intellisense in some other classes. I mean the visibility of these methods in intellisense depends on the class which wants to use the method. How can I reach to the intellisesne with C# code? I want to define an attribute for methods and then according to that customize the intellisense based on every client access level. Thanks.

seti
  • 11
  • 3
  • You might want to check related questions like http://stackoverflow.com/questions/9086136/how-to-hide-public-methods-from-intellisense – Progman Apr 17 '17 at 12:43

2 Answers2

0

You can create an interface with a subset of the class methods and work only against the interface. This way IntelliSense only sees the methods from the interface, not the additional methods of the class which implements the interface.

Progman
  • 16,827
  • 6
  • 33
  • 48
  • Thank you Progman, but this does not solve my problem, the other teams in the company cannot change their injected interface apparently. – seti Apr 19 '17 at 11:49
0

I found the answer. I should use EditorBrowsableAttribute. It has a property which should be set to Never. like this: [EditorBrowsable(EditorBrowsableState.Never)] public void myMethod(){} MsDN says that this setting hides the method from the projects outside the assembly. However when I tested it, it hides the method from intellisense in projects outside the solution which have added my dll. But it does not hide it from projects which are inside my solution and have the dll. I don't know why but anyways it solved our problem.

seti
  • 11
  • 3