提交 75dc71db 编写于 作者: T Tom Meschter

Merge pull request #2895 from tmeschter/FixAnalyzerDependencyChecker

Fix nulls in AnalyzerDependencyChecker.

Currently we use a `Task.FromResult(null)` as a sentinel task before a
real dependency check has been queued up. This works fine until we try
to access the results of this task, and things blow up.

Instead, we should create an AnalyzerDependecyResults.Empty singleton,
and create a task from that.

Also, this change catches all exceptions coming out of
`AnalyzerDependencyChecker`, to avoid bringing down VS.
......@@ -26,7 +26,7 @@ internal sealed class AnalyzerDependencyCheckingService
private readonly BindingRedirectionService _bindingRedirectionService;
private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private Task<AnalyzerDependencyResults> _task = Task.FromResult((AnalyzerDependencyResults)null);
private Task<AnalyzerDependencyResults> _task = Task.FromResult(AnalyzerDependencyResults.Empty);
private ImmutableHashSet<string> _analyzerPaths = ImmutableHashSet.Create<string>(StringComparer.OrdinalIgnoreCase);
[ImportingConstructor]
......@@ -46,7 +46,7 @@ public async void CheckForConflictsAsync()
{
results = await GetConflictsAsync().ConfigureAwait(continueOnCapturedContext: true);
}
catch (OperationCanceledException)
catch
{
return;
}
......
......@@ -7,6 +7,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
internal sealed class AnalyzerDependencyResults
{
public static readonly AnalyzerDependencyResults Empty = new AnalyzerDependencyResults(ImmutableArray<AnalyzerDependencyConflict>.Empty, ImmutableArray<MissingAnalyzerDependency>.Empty);
public AnalyzerDependencyResults(ImmutableArray<AnalyzerDependencyConflict> conflicts, ImmutableArray<MissingAnalyzerDependency> missingDependencies)
{
Debug.Assert(conflicts != default(ImmutableArray<AnalyzerDependencyConflict>));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册