Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of unmanaged type parameter constraint #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant