Hiding namespaces containing only internal types in a class library?

I have a class library that has a pair of namespaces containing only internal types.

However, when using the class library in the application project, the namespaces are displayed in intellisense, but of course they are empty. Is there a way to completely hide namespaces when using intellisense in other projects?

I tried to apply EditorBrowsableAttribute to all inner classes, but what I would like to do is apply this to the namespace, which of course is not possible.

Or, if I don’t care, is the only option that I should simply move the types to a namespace that contains public types?

+42
c # namespaces hide internal intellisense
Apr 06 '09 at 8:47
source share
2 answers

It depends on how you reference your class library:

  • If you have a class library project contained in your solution and use the project link, you will always see an empty namespace through Intellisense.
  • If you reference the compiled dll of your class library, you will not see the namespace appearing in intellisense if it contains only internal members.

Try the following:

 namespace ClassLibrary1 { namespace Internal { internal class InternalClass { public int internalStuff { get; set; } } } namespace Public { public class PublicClass { public int publicStuff { get; set; } } } } 

If you reference this using a project link, you will see an empty namespace. If you reference the DLL, you will not.

+43
Feb 19 2018-12-12T00:
source share

I came across this before and did not find a solution that may or may not work in your project. Instead of defining a namespace, can you use a nested static class?

+5
Apr 06 '09 at 8:51
source share



All Articles