Repository navigation
Encode recurring review conventions in Copilot instructions and analyzers - #2127
Merged
waldekmastykarz merged 6 commits intoNov 25, 2026
Merged
Conversation
HelpExamples.Add now takes (command, description) pairs and pads them to a shared column, fixing runtime misalignment of the jwt and root examples caused by escaped quotes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add Microsoft.CodeAnalysis.BannedApiAnalyzers so RS0030 flags System.Console in DevProxy.Plugins, DevProxy.Abstractions, DevProxy.Proxy.Kestrel and CLI commands. Existing commands that need raw stdout/stderr are exempted in .editorconfig. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Capture recurring review feedback: logger-based command output, global --output reuse, exit codes, defaults from code, command naming, help examples, schema versioning, lock files and visibility. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The command instructions incorrectly promise raw JSON output instead of the formatter’s result envelope, misleading consumers about the output contract.
1 open issue
What changed in this PR
This PR turns recurring Dev Proxy review feedback into contributor guidance and build-time enforcement, while centralizing CLI help-example alignment.
Changes:
- Adds a scoped
System.Consoleban, preserving existing raw-output exceptions. - Documents shared coding, CLI command, and schema-versioning conventions.
- Converts help examples to command/description pairs and adds alignment tests.
| File | Description |
|---|---|
Directory.Build.props |
Adds the banned-API analyzer to non-test projects. |
DevProxy/packages.lock.json |
Locks the analyzer dependency. |
DevProxy/Commands/StdioCommand.cs |
Converts stdio examples to pairs. |
DevProxy/Commands/OutdatedCommand.cs |
Converts update-check examples to pairs. |
DevProxy/Commands/MsGraphDbCommand.cs |
Converts the database-generation example to a pair. |
DevProxy/Commands/JwtCommand.cs |
Converts JWT examples to pairs. |
DevProxy/Commands/HelpExamples.cs |
Centralizes runtime description alignment. |
DevProxy/Commands/DevProxyCommand.cs |
Converts root-command examples to pairs. |
DevProxy/Commands/ConfigCommand.cs |
Converts configuration examples to pairs. |
DevProxy/Commands/CertCommand.cs |
Converts certificate examples to pairs. |
DevProxy.Tests/HelpExamplesTests.cs |
Tests shared alignment and long-command spacing. |
DevProxy.Proxy.Kestrel/packages.lock.json |
Locks the analyzer dependency. |
DevProxy.Plugins/packages.lock.json |
Locks the analyzer dependency. |
DevProxy.Abstractions/packages.lock.json |
Locks the analyzer dependency. |
BannedSymbols.txt |
Declares the System.Console ban. |
.github/instructions/schemas.instructions.md |
Documents versioned schema-editing rules. |
.github/instructions/commands.instructions.md |
Documents CLI implementation conventions. |
.github/copilot-instructions.md |
Adds repository-wide coding and validation guidance. |
.editorconfig |
Configures analyzer scope and existing command exemptions. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| # CLI command conventions | ||
|
|
||
| - **Output goes through `ILogger`, not `Console`.** Inject `ILogger<TCommand>` and log human-readable text with `LogInformation`/`LogWarning`/`LogError`. For `--output json`, serialize with `ProxyUtils.JsonSerializerOptions` and call `_logger.LogStructuredOutput(json)`; the JSON console formatter wraps it in a JSON Lines envelope `{ "type": "result", "data": <your payload>, "category": …, "timestamp": … }`, so document the payload as `data`, not as top-level output. `System.Console` is banned in this folder by analyzer `RS0030` (see `BannedSymbols.txt`); the few existing files that need raw stdout/stderr (secrets, log streaming, prompts, help rendering) are listed in `.editorconfig`. Don't add files to that list. | ||
| - **Reuse global options and existing helpers.** `--output` is a global option: read it with `parseResult.GetValueOrDefault<OutputFormat?>(DevProxyCommand.OutputOptionName) ?? OutputFormat.Text`; don't add per-command output/format options. Before writing parsing or validation code, search `DevProxyCommand` (e.g. `ValidatePort`), `DevProxy.Abstractions/Utils/ProxyUtils.cs` (URL matching, JSON schema validation) and other commands, and reuse or centralize instead of duplicating. |
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.


Encodes the conventions maintainers repeatedly asked for in review (mostly of Copilot coding agent PRs) so they're applied before review, and enforces the deterministic ones.
Enforcement
System.Consoleuse (RS0030viaMicrosoft.CodeAnalysis.BannedApiAnalyzers,BannedSymbols.txt) inDevProxy.Plugins,DevProxy.Abstractions,DevProxy.Proxy.KestrelandDevProxy/Commands. Feedback: Replace --log-for with --output text|json for structured output #1548, Adddevproxy config validatesubcommand #1552, Adddevproxy api showcommand and API section to--help#1553. Existing code passes without changes.DevProxy(Program.cs, console formatters, interactive console) legitimately uses the console and is out of scope.api token,jwt,logs,status,stop,stdio, cert prompt, help actions) are exempted by file in.editorconfig. Migrating them toILoggerwould change their output (log levels, stderr thresholds, formatting), so it's left out of this PR. New command files,ConfigCommand,OutdatedCommandandDevProxyCommandare enforced.HelpExamples.Addnow takes(command, description)pairs and pads them to a shared column. This also fixes existing runtime misalignment indevproxy --helpanddevproxy jwt create --help(escaped quotes made source alignment differ from output).Instructions (prose)
.github/copilot-instructions.md› Code Conventions: build/test before review, lock files only with dependency changes (Add bodyRegex support for MockStdioResponsePlugin stdin matching #1530, Fix off-by-one in random error plugins' failure rate check #1929–Expand leading ~/ to home directory in config file paths #1936), no console output, reuse utilities, minimal visibility (Extend MinimalPermissionsGuidancePlugin with scopes to ignore #1365), focused PRs and naming..github/instructions/commands.instructions.md(DevProxy/Commands/**): logger +LogStructuredOutput, global--output, exit codes 0/1/2 (Document exit codes in CLI help output and return exit code 2 for input errors #1546, Adddevproxy config validatesubcommand #1552), defaults from code (Adddevproxy api showcommand and API section to--help#1553), noun-verb naming (Adddevproxy api showcommand and API section to--help#1553), help examples..github/instructions/schemas.instructions.md(schemas/**): new properties only in the current version; fixes to all versions since introduction (Extend MinimalPermissionsGuidancePlugin with scopes to ignore #1365, Remove maxMs limit from LatencyPlugin schema #1469, Add bodyRegex support for MockStdioResponsePlugin stdin matching #1530).Rules that can't be checked deterministically (schema versioning, exit codes, naming, lock-file churn) stay as instructions.
Validation
dotnet restore DevProxy.sln --locked-mode, build (0 warnings), all tests pass. VerifiedRS0030fires in each enforced project/folder and not in exempted files.