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

TypeSymbol of unbound generic does not return any member or type information #66512

Open
dotlogix opened this issue Jan 21, 2023 · 1 comment

Comments

@dotlogix
Copy link

Version Used:
.NET SDK (reflecting any global.json):
Version: 6.0.400
Commit: 7771abd614

Steps to Reproduce:

  1. Create a source generator
  2. Create an attribute accepting an open generic type
  3. Retrieve the provided open generic type parameter from the semantic model
  4. Try to obtain type information about the types members, interfaces or base types

Expected Behavior:
The type symbol should return the methods using the type parameters instead of specific types, just like in normal C# where we can have generic method definitions.

Actual Behavior:
The GetMembers() method does not return anything, same for interfaces and base types which makes this symbol kind of useless.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 21, 2023
@dotlogix
Copy link
Author

dotlogix commented Jan 22, 2023

After a long while of debugging and trying to udnerstand how this works I found out, that the OriginalDefinition of a TypeSymbol marked as IsUnboundGenericType HAS all of the members, the documentation of the IsUnboundGenericType property however only tells you this:
"An unbound generic type yields null for its BaseType and an empty result for its Interfaces."

It should be "...empty results for interfaces and members" and provide you with a hint to OriginalDefinition where you can actually get all of the correct type information.
Not sure though why bound generic types can show you the members but unbound can not. Also if there is a difference, why do bound generic types not substitute the generic type parameters for the provided ones.
I would prefer a consistent behavior for unbound generic types instead of this inconvenience :)

@jcouv jcouv added the Question label Jan 27, 2023
@jcouv jcouv added this to the Backlog milestone Aug 18, 2023
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants