开发者

Keeping namespaces for internal classes from appearing in intellisense

I am writing a class library that contains classes with purely internal members. I have these divided into namespaces. There are no public or protected members in these internal classes.

The thing is, when I use this class library in a client application, these namespaces show up on intellisense. of course, they contain no accessabl开发者_运维百科e items, so it just ends, but I am worried that this may confuse users of the library

example:

    namespace mynamespace.yournamespace  
    {  
        internal class blah  
        {  
            internal void function1(){};  
            internal void function2(){};  
        }  
    }  

When used externally intellisense will show for: mynamespace.yournamespace but not offer any members (because theyre internal).

The question then, is, is there a way to prevent those internal classes from showing up in intellisense, or am I just worried about nothing? or.....if its internal, does it even need its own namespace?

Any help appreciated

(there is a similar post at: How can I prevent a public class that provides extension methods from appearing in Intellisense? that was inconclusive.)


No, I don't think there is a way.

Based on the error

Error 1 A namespace declaration cannot have modifiers or attributes

I don't see how you could specify that a namespace should be hidden.

The only (?) other way this might have been done is with include/exclude lists in the Intellisense settings but they're not there.


You can try EditorBrowsableAttribute - it is documented to hide a member of a class defined in a different assembly, but keeps it visible if it's the same assembly. Sounds perfect for internal - although I haven't tried it myself.

I guess it didn't work in your linked question because it's intended for properties or methods only: "Specifies that a property or method is viewable in an editor."


Try this answer Custom intellisense for server controls?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜