-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support unbound generic types in 'nameof' operator. #75368
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass (iteration 17)
Visit(node.ElementType); | ||
} | ||
|
||
public override void VisitPointerType(PointerTypeSyntax node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. @333fred do function pointers need special handling here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: i've added some typeof and nameof tests taht exercise func-ptrs. The results seem expected to me. But i wouldn't mind SMEs here validating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've played with the change a bit and looked through the logic, and I can't see a scenario where it should matter; since we use DefaultVisit
for the function pointer, no nested generic types will be marked as allowed. And for any containers, it seems that the following should always hold:
- The container is a generic type, and we won't parse that as an unbound generic type if there are any arguments (ie,
IsUnboundGenericName
won't be true for something likeDictionary<,delegate*<List<>>
) - The container is an array or nullable type, and that's always marked as seen constructed.
- The container is a tuple type, and that's never visited by this visitor, so nothing underneath is allowed to be open.
I think that covers all the possibilities, so I don't expect there to be any issues. However, @CyrusNajmabadi, please add a test with 3 generics used like this:
C<, delegate*<int>, List<>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@333fred tests added. test results seemed sensible to me, so i'm moving forward with submitting this. tnx.
Seems like it would be nice there as well. If someone wants to champion that, i'd support it. |
If you are not planning to adjust VB, please open an issue to follow up and CC @KathleenDollard on it. |
Opened #75975 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 49)
@CyrusNajmabadi Please squash commits while merging. |
Championed proposal: dotnet/csharplang#8480