Skip to content

Auto-detect metadata-only CLI mode to suppress DB/transport init#2485

Merged
jeremydmiller merged 1 commit intomainfrom
fix/2471-metadata-only-cli-mode
Apr 9, 2026
Merged

Auto-detect metadata-only CLI mode to suppress DB/transport init#2485
jeremydmiller merged 1 commit intomainfrom
fix/2471-metadata-only-cli-mode

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

Fixes #2471.

  • Auto-detect codegen mode: WolverineRuntime.StartAsync now calls applyMetadataOnlyModeIfDetected() before any persistence or transport initialization. When DynamicCodeBuilder.WithinCodegenCommand is true (set by JasperFx when the codegen command is in the command-line args or when running with --start), Wolverine automatically applies lightweight startup settings: external transports are stubbed, durability agents are disabled, and the durability mode is set to MediatorOnly.
  • Auto-detect OpenAPI generation tools: The same detection also checks ASPNETCORE_HOSTINGSTARTUPASSEMBLIES for "GetDocument", which is set by Microsoft.Extensions.ApiDescription.Server (GetDocument.Insider) when generating OpenAPI docs. This removes the need for users to add GetCommandLineArgs or assembly-name workarounds.
  • Fix code smell: Replaced Environment.CommandLine.Contains("codegen", StringComparison.OrdinalIgnoreCase) in WolverineHttpEndpointRouteBuilderExtensions with DynamicCodeBuilder.WithinCodegenCommand.
  • Tests: Two smoke tests — one verifying codegen preview builds without starting the host, one verifying StartAsync applies lightweight mode when WithinCodegenCommand is true.
  • Docs: command-line.md updated with a section explaining that CLI diagnostic commands do not require external connectivity.

Test plan

  • Bug_2471_codegen_without_connectivity tests pass (2/2)
  • Wolverine.csproj builds with 0 errors
  • Wolverine.Http.csproj builds with 0 errors
  • CoreTests.csproj builds with 0 errors

🤖 Generated with Claude Code

- 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>
@jeremydmiller jeremydmiller merged commit 82488b2 into main Apr 9, 2026
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure codegen and OpenAPI CLI commands work without database/transport connectivity

1 participant