-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include project diagnostic suppressors in host analyzer execution #75684
base: release/dev17.12
Are you sure you want to change the base?
Conversation
telemetry = telemetry.AddRange(hostAnalysisResult.AnalyzerTelemetryInfo); | ||
// Use SetItems instead of AddRange so exceptions will not occur if diagnostic suppressors are | ||
// counted in both project and host analysis results. | ||
telemetry = telemetry.SetItems(hostAnalysisResult.AnalyzerTelemetryInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 This could negatively impact telemetry accuracy by only including timing information for the host execution of suppressors. It's not clear how important it is to merge the data instead of overwrite it.
@@ -146,6 +146,8 @@ static string GetLanguageSpecificId(string? language, string noLanguageId, strin | |||
// Create driver that holds onto compilation and associated analyzers | |||
var filteredProjectAnalyzers = projectAnalyzers.WhereAsArray(static a => !a.IsWorkspaceDiagnosticAnalyzer()); | |||
var filteredHostAnalyzers = hostAnalyzers.WhereAsArray(static a => !a.IsWorkspaceDiagnosticAnalyzer()); | |||
var filteredProjectSuppressors = filteredProjectAnalyzers.WhereAsArray(static a => a is DiagnosticSuppressor); | |||
filteredHostAnalyzers = filteredHostAnalyzers.AddRange(filteredProjectSuppressors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 This path is hit by the test that was failing, and revealed a case of AddRange
causing a problem. It's not clear how well this or other paths are exercised, so I'm certainly concerned with bugs slipping through.
if (hostAnalyzerIds.Any()) | ||
{ | ||
// If any host analyzers are active, make sure to also include any project diagnostic suppressors | ||
hostBuilder.AddRange(projectAnalyzers.WhereAsArray(static a => a is DiagnosticSuppressor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Don't need "WhereAsArray" here, "Where" should do.
src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/DiagnosticComputer.cs
Outdated
Show resolved
Hide resolved
Debug.Assert(diagnostics.Length == CompilationWithAnalyzers.GetEffectiveDiagnostics(diagnostics, compilation).Count()); | ||
|
||
// ⚠️ No obvious way to keep this assertion | ||
//Debug.Assert(diagnostics.Length == CompilationWithAnalyzers.GetEffectiveDiagnostics(diagnostics, compilation).Count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Need to understand how important this assertion is. If it is not important, there are multiple parameters that can be removed to simplify this code.
Fixes #75399