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 parameters not showing up in 'nameof' on a method #76017

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #60812

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 22, 2024 01:04
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 22, 2024
@CyrusNajmabadi
Copy link
Member Author

@genlu ptal

? null
: semanticModel.GetSymbolInfo(enclosingMethodOrLambdaNode).GetAnySymbol() ?? semanticModel.GetDeclaredSymbol(enclosingMethodOrLambdaNode);
if (enclosingMethodOrLambda is IMethodSymbol method)
symbols = [.. symbols.Concat(method.Parameters)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[..

is this the same as

symbols = symbols.Concat(method.Parameters);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely yes. will fixup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. .Concat returns an IEnumerqable here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's confusing. symbols is an IA, method.Parameters is an IA, isn't this invoking the IA overload for Concat?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's not. i get an error when i try :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see. One is IA, the other is IA. It needs to be:

symbols.Concat(method.Parameters.Cast());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, just a sec, I thought that cast call just cast the array, not enumerate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh, it's CastArray, not Cast

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit 2a1029c into dotnet:main Nov 25, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the nameofParameter branch November 25, 2024 21:47
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symbol completion doesn't work on empty nameof in certain attributes
2 participants