[Proposal] public internal #2283
-
Public exposure, Internal consumption. Classes and Interfaces with this keyword combination are exposed as public members but can't be inherited/implemented outside the assembly, they are for internal consumption only. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
So basically, you want |
Beta Was this translation helpful? Give feedback.
-
Yes |
Beta Was this translation helpful? Give feedback.
-
Difficult to be sure here, as DIMs in C# 8 are still a bit of an unknown, but in theory, public IInternalImplementationOnly
{
internal void InternalOnlyImplementationGuard();
} should cover this already as only internal classes can implement |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
It looks like java 15 is implementing some feature similar to this, sealed classes/interfaces, sealed here meaning that these classes/interfaces can only be inherited/implemented by the types specified by I would proprose it as public closed interface IFoo
allows Foo
{
void Bar();
} So the interface is publicy exposed, but can only be implemented by Foo, no other class/type can implement it. I'm not sure how would this work with interface inheritance but I would guess they would inherit the same restriction or would it have to be explicit? What do you think guys? |
Beta Was this translation helpful? Give feedback.
Duplicate of #485, #1716, #1790.