How to Hide inherited Object members from intellisense?  
Author Message
Robuz





PostPosted: Tue Sep 13 16:30:22 CDT 2005 Top

Visual C#.Net >> How to Hide inherited Object members from intellisense? ..Such as ToString(), Equals(), etc.

[EditorBrowsable(EditorBrowsableState.Never)]
public override String ToString() { return base.ToString(); }

The above doesn't work.

Any ideas? And before you ask, Yes I do have a sane reason for wanting
to do this.

DotNet416  
 
 
Chris





PostPosted: Tue Sep 13 16:30:22 CDT 2005 Top

Visual C#.Net >> How to Hide inherited Object members from intellisense? EMail@HideDomain.com wrote:
> [EditorBrowsable(EditorBrowsableState.Never)]
> public override String ToString() { return base.ToString(); }
>
> The above doesn't work.
>

Have you tried just the Browsable attribute?

[Browsable(false)]
public int MyProperty {
get {
// Insert code here.
return 0;
}
set {
// Insert code here.
}
}

 
 
wackyphill





PostPosted: Tue Sep 13 21:50:32 CDT 2005 Top

Visual C#.Net >> How to Hide inherited Object members from intellisense? Browsable refers to the property window not intellisense when you are
coding.

 
 
Chris





PostPosted: Wed Sep 14 08:41:10 CDT 2005 Top

Visual C#.Net >> How to Hide inherited Object members from intellisense? So it does! My mistake.

I just tried the EditorBrowsable attribute on a property and also on a
method and it worked correctly. I then tried it on an overridden
ToString method and it *did not* work on that method.

Next I created a simple class with one overridable method and a derived
class that overrides the method with an additional method that was not
part of the base class. It seems that if the overridden method is
hidden using the EditorBrowsable attribute, then the base class method
is exposed. This was coded in VB.Net. I then repeated the test in C#
but the EditorBrowsable attribute seemed to have no effect either way.


It seems very strange.

 
 
wackyphill





PostPosted: Wed Sep 14 09:21:26 CDT 2005 Top

Visual C#.Net >> How to Hide inherited Object members from intellisense? Yeah, I don't understand it really. I'm not really interested in
overriding just hiding the methods from the intellisense window.

I guess what I'd really like to do is apply the EditorBrowsable
attribute to an inherited method like ToString(); Just don't know how.

I wish something like this would work to do it:

class MyClass : Object
{
MyClass() {}

[EditorBrowsable(EditorBrowsableState.Never)]
public String ToString();
}

Of course it's not valid but that's my intent. Thanks for the
investigative effort Chris.