Skip to content

Fix InputParserGenerator CS8619 on Dictionary<string,string?> flags (#378)#379

Merged
jeremydmiller merged 2 commits into
mainfrom
fix-378-inputparser-nullable
May 27, 2026
Merged

Fix InputParserGenerator CS8619 on Dictionary<string,string?> flags (#378)#379
jeremydmiller merged 2 commits into
mainfrom
fix-378-inputparser-nullable

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Fixes #378.

Problem

InputParserGenerator emits #nullable enable and casts a Dictionary<string, string?> flag member — e.g. the inherited NetCoreInput.ConfigFlag — to the IDictionary<string, string> shape that GeneratedDictionaryFlag requires:

obj => ((StorageInput)obj).ConfigFlag as System.Collections.Generic.IDictionary<string, string>,
(obj, val) => ((StorageInput)obj).ConfigFlag = (Dictionary<string, string>)val),

Those types are identical at runtime (nullable annotations are erased) but nullably-distinct to the compiler, so under #nullable enable + TreatWarningsAsErrors it's CS8619 — a build break for net10 consumers. Discovered upgrading WolverineFx to JasperFx 2.1.2 (dotnet build wolverine.slnx -c Release failed with 8 × CS8619 on net10.0; net9.0 was unaffected). The CLI generators became active in #370, which is why this surfaced now.

The mismatch is intrinsic at the cast site: GeneratedDictionaryFlag's delegates are typed IDictionary<string, string>, while ConfigFlag is Dictionary<string, string?>.

Fix

Emit #nullable disable in the generated parser. Machine-generated parser code shouldn't participate in nullable analysis, and the generator already renders member types via FullyQualifiedFormat (which emits no ? annotations), so this introduces no CS8632. Runtime behavior is unchanged.

Test

InputParserGeneratorTests.dictionary_flag_parser_compiles_clean_under_nullable runs the generator on a Dictionary<string, string?> flag and asserts the generated parser carries #nullable disable and produces no CS8619 under NullableContextOptions.Enable. Verified it fails before the fix and passes after.

Unblocks the WolverineFx → JasperFx 2.1.2 upgrade once this ships (2.1.3).

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits May 26, 2026 20:30
…378)

The generated input parser emitted `#nullable enable` and cast Dictionary<string,string?>
flag members (e.g. the inherited NetCoreInput.ConfigFlag) to IDictionary<string,string> — the
delegate type GeneratedDictionaryFlag requires. Those are runtime-identical but nullably-distinct,
so under `#nullable enable` + TreatWarningsAsErrors it's CS8619 and breaks consumer builds (net10;
discovered upgrading WolverineFx to JasperFx 2.1.2).

Emit `#nullable disable` in the generated parser instead — machine-generated parser code shouldn't
participate in nullable analysis, and the generator already renders member types via
FullyQualifiedFormat (no `?` annotations emitted), so this introduces no CS8632.

Adds InputParserGeneratorTests asserting a Dictionary<string,string?> flag generates a parser that
compiles clean under nullable (no CS8619). Verified to fail before the fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 10ba178 into main May 27, 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.

InputParserGenerator drops nullable annotation on Dictionary<string,string?> flags → CS8619 breaks net10 + nullable + TreatWarningsAsErrors consumers

1 participant