Visual Studio IntelliSense - IHideObjectMembers trick doesn't work. What am I missing?

Posted by stakx on Stack Overflow See other posts from Stack Overflow or by stakx
Published on 2010-05-31T19:10:35Z Indexed on 2010/05/31 19:13 UTC
Read the original article Hit count: 256

The IHideObjectMembers trick can be used e.g. in fluent interface implementations to hide System.Object members from IntelliSense. (If you don't know this trick, you can read up on it via the above link; I'm just repeating the interface's usual declaration here:)

using System;
using System.ComponentModel;

[EditorBrowsable(EditorBrowsableState.Never)]
public interface IHideObjectMembers {

    [EditorBrowsable(EditorBrowsableState.Never)]
    Type GetType();

    [EditorBrowsable(EditorBrowsableState.Never)]
    int GetHashCode();

    [EditorBrowsable(EditorBrowsableState.Never)]
    string ToString();

    [EditorBrowsable(EditorBrowsableState.Never)]
    bool Equals(object obj);
}

I'm now supposed to be able to hide System.Object members on another type as follows:

public class SomeClass : IHideObjectMembers { ... }

or:

public class ISomeInterface : IHideObjectMembers { ... }

I tried this in both VS 2008 Express and VS 2008 Standard. However, no members are hidden from IntelliSense at all. I have used the EditorBrowsableAttribute in different projects and it always worked well; however, it doesn't work in this particular scenario.

If things had worked as expected, I would only have seen the SomeMethodTwo method.

Am I missing something?

© Stack Overflow or respective owner

Related posts about visual-studio-2008

Related posts about filter