Skip to content

Conversation

rkonklewski-am2m
Copy link

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 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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant