System.ComponentModel.EditorBrowsable was written by idiots

This post is to remind myself that the EditorBrowsableAttribute was written in such a way that it isn’t really usable by anyone other than framework developers. Essentially this attribute is supposed to provide Visual Studio with a hint as to whether a property/method/field/class/struct etc should be visible in Intellisense or in the visual designers. In my case I wanted to hide certain properties from intellisense, not because they couldn’t be used but because in most cases there is a better way to do the task (I’m not hear to argue whether this is the correct way to handle this or not). You’d expect the following to hide MyProperty from intellisense.

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public int MyProperty { get; set; }

Unfortunately there are a couple of conditions that need to be met in order for this to work.

1) The item that you’re applying the EditorBrowsable attribute to has to be declared in a separate assembly from the one you’re consuming it in.

2) It isn’t enough to just place the item in another project within the same Visual Studio solution – it has to be an assembly reference (ie not a project reference).

The second point is the one I don’t get – why doesn’t this work for project references. The work around is to reference the built version of the assemblies, but that introduces all manner of issues with Visual Studio and deployment. Honestly, who designed this stuff?

Leave a comment