Skip to content

Commit cace554

Browse files
Refactor to use conditional expression and GenerateUniqueLocalName
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
1 parent ae24b17 commit cace554

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/Features/Core/Portable/IntroduceParameter/IntroduceParameterDocumentRewriter.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,16 @@ private async Task<string> GetNewParameterNameAsync(CancellationToken cancellati
8686
{
8787
var semanticModel = await _originalDocument.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
8888

89-
string baseName;
90-
if (ShouldRemoveVariableDeclaratorContainingExpression(out var varDeclName, out _))
91-
{
92-
baseName = varDeclName;
93-
}
94-
else
95-
{
96-
baseName = _semanticFacts.GenerateNameForExpression(semanticModel, _expression, capitalize: false, cancellationToken);
97-
}
89+
var baseName = ShouldRemoveVariableDeclaratorContainingExpression(out var varDeclName, out _)
90+
? varDeclName
91+
: _semanticFacts.GenerateNameForExpression(semanticModel, _expression, capitalize: false, cancellationToken);
9892

9993
// Ensure the parameter name doesn't conflict with existing parameters
100-
var existingParameterNames = _methodSymbol.Parameters.Select(p => p.Name);
101-
var uniqueName = _semanticFacts.GenerateUniqueName(
94+
var uniqueName = _semanticFacts.GenerateUniqueLocalName(
10295
semanticModel,
103-
_containerMethod,
104-
_containerMethod,
96+
_expression,
97+
container: null,
10598
baseName,
106-
existingParameterNames,
10799
cancellationToken);
108100

109101
return uniqueName.ValueText;

0 commit comments

Comments
 (0)