33

I tried to hide inherited property in intellisense with EditorBrowsable (as said here Hiding user control properties from IntelliSense), when testing in client form though I can still see it why ?

[
Category("Main"),
Description("Text"),
Obsolete("Don't use this"),
Browsable(false),
EditorBrowsable(EditorBrowsableState.Never)
]
public override String Text
{
    get { return null; }
}
Community
  • 1
  • 1
user310291
  • 36,946
  • 82
  • 271
  • 487

4 Answers4

45

Are you using ReSharper? It seems like ReSharper doesn't obey the EditorBrowsable attribute.
If I turn off ReSharper, I don't see my property. If I turn ReSharper on, it does show.

In ReSharper Options, go to Environment | IntelliSense | Completion Appearance and check "Filter members by [EditorBrowsable] attribute".

You still have to reference the assembly though, it doesn't work within a solution if you reference your usercontrol's project.

Pang
  • 9,564
  • 146
  • 81
  • 122
comecme
  • 6,086
  • 10
  • 39
  • 67
  • 1
    No I'm not using Reshaper. I have opened the client project in another solution and point to the dll from toolbox and I can still see Text property in intellisense. I think I'll give up seems too irational for me :) – user310291 Dec 14 '10 at 22:41
  • that worked for me, as I am using resharper. Even with the same solution when referenced as a project it works. thank you! – afif Apr 22 '12 at 12:45
  • Thanks! After hours trying to make it work, I read your answer and voilá! Works flawlessly now. Thanks, I'd never thought resharp was causing it. – Retired_User Jan 29 '13 at 23:30
  • To me it seems like Resharper can actually enforce obeying of this attribute where VS does not. If I disable Resharper, the attribute does not work - only when I enable Resharper and set this filtering, then it works. Verified in 2015 and 2017. – Bartosz Dec 17 '18 at 09:23
27

I repro. There is a Note in the MSDN article about this:

In Visual C#, EditorBrowsableAttribute does not suppress members from a class in the same assembly.

Oddly, I don't see it suppress it either when I put the UserControl in a different assembly in the same solution.
You may want to ping connect.microsoft.com about this, something isn't right.

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
15

As said in this answer's comments:

editorbrowsable only hides the method if you're just importing the dll, not if you're referencing another project in the solution i think

Community
  • 1
  • 1
Jerther
  • 5,558
  • 8
  • 40
  • 59
-2

Have you tried this:

Visual Studio > Tools > Options > General > Hide Advance Members

Check the "Hide Advance Members", remember that, in Visual C#, EditorBrowsableAttribute does not suppress members from a class in the same assembly.

EditorBrowsableAttribute Class

Pl4tinum
  • 123
  • 15