Skip to content

Conversation

@mavasani
Copy link
Contributor

Implements the design in #18818 for analyzers. De-duping for code actions will be implemented in a follow-up PR.

  1. We now execute only those VSIX analyzers which report at least one unique diagnostic ID that is not reported by any NuGet based project analyzers.
  2. Additionally, we filter out the diagnostics of IDs reported by VSIX analyzers, which also have a corresponding NuGet analyzer reporting the same diagnostic ID.

First commit implements the unit tests as per the design mentioned in #18818 - all the added unit tests failed after this commit
Second commit implements the above logic in the IDE diagnostic analyzer engine.

…uGet and VSIX analyzers reporting same/overlapping diagnostic IDs - dotnet#18818

Verified all the added unit tests fail currently as both NuGet and VSIX analyzers always execute and no diagnostic filtering is done.
@mavasani mavasani added this to the 16.6.P1 milestone Feb 14, 2020
@mavasani mavasani requested a review from sharwell February 14, 2020 02:51
/// <summary>
/// Information about host analyzers that can be skipped for the given project ID.
/// </summary>
private readonly ConditionalWeakTable<ProjectId, ISkippedAnalyzersInfo> _skippedAnalyzersInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Any reason to not use the same IReadOnlyList<AnalyzerReference> key that CodeFixService uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only have the project ID in the project removal callback when we clear this cache entry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it clear itself if we use CWT?

var asyncToken = _asyncOperationListener.BeginAsyncOperation(nameof(AnalyzeInProcAsync));
var _ = FireAndForgetReportAnalyzerPerformanceAsync(project, client, analysisResult, cancellationToken).CompletesAsyncOperation(asyncToken);

// get skipped analyzers info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is redundant

Suggested change
// get skipped analyzers info

/// <summary>
/// Information about host analyzers that can be skipped for the given project analyzers.
/// </summary>
private readonly ConditionalWeakTable<IReadOnlyList<AnalyzerReference>, ISkippedAnalyzersInfo> _skippedAnalyzersInfo;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell CWT feedback addressed.

return _skippedAnalyzersInfo.GetValue(project.AnalyzerReferences, createValueCallback);
}

public ISkippedAnalyzersInfo GetOrCreateSkippedAnalyzersInfo(Project project, IEnumerable<AnalyzerReference> hostAnalyzers)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is used for computing this info in OOP, as we don't have HostDiagnosticAnalyzers available in OOP.

@mavasani mavasani modified the milestones: 16.6.P1, 16.6.P2, 16.6, 16.6.P3 Mar 18, 2020
@mavasani mavasani modified the milestones: 16.6.P3, 16.6.P1 Mar 18, 2020
…e is an existing unit test which caught this issue.
@mavasani
Copy link
Contributor Author

Thank you @sharwell

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approval

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants