Automatically seal not-derived internal and private classes #4573
Replies: 4 comments 2 replies
-
dotnet/runtime#49944 will offer a code fix for it, assuming the project goes ahead. |
Beta Was this translation helpful? Give feedback.
-
As discussed in dotnet/runtime#49944 this can't be done automatically because types can be created at runtime via reflection.Emit |
Beta Was this translation helpful? Give feedback.
-
The compiler can't know enough to seal automatically; but the developer can - and it's an easy change. |
Beta Was this translation helpful? Give feedback.
-
See this discussion on why the JIT can't automatically seal types: dotnet/runtime#49944 . Many of those arguments also apply here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I saw this:
dotnet/runtime@bdc8e42
And it made me think that, since the compiler knows if a class is derived, this is something the compiler could do automatically. Or at least offer a code fix for it.
Beta Was this translation helpful? Give feedback.
All reactions