- [Signatures](#signatures)
- [Heap sizes](#heap-sizes)
- [Metadata merging](#metadata-merging)
+- [Metadata logical format](#metadata-logical-format)
- [Module Initializer](#module-initializer)
- [Default Interface Methods](#default-interface-methods)
- [Static Interface Methods](#static-interface-methods)
> * ~~If there are duplicates and two or more have an accessibility other than
> **compilercontrolled**, an error has occurred.~~
+## Metadata logical format
+
+The requirement to sort InterfaceImpl table using the Interface column as a secondary key in § II.22 _Metadata logical format: tables_ is a spec bug. The interface declaration order affects resolution and a requirement to sort it would make it impossible to emit certain sequences of interfaces (e.g. not possible to have an interface list I1, I2, while also having interface list I2, I1 elsewhere in the module).
+
+The text should be deleted:
+
+> Furthermore, ~~the InterfaceImpl table is sorted using the Interface column as a secondary key, and~~ the GenericParam table is sorted using the Number column as a secondary key.
+
## Module Initializer
All modules may have a module initializer. A module initializer is defined as the type initializer (§ II.10.5.3) of the `<Module>` type (§ II.10.8).
// GenericParam Owner, Number No**
// GenericParamConstraint Owner No**
// ImplMap MemberForwarded No*
- // InterfaceImpl Class, Interface No**
+ // InterfaceImpl Class No**
// MethodImpl Class No*
// MethodSemantics Association Yes
// NestedClass NestedClass No*
private void ValidateInterfaceImplTable()
{
- if (_interfaceImplTable.Count == 0)
+ for (int i = 1; i < _interfaceImplTable.Count; i++)
{
- return;
- }
-
- InterfaceImplRow current, previous = _interfaceImplTable[0];
- for (int i = 1; i < _interfaceImplTable.Count; i++, previous = current)
- {
- current = _interfaceImplTable[i];
-
- if (current.Class > previous.Class)
+ if (_interfaceImplTable[i - 1].Class > _interfaceImplTable[i].Class)
{
- continue;
+ Throw.InvalidOperation_TableNotSorted(TableIndex.InterfaceImpl);
}
-
- if (previous.Class == current.Class && current.Interface > previous.Interface)
- {
- continue;
- }
-
- Throw.InvalidOperation_TableNotSorted(TableIndex.InterfaceImpl);
}
}
Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
builder = new MetadataBuilder();
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(1));
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
-
- builder = new MetadataBuilder();
builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(2));
builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
-
- builder = new MetadataBuilder();
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeReferenceHandle(2));
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeReferenceHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
-
- builder = new MetadataBuilder();
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeSpecificationHandle(2));
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeSpecificationHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
-
- builder = new MetadataBuilder();
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeReferenceHandle(1));
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
-
- builder = new MetadataBuilder();
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeSpecificationHandle(1));
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeReferenceHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
-
- builder = new MetadataBuilder();
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeSpecificationHandle(1));
- builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(1));
- Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
+ builder.ValidateOrder(); // ok
}
[Fact]