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

Unexpected result when checking if generic type implements its generic type definition #25

Open
LaXiS96 opened this issue May 2, 2023 · 1 comment

Comments

@LaXiS96
Copy link

LaXiS96 commented May 2, 2023

Hello,
please have a look at this fiddle: https://dotnetfiddle.net/NlY70e

Dictionary<string, object?> is the concrete type.
IDictionary<string, object?> is the closed generic type.
IDictionary<,> is the open generic type (generic type definition).

Checking if the concrete type implements either the closed or open generic types returns True as expected.
But checking if the closed generic type implements its open generic type returns False, which is not correct in my opinion. I would have expected it to return True since the closed generic type is essentially an "implementation" of its generic type definition.

Can anyone comment on this?
Thanks

@LaXiS96
Copy link
Author

LaXiS96 commented May 2, 2023

Updated fiddle with workaround: https://dotnetfiddle.net/NED18q

I am using IsConstructedGenericType and GetGenericTypeDefinition() to check the open generic type, while also keeping Implements() for all other cases.

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

No branches or pull requests

1 participant