简体   繁体   English

保持内部类的名称空间不会出现在intellisense中

[英]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设置中使用包含/排除列表,但它们不在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可以在其他命名空间中访问内部类吗? - Can internal classes be accessed within other namespaces? 内部类具有相同的命名空间但在不同的程序集中? - Internal classes having the same namespaces but in different assemblies? 从IntelliSense隐藏名称空间或更改建议名称空间的顺序(自定义IntelliSense) - Hide namespace from IntelliSense or change order of suggested namespaces (Customizing IntelliSense) VS 在 cshtml 文件中没有智能感知,未添加来自 web.config 的命名空间 - VS no intellisense in cshtml file, namespaces from web.config not added 访问来自不同命名空间中的不同类的变量 - Access a variable from different classes that are in different namespaces Intellisense没有出现在DbSet类中 - Intellisense not appearing for DbSet class MVC5将脚手架用于其他名称空间中的类(引用的DLL) - MVC5 using scaffolding for classes from other namespaces (referenced DLL) 将名称空间保留在C#soapservice中 - Keeping the namespaces in c# soapservice 组织目录中的命名空间和类 - Organizing namespaces and classes in directories 使用名称空间将类序列化为XML - Serialize classes to XML with namespaces
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM