提交 a06b6fd1 编写于 作者: A Andrew Casey

Merge pull request #4267 from amcasey/AnalyzerAssert

Loosen diagnostics assert
......@@ -163,7 +163,9 @@ private async Task<bool> TryGetSyntaxAndSemanticCompilerDiagnostics(StateSet sta
[Conditional("DEBUG")]
private void VerifyDiagnostics(SemanticModel model)
{
Func<Diagnostic, bool> shouldInclude = d => _range.IntersectsWith(d.Location.SourceSpan);
// Exclude unused import diagnostics since they are never reported when a span is passed.
// (See CSharp/VisualBasicCompilation.GetDiagnosticsForMethodBodiesInTree.)
Func<Diagnostic, bool> shouldInclude = d => _range.IntersectsWith(d.Location.SourceSpan) && !IsUnusedImportDiagnostic(d);
// make sure what we got from range is same as what we got from whole diagnostics
var rangeDeclaractionDiagnostics = model.GetDeclarationDiagnostics(_range).ToArray();
......@@ -192,6 +194,19 @@ private void VerifyDiagnostics(SemanticModel model)
}
}
private static bool IsUnusedImportDiagnostic(Diagnostic d)
{
switch (d.Id)
{
case "CS8019":
case "BC50000":
case "BC50001":
return true;
default:
return false;
}
}
private static TextSpan AdjustSpan(Document document, SyntaxNode root, TextSpan span)
{
// this is to workaround a bug (https://github.com/dotnet/roslyn/issues/1557)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册