未验证 提交 d148f06f 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #47537 from sharwell/non-null-compilation

Update SyntaxNodeAnalysisContext.Compilation to not return null
......@@ -43,7 +43,6 @@ private void ReportDiagnosticsIfNeeded(NameColonSyntax nameColon, SyntaxNodeAnal
return;
}
RoslynDebug.Assert(context.Compilation is object);
var parseOptions = (CSharpParseOptions)syntaxTree.Options;
var preference = options.GetOption(
CodeStyleOptions2.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken);
......@@ -71,7 +70,6 @@ private void ReportDiagnosticsIfNeeded(NameEqualsSyntax nameEquals, SyntaxNodeAn
return;
}
RoslynDebug.Assert(context.Compilation is object);
var preference = options.GetOption(
CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken);
if (!preference.Value ||
......
......@@ -1397,7 +1397,7 @@ public struct SyntaxNodeAnalysisContext
/// <summary>
/// <see cref="CodeAnalysis.Compilation"/> containing the <see cref="SyntaxNode"/>.
/// </summary>
public Compilation? Compilation => _semanticModel?.Compilation;
public Compilation Compilation => _semanticModel?.Compilation ?? throw new InvalidOperationException();
/// <summary>
/// Options specified for the analysis.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册