Repository navigation
[release/10.0.4xx] Check each referenced project once in dotnet format - #57019
Merged
jasonmalinowski merged 2 commits intoNov 18, 2026
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the reference-walk performance backport.
No open issues 🎉
What changed in this PR
Backports the dotnet format reference-walk performance fix to release/10.0.4xx, addressing excessive processing time on dense project-reference graphs while preserving the branch’s existing reference-validation behavior.
Changes:
- Replaces recursive traversal with a cached dependency-graph lookup so each reachable project is checked once per validation.
- Adds an xUnit regression test using 40 densely connected projects, verifying the expected diagnostic and no logged warnings.
| File | Description |
|---|---|
test/dotnet-format.UnitTests/Analyzers/AnalyzerRunnerTests.cs |
Adds dense-graph regression coverage for analyzer execution. |
src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs |
Uses transitive dependency enumeration while retaining the mscorlib.dll validation check. |
Review effort: Balanced
This was referenced Nov 10, 2026
JoeRobich
approved these changes
Nov 10, 2026
jasonmalinowski
force-pushed
the
backport-dotnet-format-recursion-fix-to-10.0.4xx
branch
from
November 14, 2026 01:21
361e9f4 to
4f75220
Compare
Member
Author
|
This is blocked on #56869 merging. |
Backport of dotnet#56621 to release/10.0.1xx. Before running analyzers, AnalyzerRunner recursively walks every project reference to confirm the runtime references loaded. Shared dependencies are re-walked on every path that reaches them, so the cost grows exponentially with the depth of the reference graph. Dense graphs (e.g. solutions using DisableTransitiveProjectReferences) make `dotnet format style` and `dotnet format analyzers` take minutes to hours. Replace the recursion with a single pass over the project and its transitive dependencies from the solution's cached ProjectDependencyGraph, so each project is checked exactly once. This is a manual port: this branch keeps its existing synchronous mscorlib.dll check rather than main's compilation-based check, and the tests are translated from MSTest to xUnit. Fixes dotnet#56363
Drop the custom timeout wrapper; the test harness already dumps hung tests, so a regression to the exponential walk trips that instead. Drop the missing-corlib tests: the old recursive walk already reported broken dependencies correctly, so they do not guard the regression this change fixes. With one caller left, inline the graph construction.
jasonmalinowski
force-pushed
the
backport-dotnet-format-recursion-fix-to-10.0.4xx
branch
from
November 18, 2026 18:50
4f75220 to
8ea6ef3
Compare
jasonmalinowski
deleted the
backport-dotnet-format-recursion-fix-to-10.0.4xx
branch
November 18, 2026 22:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #56621 to
release/10.0.4xx. Fixes #56363 for .NET 10.#56621 merged to
mainon 2026-10-28.Description
Before running analyzers,
dotnet format style/dotnet format analyzerschecks that every referenced project loaded by recursively walkingProjectReferences. The walk never remembers which projects it already checked, so a shared dependency is re-walked once per path that reaches it, which is exponential in the depth of the reference graph.This replaces the recursion with a single pass over the project and its transitive dependencies from the solution's cached
ProjectDependencyGraph, so each project is checked once.This is a manual port, not a cherry-pick. On this branch the check is the synchronous
AllReferencedProjectsLoaded(anmscorlib.dllmetadata-reference check) undersrc/BuiltInTools/dotnet-format, rather than the async compilation check onmain. The port keeps this branch's check exactly as is and changes only how the graph is walked. The test is translated from MSTest to xUnit.Customer Impact
On solutions with dense project-reference graphs (for example, ones using
DisableTransitiveProjectReferences),dotnet format style/analyzersruns for minutes to hours. #56363 reports 11.5 minutes on a 30-project repro and 14+ hours on a 380-project solution. Teams that usedotnet format --verify-no-changesas a CI gate can't run it. The only workarounds are formatting project by project or skipping the analyzer passes.Regression?
No. The unmemoized walk is long-standing; it is also present in .NET 8 (
dotnet/format).Risk
Low. The change is limited to the pre-analysis reference check. The set of projects checked is the same (the project plus its transitive project references), and so is the per-project check. Any dependency that fails the check still skips the project with the existing "required references did not load" warning.
Testing
New
AnalyzerRunnerTests: a dense 40-project graph (each project references every earlier one) completes in seconds; without the fix it effectively never finishes and the test harness's hang detection trips.