Skip to content

Fix check for a project being properly loaded#54983

Merged
jasonmalinowski merged 2 commits into
dotnet:mainfrom
jasonmalinowski:correct-project-loaded-check
Jul 8, 2026
Merged

Fix check for a project being properly loaded#54983
jasonmalinowski merged 2 commits into
dotnet:mainfrom
jasonmalinowski:correct-project-loaded-check

Conversation

@jasonmalinowski

Copy link
Copy Markdown
Member

We were explicitly looking for an mscorlib.dll as being in the list of references, but that won't work for Corlib itself since it has no references. Just replace the check that to do analysis, we have to have a System.Object somewhere.

Fixes #53595

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates dotnet-format’s analyzer runner to better detect when a project is “properly loaded” for analysis, specifically fixing scenarios like building/analyzing System.Private.CoreLib where mscorlib.dll is not a reliable sentinel.

Changes:

  • Replace the mscorlib.dll metadata-reference heuristic with a compilation-based check that System.Object is available.
  • Make referenced-project loading verification async and recursive across ProjectReferences.
  • Add System.Diagnostics for a debug-only assertion (but see review comment about release behavior).
Show a summary per file
File Description
src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs Switches the “references loaded” detection from mscorlib.dll to System.Object availability and recurses across referenced projects before running analyzers.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 4

Comment thread src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs Outdated
Comment thread src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs
Comment thread src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs
Comment thread src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs Outdated
Comment thread src/Dotnet.Format/dotnet-format/Analyzers/AnalyzerRunner.cs Outdated

@mwiemer-microsoft mwiemer-microsoft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At least typo fixes, maybe the AI-suggested changes as well

We were explicitly looking for an mscorlib.dll as being in the list of
references, but that won't work for Corlib itself since it has no
references. Just replace the check that to do analysis, we have to have
a System.Object somewhere.

Fixes dotnet#53595
This isn't needed since it's just a console app.
@jasonmalinowski jasonmalinowski merged commit b09358c into dotnet:main Jul 8, 2026
25 checks passed
@jasonmalinowski jasonmalinowski deleted the correct-project-loaded-check branch July 8, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dotnet format doesn’t work on runtime corelib

4 participants