You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey guys,
I wasn't sure where the right place it ask is. But let me explain first...
I'm working on some low-level stuff where I need to work with IL and the ECMA-335 specification. While looking at generics I noticed something that got my interest and I'm not sure if I'm misunderstanding the spec, missing some part or the spec is wrong or the current implementation is wrong (but i suppose it's the former two cases 😉)
Note that InnerGenericClassHiding´2 re-used T from GenericClassWithNestedGeneric´2. Roslyn correctly informs me about the situation, however I can compile this just fine. According to I.10.7.1 p.65 this is correct, resulting in this IL signature InnerGenericClassHiding`2<T, TV, T>. The section also states that there is no "name inheritance" but "position inheritance" .
Investigating this code on a binary level I noticed that the GenericParam (0x2a) metadata table has 3 entries for InnerGenericClassHiding´2 (as expected) however II.22.20 p.229 states the following:
There shall be no duplicate rows based upon Owner+Name [ERROR] [Rationale:
Otherwise, code using Reflection cannot disambiguate the different generic
parameters. end rationale]
According to this, if I'm not mistaken, my class should not be legals as we have a duplicate for Owner and Name. I confirmed this is a real duplicates with Mono.Cecil, ILSpy, and System.Reflection.Metadata.
I hope somebody can illuminate me on the matter
Cheers!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey guys,
I wasn't sure where the right place it ask is. But let me explain first...
I'm working on some low-level stuff where I need to work with IL and the ECMA-335 specification. While looking at generics I noticed something that got my interest and I'm not sure if I'm misunderstanding the spec, missing some part or the spec is wrong or the current implementation is wrong (but i suppose it's the former two cases 😉)
I'm considering the following (C# )Code:
Note that InnerGenericClassHiding´2 re-used T from GenericClassWithNestedGeneric´2. Roslyn correctly informs me about the situation, however I can compile this just fine. According to
I.10.7.1 p.65
this is correct, resulting in this IL signatureInnerGenericClassHiding`2<T, TV, T>. The section also states that there is no "name inheritance" but "position inheritance" .
Investigating this code on a binary level I noticed that the GenericParam (0x2a) metadata table has 3 entries for InnerGenericClassHiding´2 (as expected) however
II.22.20 p.229
states the following:According to this, if I'm not mistaken, my class should not be legals as we have a duplicate for
Owner
andName
. I confirmed this is a real duplicates with Mono.Cecil, ILSpy, and System.Reflection.Metadata.I hope somebody can illuminate me on the matter
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions