feat: C# 15 union type support — Argh CLI binding + UnionMakeApp<TUnion>#59
Draft
Mpdreamz wants to merge 3 commits into
Draft
feat: C# 15 union type support — Argh CLI binding + UnionMakeApp<TUnion>#59Mpdreamz wants to merge 3 commits into
Mpdreamz wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds CliScalarKind.Union and two binding modes: - Flag mode: --format <case> [--<case>-<prop> ...] e.g. union-format-flag --format union-json --union-json-pretty - Argument mode: <case> [--<prop> ...] e.g. union-format-arg union-json --pretty The generator detects IUnion/[Union] on parameter types, emits a switch-based assembly block post flag-parse, and wires prop flags to the matching case constructor. Case-prop flags are prefixed with the case CLI name in flag mode to avoid collisions; in argument mode they are bare (matching across cases that share prop names is fine). Includes 12 new integration tests covering both modes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a C#-native build target DSL that uses union types as the target
identity, bringing the C# API much closer to the existing F# MakeApp.
Consumer pattern:
union Build(Clean, Test, Pack);
var app = new UnionMakeApp<Build>();
app.Bind(b => b switch {
Clean c => app.Target().Executes(() => ...),
Test t => app.Target().DependsOn(new Clean()).Executes(() => ...),
Pack p => app.Target().DependsOn<Test>().Executes(() => ...),
});
await app.RunAsync(args);
Key additions:
- UnionMakeApp<TUnion>: discovers cases via UnionReflector, resolves
DependsOn/Composes deps, delegates to existing DepGraphExecutor.
- UnionReflector: IUnion detection, recursive case enumeration (nested
unions become namespaced routes), default-instance construction.
- IUnionTargetBuilder<TUnion> / UnionTargetBuilderImpl<TUnion>: fluent
builder with DependsOn(TUnion), DependsOn<T1..T4>() generic overloads,
and Composes() variants.
- UnionOptionRef<T>: typed global flag/option with implicit T conversion.
- TargetNode gains RouteRequires/RouteComposes for deferred dep resolution.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a06ced6 to
89a931e
Compare
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
Two complementary features built on C# 15 discriminated unions (lowered to
IUnion/[Union]):1. Argh: union types as CLI parameters
Union cases become selectable CLI values with case-specific flags — two binding modes:
Flag mode — a selector flag names the case, case properties become
--<case>-<prop>flags:Argument mode — case name is a positional, properties become bare flags:
Union type definition (C# 15 syntax):
IUnion/[Union]on parameter types via Roslyn--json-prettyvs--table-pretty)--prettyon bothJsonandTable) are valid — the active case determines which is used2. Argh.Make:
UnionMakeApp<TUnion>C# DSLA C#-native build target DSL that uses union types as the target identity, bringing the C# API much closer to the existing F#
MakeApp<'TCase>API.Generic
DependsOnoverloads for compile-time-safe deps without instantiating a union value:Global flags/options (named options shared across all targets):
Nested unions for namespaced target groups:
Key implementation files:
src/Nullean.Make/UnionMakeApp.cs— entry point, graph building, dep resolutionsrc/Nullean.Make/UnionGraph/UnionReflector.cs—IUniondetection, recursive case enumeration, default constructionsrc/Nullean.Make/UnionGraph/IUnionTargetBuilder.cs— fluent builder interfacesrc/Nullean.Make/UnionGraph/UnionTargetBuilderImpl.cs— internal implementationsrc/Nullean.Make/UnionGraph/UnionOptionRef.cs— typed global flag/optionOpen items (tracked separately)
schema --helpfalls back to root help instead of schema-specific helpUnionMakeAppintegration tests (Make side untested, only Argh CLI tested)--format <table|json|csv>etc.)Test plan
dotnet test -c Release)UnionMakeApp(no automated tests yet)🤖 Generated with Claude Code