Code-completion can't hide overridden virtual members

SyntaxEditor for WPF Forum

Posted 7 years ago by Frank Audun Kvamtroe
Version: 12.2.0570
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

I'm having problem figuring out how to hide overridden virtual members in the Syntax Editor code-completion of C# classes using the EditorBrowsable attribute. I'm trying to hide common members like Equals, GetHashCode and ToString using the following methodology:

public class BaseClass
{
    public BaseClass() {}

    [EditorBrowsableAttribute(EditorBrowsableState.Never)]
    public override bool Equals(object obj) { return base.Equals(obj); }

    [EditorBrowsableAttribute(EditorBrowsableState.Never)]
    public override int GetHashCode() { return base.GetHashCode(); }

    [EditorBrowsableAttribute(EditorBrowsableState.Never)]
    public override string ToString() { return base.ToString(); }
}

public class DerivedClass : BaseClass
{
    public BaseClass() {}
}

It doesn't matter if I instanciate the DerivedClass or the BaseClass, the code-completion shows Equals, GetHashCode and ToString in any case.

This methodology is fairly common in different editors (including the Visual Studio editor) and I would expect it work the same way in the Actipro Syntax Editor as well.

Is this a bug or is there some other way to be able to hide overridden virtual members?

Comments (1)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Frank,

Thanks for letting us know about this.  It looks like while the member is ignored by our resolver when it examines BaseClass, it also goes to the base class of that (Object) to see which members are there and finds them again without the EditorBrowsableState setting, so they get added there.

We've corrected the behavior for the next version.  In the meantime you might need to override the completion provider's OnSessionOpening method and remove the completion items for those members.  OnSessionOpening fires before the completion session displays.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.