-
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
Introduce Parameter Should Not Try to Introduce on a Parameter #58959
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,12 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex | |
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the original fix was corrrect. i don't see why we'd want to special case local functions. note: we should have extra tests here. for example if the user is on a local-func parameter, we shouldn't add that a second time either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO the correct fix is none of the two, but: if (expressionSymbol is IParameterSymbol parameterSymbol && parameterSymbol.ContainingSymbol.Equals(containingSymbol))
{
return;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm ok not adding one parameter to another container. but i don't feel strongly about that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CyrusNajmabadi This scenario is important IMO if I want to move from: public class C
{
public void M(string s)
{
localFunction();
void localFunction()
{
_ = s.ToString();
}
}
} to: public class C
{
public void M(string s)
{
localFunction(s);
localFunction("Another string");
void localFunction(string s)
{
_ = s.ToString();
}
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Youssef1313 I agree, I like that example. |
||
|
||
var expressionSymbol = semanticModel.GetSymbolInfo(expression, cancellationToken).Symbol; | ||
if (expressionSymbol is IParameterSymbol parameterSymbol && parameterSymbol.ContainingSymbol.Equals(containingSymbol)) | ||
{ | ||
return; | ||
} | ||
|
||
// Code actions for trampoline and overloads will not be offered if the method is a constructor. | ||
// Code actions for overloads will not be offered if the method if the method is a local function. | ||
var methodKind = methodSymbol.MethodKind; | ||
|
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.
does this also inhibit things like
args[0]
andargs + "My String"
?