InterfaceGenerator icon indicating copy to clipboard operation
InterfaceGenerator copied to clipboard

Fix handling of unmanaged type parameter constraint

Open rkonklewski-am2m opened this issue 2 years ago • 0 comments

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.

rkonklewski-am2m avatar Jul 11 '23 10:07 rkonklewski-am2m