Skip to content

Encode recurring review conventions in Copilot instructions and analyzers - #2127

Merged
waldekmastykarz merged 6 commits into
dotnet:mainfrom
waldekmastykarz:agent-conventions-analyzers
Nov 25, 2026
Merged

waldekmastykarz merged 6 commits into
dotnet:mainfrom
waldekmastykarz:agent-conventions-analyzers

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

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

Instructions (prose)

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. Verified RS0030 fires in each enforced project/folder and not in exempted files.

waldekmastykarz and others added 3 commits November 20, 2026 08:58
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>
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner November 20, 2026 07:58
Copilot AI balanced review requested due to automatic review settings November 20, 2026 07:58

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.

🟡 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.Console ban, 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>

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.

🟢 Approval recommended

There are no outstanding review issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@waldekmastykarz waldekmastykarz added the pr-review Code review quality, review conventions, and automated PR validation or CI improvements label Nov 21, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 13:44
@waldekmastykarz
waldekmastykarz merged commit 7817144 into dotnet:main Nov 25, 2026
18 checks passed
@waldekmastykarz
waldekmastykarz deleted the agent-conventions-analyzers branch November 25, 2026 13:46

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.

🟡 Changes recommended

The recommended output fallback ignores configured JSON output, causing commands to emit human-readable log messages instead of structured result payloads.

1 open issue

Review effort: Balanced

# 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-review Code review quality, review conventions, and automated PR validation or CI improvements

2 participants