-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support structurally closed hierarchies like Discriminated Unions #42
Comments
…lkerCodeRanger#42) Detecting closed hierarchies like discriminated unions without the need to provide [Closed]-Attribute
A similar case applies even when the subclasses are not nested classes, but all the constructors of the base class are |
Yes, i did not consider private protected... could add that in another step. So if there is at least one private protected constructor and all constructors are private or private protected and all subclasses (recursively) in the compilation unit are either sealed or also have at most private protected visibility in constructor, the hierarchy is also known to be structurally closed. |
Implement support for structurally detectable closed hierarchcies (#42)
@WalkerCodeRanger |
Is this project still maintained? |
@csharper2010 Have you published your version on nuget by any chance? |
It would be helpful to detect the closed hierarchy of a class with private constructor and nested subclasses having either also a private constructor or a sealed modifier. This is a way to simulate the desparately missing discriminated unions safely in C#.
A switch expression like this should provide the error:
This would be o.k.:
The text was updated successfully, but these errors were encountered: