Add wolverine-diagnostics codegen-preview CLI command#2486
Merged
jeremydmiller merged 2 commits intoApr 9, 2026
Conversation
- Wolverine now detects codegen commands (via DynamicCodeBuilder.WithinCodegenCommand)
and OpenAPI generation tools (via ASPNETCORE_HOSTINGSTARTUPASSEMBLIES containing
"GetDocument") and automatically applies lightweight startup mode, suppressing
persistence and transport initialization.
- Replaced the Environment.CommandLine.Contains("codegen") code smell in
WolverineHttpEndpointRouteBuilderExtensions with DynamicCodeBuilder.WithinCodegenCommand.
- Added smoke tests verifying codegen preview and host startup work without DB.
- Added documentation in command-line.md explaining that CLI commands do not
require external connectivity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new `wolverine-diagnostics` Oakton command with an extensible sub-command dispatch pattern (string action argument). The first sub-command is `codegen-preview`: dotnet run -- wolverine-diagnostics codegen-preview --handler MyApp.Orders.CreateOrder dotnet run -- wolverine-diagnostics codegen-preview --route "POST /api/orders" - --handler: accepts fully-qualified message type, short class name, or handler class name with fuzzy contains fallback; prints the single generated MessageHandler adapter class with full middleware chain. - --route: converts "METHOD /path" to an expected HttpChain FileName and searches all ICodeFileCollection instances, so HTTP endpoints work without a direct Wolverine.Http compile-time dependency from core. - Starts the host in codegen lightweight mode so no DB/transport connectivity is required (same behaviour as `codegen preview --start`). - 13 passing unit/smoke tests covering route-name conversion, handler chain matching strategies, and end-to-end code generation. - Docs added to docs/guide/command-line.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 11, 2026
This was referenced Apr 18, 2026
This was referenced Apr 25, 2026
This was referenced May 9, 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.
Summary
Closes #2467.
WolverineDiagnosticsCommand(wolverine-diagnostics) tosrc/Wolverine/Diagnostics/as an extensible parent command using a string-typed sub-command action (JasperFx/Oakton's idiomatic pattern — no true sub-command mechanism exists; enum-style dispatch used via string switch).codegen-previewwith--handlerand--routeflags.Wolverinepackage; HTTP route support avoids a direct compile-time dependency onWolverine.Httpby matching againstICodeFile.FileName(mirrorsHttpChain.determineFileName()logic).Usage:
```bash
By fully-qualified message type
dotnet run -- wolverine-diagnostics codegen-preview --handler MyApp.Orders.CreateOrder
By short class name or handler class name (fuzzy match)
dotnet run -- wolverine-diagnostics codegen-preview --handler CreateOrderHandler
HTTP endpoint
dotnet run -- wolverine-diagnostics codegen-preview --route "POST /api/orders"
dotnet run -- wolverine-diagnostics codegen-preview --route "GET /api/orders/{id}"
```
Note on sub-command naming: JasperFx's `Enum.Parse`-based argument conversion does not support hyphens in enum value names. Using a `string` action property allows `codegen-preview` (with hyphen) to work exactly as described in the issue. Future sub-commands (`describe-routing`, `describe-resiliency`) follow the same pattern.
Test plan
🤖 Generated with Claude Code