Skip to content

Only cache diagnostics for legacy projects#82643

Open
JoeRobich wants to merge 2 commits intomainfrom
dev/jorobich/cache-legacy-projects
Open

Only cache diagnostics for legacy projects#82643
JoeRobich wants to merge 2 commits intomainfrom
dev/jorobich/cache-legacy-projects

Conversation

@JoeRobich
Copy link
Member

We added a diagnostic id cache to answer whether a build error was supported by a particular project. This cache stored diagnostic ids for all projects in the solution. However it was only being used for legacy projects. This means we were doing too much work.

This PR changes the cache to only store diagnostic ids for registered projects and updates the AbstractLegacyProject to register new projects with the cache when they are created.

@JoeRobich JoeRobich requested a review from a team as a code owner March 6, 2026 05:25
@JoeRobich
Copy link
Member Author

/pr-val

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

View PR Validation Run triggered by @JoeRobich

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82643
  • Commit SHA: e73aaba70ac33ec90201e72dfffd4e50e0c620b4
  • Source Branch: dev/jorobich/cache-legacy-projects
  • Target Branch: main
  • Build ID: 13479013

@JoeRobich
Copy link
Member Author

/pr-val

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

View PR Validation Run triggered by @JoeRobich

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82643
  • Commit SHA: 079d378f7149c665b7cf6632caf9111e404fc172
  • Source Branch: dev/jorobich/cache-legacy-projects
  • Target Branch: main
  • Build ID: 13482118

/// <summary>
/// Returns all the DiagnosticIds producible by the referenced DiagnosticAnalyzers.
/// </summary>
public ImmutableHashSet<string> GetAllDiagnosticIds(
Copy link
Contributor

Choose a reason for hiding this comment

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

ImmutableHashSet

Have you considered using an IReadOnlySet instead of ImmutableHashSet? It doesn't look like the caller needs the ability to update this set, and ImmutableHashSet is more expensive to create and query than a HashSet exposed as an IReadOnlySet

Copy link
Contributor

Choose a reason for hiding this comment

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

To be fair, this is no worse than the code directly below it creating ImmutableDictionary objects when it seems like it could be using ReadOnlyDictionary objects.

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.

2 participants