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 ArgumentException caused by Enum constraint on method out parameter #658

Merged
merged 4 commits into from
Aug 28, 2023

Conversation

stakx
Copy link
Member

@stakx stakx commented Aug 23, 2023

Fixes #656.

@stakx stakx added this to the vNext milestone Aug 23, 2023
@stakx stakx force-pushed the bug/generic-enum-constraint branch from 37c3a55 to 80fd65d Compare August 23, 2023 09:51
@stakx
Copy link
Member Author

stakx commented Aug 23, 2023

@castleproject/committers, this too should be a fairly straightforward bug fix. Leaving it open for review for a week or two, without feedback I'll go ahead and merge it after that.

This triggers a `ArgumentException`: "Cannot create an instance of
`TEnum` because `Type.ContainsGenericParameters` is true."
 * As the previous commit showed, the `IsGenericParameter` check must
   have priority... probably not just over enums, but over any other
   value types, too.

 * The `IsEnum` check can be put behind `IsValueType` so it does not run
   for non-value types.
@stakx stakx force-pushed the bug/generic-enum-constraint branch from 80fd65d to 1bc7f18 Compare August 28, 2023 10:07
@stakx stakx merged commit 57e666d into castleproject:master Aug 28, 2023
3 checks passed
@stakx stakx deleted the bug/generic-enum-constraint branch August 28, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants