Skip to content

codegen: --language fsharp flag (2.4.1)#406

Merged
jeremydmiller merged 1 commit into
mainfrom
feat-codegen-fsharp-language
Jun 1, 2026
Merged

codegen: --language fsharp flag (2.4.1)#406
jeremydmiller merged 1 commit into
mainfrom
feat-codegen-fsharp-language

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Adds a --language flag (csharp | fsharp, default csharp) to the codegen command so a JasperFx app can pre-generate its runtime code as F#:

dotnet run -- codegen write --language fsharp

The F# emit capability (GeneratedAssembly.GenerateFSharpCode) already existed; this wires it through the CLI write/preview paths.

Changes

  • CodegenLanguage enum + GenerateCodeInput.LanguageFlag.
  • DynamicCodeBuilder.Language threads into both the write and preview paths — renderCode picks GenerateFSharpCode vs GenerateCode, and the file extension is .fs vs .cs.
  • codegen test --language fsharp is rejected with a clear message (the test action uses in-memory C# Roslyn compilation, which doesn't apply to F#).
  • CI: SmokeTestCommands now also runs codegen preview --language fsharp --start against GeneratorTarget, validating the flag emits F# end-to-end through the CLI.
  • 5 unit tests for the language switch + .fs extension.
  • Bumped JasperFxVersion2.4.1.

Verification

  • dotnet build jasperfx.slnx -c Release clean; 404 CodegenTests pass.
  • ✅ Smoke-ran codegen preview --language fsharp against GeneratorTarget on net9.0 and net10.0 — emits namespace/open/type F#.

Scope note

This proves the CLI plumbing. Compilable/runnable pre-generated F# is proven downstream against real Wolverine handler chains (the F# emitter targets the static model and is validated by Wolverine's behavioural run-step under TypeLoadMode.Static). The experimental emitter's handling of some C#-style frames (e.g. return) is unchanged here.

🤖 Generated with Claude Code

Adds a `--language` flag (csharp|fsharp, default csharp) to the `codegen` command
so `dotnet run -- codegen write --language fsharp` writes the pre-generated code as
F# (.fs) instead of C# (.cs). The F# emit capability (GeneratedAssembly.GenerateFSharpCode)
already existed; this wires it through the CLI.

- CodegenLanguage enum + GenerateCodeInput.LanguageFlag.
- DynamicCodeBuilder.Language threads into the write and preview paths (renderCode
  picks GenerateFSharpCode vs GenerateCode; .fs vs .cs extension).
- `codegen test --language fsharp` is rejected with a clear message (the test action
  uses in-memory C# Roslyn compilation, which doesn't apply to F#).
- CI: SmokeTestCommands runs `codegen preview --language fsharp --start` against
  GeneratorTarget to validate the CLI flag emits F#. (Compilable/runnable pre-generated
  F# is proven downstream against real Wolverine handler chains.)
- 5 unit tests for the language switch + .fs extension. Bumped JasperFxVersion to 2.4.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit e25fec9 into main Jun 1, 2026
1 check 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.

1 participant