Add support for formatting file-based apps - #55626
Open
jjonescz wants to merge 3 commits into
Open
Conversation
|
Azure Pipelines: 3 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: 3 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.
Pull request overview
This PR updates dotnet format to accept C# file-based programs (e.g., dotnet format app.cs) by treating eligible .cs entrypoint files as valid “workspace” inputs, updating workspace loading behavior to correctly scope formatting, and adding regression tests and localized help text.
Changes:
- Extend workspace discovery/help text to allow project/solution or file-based program inputs.
- Track the loaded ProjectId when opening a single project workspace so referenced projects are excluded reliably.
- Add unit + CLI scenario tests (and test assets) covering formatted/unformatted file-based apps.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/TestAssets/dotnet-format/for_code_formatter/file_based_app/unformatted.cs | New unformatted file-based app input for formatter tests. |
| test/TestAssets/dotnet-format/for_code_formatter/file_based_app/formatted.cs | New formatted baseline for file-based app formatter tests. |
| test/dotnet.Tests/CommandTests/Run/RunFileTests_BuildCommands.cs | Adds CLI-level regression test for dotnet format app.cs. |
| test/dotnet-format.UnitTests/MSBuild/MSBuildWorkspaceLoaderTests.cs | Updates tests for new LoadedWorkspace return type. |
| test/dotnet-format.UnitTests/CodeFormatterTests.cs | Adds file-based app formatting coverage and treats .cs as project workspace in test helper. |
| test/dotnet-format.UnitTests/Analyzers/ThirdPartyAnalyzerFormatterTests.cs | Updates for new LoadedWorkspace API. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.zh-Hant.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.zh-Hans.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.tr.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.ru.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.pt-BR.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.pl.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.ko.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.ja.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.it.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.fr.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.es.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.de.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/xlf/Resources.cs.xlf | Localization updates for new/renamed workspace argument strings. |
| src/Dotnet.Format/dotnet-format/Workspaces/MSBuildWorkspaceLoader.cs | Changes loader to return LoadedWorkspace including ProjectId. |
| src/Dotnet.Format/dotnet-format/Workspaces/MSBuildWorkspaceFinder.cs | Accepts file-based program entrypoints as workspace inputs; updates invalid-workspace error. |
| src/Dotnet.Format/dotnet-format/Resources.resx | Updates help/error strings to include file-based apps. |
| src/Dotnet.Format/dotnet-format/dotnet-format.csproj | Adds project reference needed for file-based program support. |
| src/Dotnet.Format/dotnet-format/Commands/FormatCommandCommon.cs | Updates argument name/description to reflect new accepted inputs. |
| src/Dotnet.Format/dotnet-format/CodeFormatter.cs | Uses ProjectId-based scoping when formatting a single project workspace. |
Member
Author
|
/azp run |
|
Azure Pipelines: 5 pipeline(s) were filtered out due to trigger conditions. |
Base automatically changed from
darc-main-bf2b710a-36ff-4a1a-8971-c2091395012b
to
main
August 6, 2026 14:38
mthalman
force-pushed
the
dev/jjonescz/49285-sprint-format
branch
from
August 6, 2026 14:38
107f5fe to
0576be4
Compare
JoeRobich
approved these changes
Aug 6, 2026
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.
Resolves #49285.
(Note that this is currently stacked on top of #55595 because it needs roslyn version from that flow. The CI failures are also unrelated to this PR as they appear in that parent PR too.)