When a method had the 'unmanaged' constraint specified, then the interface generator would output both 'struct' and 'unmanaged' constraints. However, the C# specification explicitly forbids to combine these constraints.
The problem is that when the HasUnmanagedTypeConstraint property of ITypeParameterSymbol is true, then HasValueTypeConstraint is also true. To fix the issue the class / struct / unmanaged / notnull constraints need to be treated as mutually exclusive, and unmanaged needs to be checked before struct.
When a method had the 'unmanaged' constraint specified, then the interface generator would output both 'struct' and 'unmanaged' constraints. However, the C# specification explicitly forbids to combine these constraints.
The problem is that when the
HasUnmanagedTypeConstraint
property ofITypeParameterSymbol
is true, thenHasValueTypeConstraint
is also true. To fix the issue theclass
/struct
/unmanaged
/notnull
constraints need to be treated as mutually exclusive, andunmanaged
needs to be checked beforestruct
.