[dotnet] [build] Format solution instead of projects#17457
[dotnet] [build] Format solution instead of projects#17457nvborisenko wants to merge 13 commits into
Conversation
Review Summary by QodoFormat solution file instead of individual projects for faster builds
WalkthroughsDescription• Format entire solution file instead of individual projects • Significantly improves build performance by 2x • Simplifies formatting logic in both Unix and Windows scripts • Eliminates per-project iteration overhead Diagramflowchart LR
A["Per-project formatting<br/>Unix + Windows loops"] -- "Refactor to" --> B["Solution-level formatting<br/>Selenium.slnx"]
B -- "Result" --> C["2x faster build<br/>Simplified scripts"]
File Changes1. dotnet/private/dotnet_format.bzl
|
Code Review by Qodo
1. Windows %* passed unsafely
|
|
Persistent review updated to latest commit 62eaf58 |
| "%DOTNET%" format %* "%%p" || exit /b 1 | ||
| ) | ||
| echo Running dotnet format %* on Selenium.slnx... | ||
| "%DOTNET%" format %* Selenium.slnx || exit /b 1 |
There was a problem hiding this comment.
1. Windows %* passed unsafely 📘 Rule violation ⛨ Security
The Windows script forwards %* directly into the dotnet format command, which can be interpreted by cmd.exe if arguments contain metacharacters like & or |. This violates the safe argument handling requirement for build/CI scripts.
Agent Prompt
## Issue description
The Windows wrapper uses `%*` directly in a command invocation, which is unsafe in `cmd.exe` because metacharacters in forwarded arguments can alter command parsing.
## Issue Context
This script is an executable entrypoint; forwarded args should be either disallowed, strictly validated/whitelisted, or passed via a safer mechanism (e.g., only known flags, response file, or controlled argument construction).
## Fix Focus Areas
- dotnet/private/dotnet_format.bzl[91-91]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "$DOTNET" format "$@" "$proj" || exit 1 | ||
| done || exit 1 | ||
| echo "Running dotnet format $@ on Selenium.slnx..." | ||
| "$DOTNET" format "$@" Selenium.slnx || exit 1 |
There was a problem hiding this comment.
2. Workspace arg after options 🐞 Bug ≡ Correctness
dotnet_format appends Selenium.slnx after all forwarded args ($@ / %*), so the solution path can be consumed as the value for an option that expects a parameter (e.g., --diagnostics) instead of being treated as the workspace. This can make dotnet format run against an unintended workspace or fail due to mis-parsed arguments.
Agent Prompt
## Issue description
The wrapper currently runs `dotnet format` with forwarded args first and the workspace (`Selenium.slnx`) last. If the last forwarded argument is an option that requires a value, `Selenium.slnx` can be treated as that value instead of the workspace.
## Issue Context
This target is invoked by other tooling (e.g., rake tasks / format scripts) and forwards arbitrary args to `dotnet format`.
## Fix Focus Areas
- dotnet/private/dotnet_format.bzl[55-56]
- dotnet/private/dotnet_format.bzl[90-91]
## Suggested change
Update both scripts to place the workspace immediately after `format`:
- Unix: `"$DOTNET" format Selenium.slnx "$@" || exit 1`
- Windows: `"%DOTNET%" format Selenium.slnx %* || exit /b 1`
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
I love bazel. |
2x faster
💥 What does this PR do?
Use SDK with setting up workspace once, instead calling it one by one per project.
🤖 AI assistance
🔄 Types of changes