R# 5.1.1 and EditorBrowsableAttribute

Hi,

I'm playing around with fluent interfaces and found various sites that show how to use EditorBrowsableAttribute and EditorBrowsableState.Never to hide the standard object members ToString(), GetType() and the like.

VS2010 does not honour that attribute if you are either inside the same assembly or add a project reference (as opposed to a reference to the compiled dll) to the code decorated with the attribute.

Nor does ReSharper v5.1.1 as it seems. Although I found the appropriate settings in ReSharper -> Options -> IntelliSense -> Completion Appearance -> Filter Members by [EditorBrowsable] attribute it keeps showing me the members decorated with the attribute (no matter wether I am inside the same assembly or another, I did not bother trying to reference the compiled dll).

Does this function have the same limitations as IntelliSense? Am I missing something?

Thanks for your help!

6 comments
Comment actions Permalink

Hello Sebastian,

I'm afraid I couldn't reproduce this behavior. Could you please attach a
small sample along with a screenshot of ReSharper | Options | IntelliSense
| Completion Appearance options tab? Thank you!

Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi,

I'm playing around with fluent interfaces and found various sites that
show how to use EditorBrowsableAttribute and
EditorBrowsableState.Never to hide the standard object members
ToString(), GetType() and the like.

VS2010 does not honour that attribute if you are either inside the
same assembly or add a project reference (as opposed to a reference to
the compiled dll) to the code decorated with the attribute.

Nor does ReSharper v5.1.1 as it seems. Although I found the
appropriate settings in +ReSharper -> Options -> IntelliSense ->
Completion Appearance -> Filter Members by
attribute+ it keeps showing me the members decorated with the
attribute (no matter wether I am inside the same assembly or another,
I did not bother trying to reference the compiled dll).

Does this function have the same limitations as IntelliSense? Am I
missing something?

Thanks for your help!

---
Original message URL:
http://devnet.jetbrains.net/message/5273578#5273578



0
Comment actions Permalink

Hello Andrey,

I attached screenshots of the IntelliSense settings and the behavior inside the editor as well as a zip with a code sample.

Thanks for your help!

Sebastian

ReSharperIntelliSenseSettings1.png
IntelliSense1.png



Attachment(s):
HideMembers.zip
0
Comment actions Permalink

Hello Sebastian,

This happens because c.ToString(), c.GetType() etc methods resolve into System.Object.ToString(),
System.Object.GetType() correspondingly (and not into IFluentInterface.ToString,
IFluentInterface.GetType) which do not have on them.
Thank you!

Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Andrey,

I attached screenshots of the IntelliSense settings and the behavior
inside the editor as well as a zip with a code sample.

Thanks for your help!

Sebastian

Image:ReSharperIntelliSenseSettings1.png
Image:IntelliSense1.png
---
Original message URL:
http://devnet.jetbrains.net/message/5273660#5273660



0
Comment actions Permalink

Well this explains the behavior but leaves the feature as useless to me as that of the original IntelliSense...

Thanks anyway

0
Comment actions Permalink

You can either override and decorate the members in the ClassWithHiddenMembers class, or use the class via an interface which implements the IFluentInterface interface. I've used the second option before, and R# works perfectly.

public interface IClassWithHiddenMembers : IFluentInterface
{
    string Foo { get; set; }
    string Bar();
}

public class ClassWithHiddenMembers : IClassWithHiddenMembers
{
    public string Foo { get; set; }
    
    public string Bar()
    {
        return string.Empty;
    }
}

public class Class1
{
    public void FooBar()
    {
        IClassWithHiddenMembers c = new ClassWithHiddenMembers();
        c.
    }
}
0
Comment actions Permalink

That was the crucial piece that was missing! I let my class inherit from IFluentInterface and then used that class directly. When I add the additional abstraction of an interface that inherits from IFluentInterface I get the expected behavior.

Thank you very much, you just made my day :-)

0

Please sign in to leave a comment.