Reputation: 58615
I'm writing a class library and came across the need to make a namespace internal. I'm doing that because there's some auto-generated code coming from XSD, in order to have no collisions.
However, does wanting a namespace to be internal make any sense at all? I know it's not possible. I read this ( Internal Namespace for .Net? ), amongst others.
What I'm asking is, if you think you want/need an internal namespace, what can be improved in your architecture/design? What should I move around in order to get rid of the false need to have an internal namespace?
Upvotes: 1
Views: 1547
Reputation: 78467
Use /namespace:<namespace>
attribute, when you generate classes from XSD, using xsd.exe
tool.
XML Schema Definition Tool (Xsd.exe)
/n[amespace]:namespace
- Specifies the runtime namespace for the generated types.
If you have a typed DataSet, that was generated based on XSD, you can change Customer Tool Namepsace
in DataSet properties.
Also, if your code is not bound to auto-generated DataSet and design tool, you can just change namespace manually, of course if you don't have to regenerate classes often.
If you need to generate classes often, make a bat (cmd) file that would run xsd.exe with the namespaces and class names that you want.
Also, if serialize/deserialize XML using XmlSerializer, you can't make classes internal.
Upvotes: 1
Reputation: 1501896
No, namespaces themselves have no particular accessibility. It's only the members of a namespace (types, basically) which have accessibilty. Simply make all the types in the namespace internal instead.
Upvotes: 2