提交 ca3ecfd4 编写于 作者: A Allison Chou

Cleanup

上级 92ccf533
......@@ -1150,6 +1150,23 @@ void M(C test)
await VerifyBuilderAsync(markup);
}
[WorkItem(42368, "https://github.com/dotnet/roslyn/issues/42368")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestInPropertyPattern()
{
var markup = @"
class C
{
int P { get; }
void M(C test)
{
if (test is { P: int o$$ })
}
}";
await VerifyBuilderAsync(markup);
}
[WorkItem(42368, "https://github.com/dotnet/roslyn/issues/42368")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestInAndPattern()
......
......@@ -211,23 +211,25 @@ private bool IsPotentialPatternVariableDeclaration(SyntaxToken token)
return false;
}
// Statements containing 'not' cannot be valid variable declarations, e.g. 'e is not int $$' and 'e is not (1 and int $$)'
if (patternSyntax.GetAncestorsOrThis(a => a is UnaryPatternSyntax unaryPatternSyntax &&
unaryPatternSyntax.PatternOperator.IsKind(SyntaxKind.NotKeyword)).Any())
var possibleInvalidVariable = patternSyntax.Parent;
while (possibleInvalidVariable is BinaryPatternSyntax ||
possibleInvalidVariable is UnaryPatternSyntax ||
possibleInvalidVariable is ParenthesizedPatternSyntax ||
possibleInvalidVariable is ParenthesizedExpressionSyntax)
{
return false;
}
// Patterns containing 'or' cannot contain valid variable declarations, e.g. 'e is 1 or int $$'
if (possibleInvalidVariable is BinaryPatternSyntax binaryPatternSyntax && binaryPatternSyntax.IsKind(SyntaxKind.OrPattern))
{
return false;
}
// Patterns containing 'or' cannot contain valid variable declarations, e.g. 'e is 1 or int $$'
var possibleBinaryPattern = patternSyntax.Parent;
while (possibleBinaryPattern is BinaryPatternSyntax binaryPatternSyntax)
{
if (binaryPatternSyntax.PatternOperator.IsKind(SyntaxKind.OrKeyword))
// Patterns containing 'not' cannot be valid variable declarations, e.g. 'e is not int $$' and 'e is not (1 and int $$)'
if (possibleInvalidVariable is UnaryPatternSyntax unaryPatternSyntax && unaryPatternSyntax.IsKind(SyntaxKind.NotPattern))
{
return false;
}
possibleBinaryPattern = binaryPatternSyntax.Parent;
possibleInvalidVariable = possibleInvalidVariable.Parent;
}
// e is int o$$
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册