提交 fec71675 编写于 作者: C CyrusNajmabadi

Don't offer to inline _ as that could become a discard.

上级 94d816b5
......@@ -1610,5 +1610,25 @@ void Foo()
}
}", ignoreTrivia: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
public async Task TestMissingOnUnderscore()
{
await TestMissingInRegularAndScriptAsync(
@"
using System;
class C
{
void M()
{
[|int|] _;
if (N(out _)
{
Console.WriteLine(_);
}
}
}");
}
}
}
\ No newline at end of file
......@@ -113,6 +113,13 @@ private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context, INamedTypeSymb
var identifierName = (IdentifierNameSyntax)argumentExpression;
// Don't offer to inline variables named "_". It can cause is to create a discard symbol
// which would cause a break.
if (identifierName.Identifier.ValueText == "_")
{
return;
}
var containingStatement = argumentExpression.FirstAncestorOrSelf<StatementSyntax>();
if (containingStatement == null)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册