提交 faf8e7a5 编写于 作者: V VSadov

Ensure that compiling is finished by the time we get to collect diagnostics.

上级 7e4c666f
......@@ -1733,6 +1733,11 @@ internal override void ReportUnusedImports(SyntaxTree filterTree, DiagnosticBag
}
}
CompleteTrees(filterTree);
}
internal override void CompleteTrees(SyntaxTree filterTree)
{
// By definition, a tree is complete when all of its compiler diagnostics have been reported.
// Since unused imports are the last thing we compute and report, a tree is complete when
// the unused imports have been reported.
......
......@@ -7729,12 +7729,13 @@ public void NoWarnAndWarnAsError_InfoDiagnostic()
return output;
}
[WorkItem(11368, "https://github.com/dotnet/roslyn/issues/11368")]
[WorkItem(899050, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/899050")]
[WorkItem(981677, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/981677")]
[WorkItem(998069, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/998069")]
[WorkItem(998724, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/998724")]
[WorkItem(1021115, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1021115")]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/11368")]
[Fact]
public void NoWarnAndWarnAsError_WarningDiagnostic()
{
// This assembly has a WarningDiagnosticAnalyzer type which should produce custom warning
......
......@@ -501,12 +501,15 @@ private int RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, Cancellat
win32ResourceStreamOpt,
diagnosticBag,
cancellationToken);
}
if (success)
{
compilation.ReportUnusedImports(null, diagnosticBag, cancellationToken);
}
// only report unused usings if we have success.
if (success)
{
compilation.ReportUnusedImports(null, diagnosticBag, cancellationToken);
}
compilation.CompleteTrees(null);
}
}
......
......@@ -1480,11 +1480,25 @@ internal bool IsRealSigned
DiagnosticBag diagnostics,
CancellationToken cancellationToken);
/// <summary>
/// Reports all unused imports/usings so far (and thus it must be called as a last step of Emit)
/// </summary>
internal abstract void ReportUnusedImports(
SyntaxTree filterTree,
DiagnosticBag diagnostics,
CancellationToken cancellationToken);
/// <summary>
/// Signals the event queue, if any, that we are done compiling.
/// There should not be more compiling actions after this step.
/// NOTE: once we signal about completion to analyzers they will cancel and thus in some cases we
/// may be effectively cutting off some diagnostics.
/// It is not clear if behavior is desirable.
/// See: https://github.com/dotnet/roslyn/issues/11470
/// </summary>
/// <param name="filterTree">What tree to complete. null means complete all trees. </param>
internal abstract void CompleteTrees(SyntaxTree filterTree);
internal bool Compile(
CommonPEModuleBuilder moduleBuilder,
bool emittingPdb,
......@@ -1695,7 +1709,7 @@ internal void EnsureAnonymousTypeTemplates(CancellationToken cancellationToken)
{
ReportUnusedImports(null, diagnostics, cancellationToken);
}
}
}
}
finally
{
......
......@@ -1610,6 +1610,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If
End If
CompleteTrees(filterTree)
End Sub
Friend Overrides Sub CompleteTrees(filterTree As SyntaxTree)
' By definition, a tree Is complete when all of its compiler diagnostics have been reported.
' Since unused imports are the last thing we compute And report, a tree Is complete when
' the unused imports have been reported.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册