未验证 提交 b0f4d110 编写于 作者: M Manish Vasani 提交者: GitHub

Merge pull request #32876 from alrz/fix-assert

Fix assertion in UsePatternMatching analyzer
......@@ -99,6 +99,39 @@ void M()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTypeCheck)]
public async Task TestInSwitchSection()
{
await TestInRegularAndScriptAsync(
@"class C
{
void M()
{
switch (o)
{
default:
[|var|] x = o as string;
if (x != null)
{
}
}
}
}",
@"class C
{
void M()
{
switch (o)
{
default:
if (o is string x)
{
}
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTypeCheck)]
public async Task TestMissingOnNonDeclaration()
{
......
......@@ -34,7 +34,7 @@ internal partial class CSharpAsAndNullCheckDiagnosticAnalyzer
Debug.Assert(comparison != null);
Debug.Assert(operand != null);
Debug.Assert(localStatement.IsKind(SyntaxKind.LocalDeclarationStatement));
Debug.Assert(enclosingBlock.IsKind(SyntaxKind.Block));
Debug.Assert(enclosingBlock.IsKind(SyntaxKind.Block, SyntaxKind.SwitchSection));
_semanticModel = semanticModel;
_comparison = comparison;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册