-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Inline Hints: More logic around handling named arguments #60184
base: main
Are you sure you want to change the base?
Conversation
foreach (var argument in argumentList.Arguments) | ||
{ | ||
if (argument.NameColon != null) | ||
continue; | ||
|
||
var parameter = argument.DetermineParameter(semanticModel, cancellationToken: cancellationToken); | ||
|
||
if (parametersOfNamedArguments.Contains(parameter)) |
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.
Aren't we already skipping here because of line 80?
if (argument.NameColon != null)
continue;
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.
In which DetermineParameter maps the argument "true" to the parameter "d". So GetParametersOfNamedArguments goes through and gets the parameters in those mappings and makes sure to skip them. The argument.NameColon is necessary for the named argument "d:" since we still want to skip it.
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.
ahhhh.... I get it now. Thanks for the explanation
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'm confused by this fix so maybe I'm missing something. It looks like all the work you do in GetParametersOfNamedArguments
is duplicate continue logic in the for. What is causing this to be different?
Previously, if there was a named argument that wasn't at the exact location as the parameter, then it was still being shown. This is to combat that case. |
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.
Why not update DetermineParameter
to not return a symbol if there is an overload resolution error?
More specifically, remove this if
entirely:
Lines 53 to 56 in 8192820
if (symbol == null && symbolInfo.CandidateSymbols.Length == 1) | |
{ | |
symbol = symbolInfo.CandidateSymbols[0]; | |
} |
I remember adding that bit of code back when I first implemented this feature, it had something to do with an overload case. I need to see if it can just be removed. Edit:
Should still show a hint for the argument in testMethod and it doesn't if we don't try to use the candidate symbol. |
@akhera99 Does disabling inline parameter hints completely when there are more arguments than the parameter count make sense? I don't think we can give any good result for this case. |
Yeah, I have no qualms with that, though I think that is orthogonal to this issue about named arguments. |
@akhera99 The issue with named arguments seems to be reproducible only when the given arguments are greater than the number of parameters. If this assumption is correct, then the suggestion will result in a less complex fix. An alternative is to somehow tweak It returns the symbol for parameter |
Fixes: #59317