[英]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. 问题是,当我在客户端应用程序中使用此类库时,这些名称空间显示在intellisense上。 of course, they contain no accessable 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). 当外部使用时,intellisense将显示:mynamespace.yournamespace但不提供任何成员(因为它们是内部的)。
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? 那么问题是,有没有办法阻止那些内部课程出现在intellisense中,或者我只是担心什么? 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.) (有一个类似的帖子: 我如何防止提供扩展方法的公共类出现在Intellisense中?这是不确定的。)
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. 您可以尝试使用
EditorBrowsableAttribute
- 它被记录为隐藏在不同程序集中定义的类的成员,但如果它是相同的程序集则使其保持可见。 Sounds perfect for internal
- although I haven't tried it myself. 对于
internal
听起来很完美 - 虽然我自己没有尝试过。
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." 我想它在你的链接问题中不起作用,因为它仅用于属性或方法:“指定在编辑器中可以查看属性或方法。”
No, I don't think there is a way. 不,我认为没有办法。
Based on the error 基于错误
Error 1 A namespace declaration cannot have modifiers or attributes
错误1名称空间声明不能包含修饰符或属性
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. 可能已经完成的唯一(?)其他方式是在Intellisense设置中使用包含/排除列表,但它们不在那里。
试试这个答案自定义intellisense服务器控件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.