未验证 提交 7a333f52 编写于 作者: A Andrew Hall 提交者: GitHub

Merge pull request #32880 from ryzngard/issue/32510_generatedeconstructprovider_nullref

Bail on null type information in GenerateDeconstructMethodCodeFixProvider
......@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateDeconstructMethod;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.GenerateDeconstructMethod
......@@ -294,6 +295,26 @@ internal void Deconstruct(out int x, out int y)
{
throw new NotImplementedException();
}
}");
}
[WorkItem(32510, "https://github.com/dotnet/roslyn/issues/32510")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task TestDeconstructionAssignment_InvalidDeclaration()
{
await TestMissingInRegularAndScriptAsync(
@"
using System.Collections.Generic;
class C
{
void Method()
{
var stuff = new Dictionary<string, string>();
foreach ((key, value) in [|stuff|]) // Invalid variable declarator syntax
{
}
}
}");
}
}
......
......@@ -68,7 +68,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
throw ExceptionUtilities.Unreachable;
}
if (type.Kind != SymbolKind.NamedType)
if (type?.Kind != SymbolKind.NamedType)
{
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册