-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Milestone
Description
Description
System.Reflection.Metadata metadata writer enforces weird rules around metadata validity for the InterfaceImpl table.
Reproduction Steps
It's not possible to generate a module with the metadata that corresponds to the following C# program:
interface I1
{
void Method();
}
interface I2
{
void Method();
}
class C1 : I1, I2
{
public void Method() { }
}
class C2 : I2, I1
{
public void Method() { }
}Expected behavior
It's possible to generate interface list for I1, I2 and I2, I1.
Actual behavior
InvalidOperationException is thrown out of this code because it's impossible to have the interface list sorted both ways:
Lines 1552 to 1576 in 57bfe47
| private void ValidateInterfaceImplTable() | |
| { | |
| if (_interfaceImplTable.Count == 0) | |
| { | |
| return; | |
| } | |
| InterfaceImplRow current, previous = _interfaceImplTable[0]; | |
| for (int i = 1; i < _interfaceImplTable.Count; i++, previous = current) | |
| { | |
| current = _interfaceImplTable[i]; | |
| if (current.Class > previous.Class) | |
| { | |
| continue; | |
| } | |
| if (previous.Class == current.Class && current.Interface > previous.Interface) | |
| { | |
| continue; | |
| } | |
| Throw.InvalidOperation_TableNotSorted(TableIndex.InterfaceImpl); | |
| } | |
| } |
Interface index should not be looked at by this code.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response