Skip to content
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

Make more APIs project-based in diag service. #77122

Merged
merged 13 commits into from
Feb 10, 2025

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Feb 8, 2025

Followup to #77121

Also address feedback from #77121

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 8, 2025
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review February 10, 2025 20:13
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 10, 2025 20:13
@@ -1075,7 +1075,7 @@ await VerifyCachedDiagnosticsAsync(
: root.DescendantNodes().OfType<CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax>().First().Span;

await analyzerService.GetDiagnosticsForIdsAsync(
sourceDocument.Project.Solution, sourceDocument.Project.Id, sourceDocument.Id, diagnosticIds: null, shouldIncludeAnalyzer: null,
sourceDocument.Project, sourceDocument.Id, diagnosticIds: null, shouldIncludeAnalyzer: null,
Copy link
Member Author

Choose a reason for hiding this comment

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

most callers had a project, but would then use it to pass a Solution+ProjectId. Simpler to just pass Project

@@ -43,6 +43,31 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
return list.ToImmutableAndClear();
}

private static async Task<ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<DiagnosticData>>> ComputeDocumentDiagnosticsCoreAsync(
Copy link
Member Author

Choose a reason for hiding this comment

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

these are moves of a couple of static methods to an outer scope so they can be seen by a few nested types.

@CyrusNajmabadi
Copy link
Member Author

@ToddGrun @dibarbet this is ready for review.

{
return ex =>
if (ex is not OperationCanceledException && crashOnAnalyzerException)
Copy link
Contributor

Choose a reason for hiding this comment

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

crashOnAnalyzerException

this is the bit that's preventing this from being a static local function?

Copy link
Member Author

Choose a reason for hiding this comment

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

will check.

@@ -94,18 +92,17 @@ public async Task<ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnos
}
else
{
var analyzerWithStateAndEmptyData = analyzer;
if (!compilerAnalyzerData.HasValue && analyzer.IsCompilerAnalyzer())
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!compilerAnalyzerData.HasValue && analyzer.IsCompilerAnalyzer())

Could the loop contents just be:

var spanBased = (oldDocumentVersion == VersionStamp.Default);
if (!compilerAnalyzerData.HasValue && analyzer.IsCompilerAnalyzer())
  compilerAnalyzerData = (analyzer, spanBased);
else if (spanBased)
  spanBasedAnalyzers.Add(analyzer);
else
  documentBasedAnalyzers.Add(analyzer);

Copy link
Member Author

Choose a reason for hiding this comment

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

will check.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit d397200 into dotnet:main Feb 10, 2025
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 10, 2025
@CyrusNajmabadi CyrusNajmabadi deleted the projectDiagBased branch February 10, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants