Access Modifier: "namespace internal" #8224
Unanswered
Jaelid
asked this question in
Language Ideas
Replies: 2 comments 3 replies
-
This has been requested several times before... One of the principal issues is that namespaces don't really exist in dotnet; the namespace is just a prefix to the type name. This makes it trivial to simply move your type to a different namespace to gain access to a type that you shouldn't have. The answer here is an analyzer; I'm sure one exists already that will give the ability to define namespace-level accessibility or friend classes. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
On occasion I find I want to suggest to the user they shouldn't use a class as its designed for use in a specific scope. This is great if you are writing a library, just mark it as a internal and now when people reference that library its not accessible. However this is not so easily done if you're writing the library itself or an application. Instead you can nest the class inside another and make it private however now if there are several classes the file becomes big and you hit a wall if one of those classes needs to be accessed by just one other class in the same scope. So the suggestion is
internal namespace: access is limited to the same namespace
potentially
I considered "protected internal namespace" but wasn't sure what the would fully entail if talking about derived classes. Perhaps someone smarter than me can consider this
Beta Was this translation helpful? Give feedback.
All reactions