Reflection Emit doesn't allow nested types in interface, even though C# 8 does #112088
Replies: 2 comments
-
You may open an issue to summarize missing cases for nested type support. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I misunderstood the meaning of SetParent -- it's for setting the base type from which members are inherited, not the enclosing type of a nested type. |
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.
-
C# 8 allows "member declarations that declare constants, operators, static constructors, and nested types" in an interface, according to Default interface methods - C# feature specifications. However, the reflection emit APIs still do not allow setting an interface as the parent of a type. SharpLab
Code that disallows interfaces is here:
runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.cs
Lines 1691 to 1692 in 9d5a6a9
runtime/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.Mono.cs
Lines 1487 to 1488 in 9d5a6a9
runtime/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs
Lines 565 to 568 in 9d5a6a9
runtime/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Lines 960 to 962 in 9d5a6a9
runtime/src/libraries/System.Reflection.Emit/src/Resources/Strings.resx
Lines 123 to 125 in 9d5a6a9
Noticed while looking at #112072. I'm posting this as a discussion rather than an issue because this is more a missing feature than a bug, and because I have not needed the feature. Nested types were not mentioned in #50129 and #9478.
Beta Was this translation helpful? Give feedback.
All reactions