提交 d8d9bf75 编写于 作者: D David Poeschl 提交者: GitHub

Merge pull request #16589 from dpoeschl/NoExceptionOnNamingStylesFixFailureToFindSymbol

Do not fail in the NamingStyleCodeFix when we cannot find the symbol (causes the failure InfoBar to be shown)
......@@ -36,6 +36,16 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
var model = await document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false);
var symbol = model.GetDeclaredSymbol(node, context.CancellationToken);
// TODO: We should always be able to find the symbol that generated this diagnostic,
// but this cannot always be done by simply asking for the declared symbol on the node
// from the symbol's declaration location.
// See https://github.com/dotnet/roslyn/issues/16588
if (symbol == null)
{
return;
}
var fixedNames = style.MakeCompliant(symbol.Name);
foreach (var fixedName in fixedNames)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册