VS IntelliSense - IFluentInterface / IHideObjectMembers trick does not work. Why?
This trick only works when you are using types that are included in referenced DLLs. These referenced assemblies cannot be Visual Studio project references. If you reference the DLL themselves, then the trick should work for you.
Before a working solution was posted (see above), I researched and experimented a bit, and found out this:
IntelliSense needs to be told to ignore properties marked with an
EditorBrowsableState
equallingAdvanced
orNever
. This is achieved in Visual Studio via the menu item Tools → Options... → Text editor → C# → IntelliSense → Hide advanced members.The
IHideObjectMembers
trick works only from "other" assemblies, and only when the project that makes use ofIHideObjectMembers
is not loaded in the same solution.Hiding non-static members of
object
sometimes doesn't work when done via aIHideObjectMembers
interface, but it works when the methods are explicitly overridden directly in the class... which unfortunately makes the shown hiding technique less useful.
Sources of these clues:
Blog article How to keep the Intellisense info box short and tidy on exdream.com.
The MSDN reference page for
System.ComponentModel.EditorBrowsableAttribute
.
The trick works if you don't use
var x = new SomeClass();
but explicitely use the interface that inherits from IHideObjectMembers
ISomeInterface x = new SomeClass();
var
takes the Type of the concrete class. Thus IntelliSense will look for object.ToString()
and not IHideObjectMembers.ToString()
. The former is not decorated with the EditorBrowsableAttribute
while the later is.
Daniel Cazzulino explicitely refers to interfaces in his post
we’ve done this with all the interfaces in our fluent API