提交 872316fb 编写于 作者: H Heejae Chang

2 tweaks on OOP.

1. write logs as warning rather than error when connection is closed (basically operation cancelled)

2. build compilation concurrently for diagnostic analyzers.
上级 2ddb8311
......@@ -54,15 +54,24 @@ public DiagnosticComputer(Project project)
bool logAnalyzerExecutionTime,
CancellationToken cancellationToken)
{
// flag that controls concurrency
var useConcurrent = true;
// get original compilation
var compilation = await _project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
// fork compilation with concurrent build. this is okay since WithAnalyzers will fork compilation
// anyway to attach event queue. this should make compiling compilation concurrent and make things
// faster
compilation = compilation.WithOptions(compilation.Options.WithConcurrentBuild(useConcurrent));
// TODO: can we support analyzerExceptionFilter in remote host?
// right now, host doesn't support watson, we might try to use new NonFatal watson API?
var analyzerOptions = new CompilationWithAnalyzersOptions(
options: new WorkspaceAnalyzerOptions(_project.AnalyzerOptions, _project.Solution.Workspace),
onAnalyzerException: OnAnalyzerException,
analyzerExceptionFilter: null,
concurrentAnalysis: true,
concurrentAnalysis: useConcurrent,
logAnalyzerExecutionTime: logAnalyzerExecutionTime,
reportSuppressedDiagnostics: reportSuppressedDiagnostics);
......
......@@ -105,7 +105,7 @@ protected virtual void Dispose(bool disposing)
protected void LogError(string message)
{
Logger.TraceEvent(TraceEventType.Error, 0, $"{DebugInstanceString} : " + message);
Log(TraceEventType.Error, message);
}
public virtual void Initialize(int sessionId, byte[] solutionChecksum)
......@@ -132,6 +132,11 @@ protected virtual void OnDisconnected(JsonRpcDisconnectedEventArgs e)
// do nothing
}
protected void Log(TraceEventType errorType, string message)
{
Logger.TraceEvent(errorType, 0, $"{DebugInstanceString} : " + message);
}
private void OnRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e)
{
// raise cancellation
......@@ -141,7 +146,10 @@ private void OnRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e)
if (e.Reason != DisconnectedReason.Disposed)
{
LogError($"Client stream disconnected unexpectedly: {e.Exception?.GetType().Name} {e.Exception?.Message}");
// this is common for us since we close connection forcefully when operation
// is cancelled. use Warning level so that by default, it doesn't write out to
// servicehub\log files. one can still make this to write logs by opting in.
Log(TraceEventType.Warning, $"Client stream disconnected unexpectedly: {e.Exception?.GetType().Name} {e.Exception?.Message}");
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册