-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Don't report assignment to ref extension parameter as unused #81680
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
Conversation
|
@CyrusNajmabadi @dotnet/roslyn-ide for review. Thanks |
| #else | ||
| if (owningSymbol.ContainingSymbol is INamedTypeSymbol { IsExtension: true, ExtensionParameter: { } extensionParameter }) | ||
| { | ||
| return parameters.Insert(0, extensionParameter); |
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.
this is fine with me. but i'm curious why this was placed in position 0. it's not obvious as to why. consider doc'ing.
| var parameters = owningSymbol.GetParameters(); | ||
| #if ROSLYN_4_12_OR_LOWER | ||
| return parameters; | ||
| #else | ||
| if (owningSymbol.ContainingSymbol is INamedTypeSymbol { IsExtension: true, ExtensionParameter: { } extensionParameter }) | ||
| { | ||
| return parameters.Insert(0, extensionParameter); | ||
| } | ||
|
|
||
| return parameters; | ||
| #endif |
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.
| var parameters = owningSymbol.GetParameters(); | |
| #if ROSLYN_4_12_OR_LOWER | |
| return parameters; | |
| #else | |
| if (owningSymbol.ContainingSymbol is INamedTypeSymbol { IsExtension: true, ExtensionParameter: { } extensionParameter }) | |
| { | |
| return parameters.Insert(0, extensionParameter); | |
| } | |
| return parameters; | |
| #endif | |
| var parameters = owningSymbol.GetParameters(); | |
| #if !ROSLYN_4_12_OR_LOWER | |
| if (owningSymbol.ContainingSymbol is INamedTypeSymbol { IsExtension: true, ExtensionParameter: { } extensionParameter }) | |
| { | |
| return parameters.Insert(0, extensionParameter); | |
| } | |
| #else | |
| return parameters; | |
| #endif |
CyrusNajmabadi
left a comment
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.
Signing off as none of the feedback is blocking.
DataFlowAnalyzer.SetAnalysisDataOnMethodExithas logic to recognize assignments toref/outparameters as reachable and used, The fix is to perform the analysis considering the full set of parameters, including the extension parameter.Fixes #81554