Fix InputParserGenerator CS8619 on Dictionary<string,string?> flags (#378)#379
Merged
Conversation
…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>
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.
Fixes #378.
Problem
InputParserGeneratoremits#nullable enableand casts aDictionary<string, string?>flag member — e.g. the inheritedNetCoreInput.ConfigFlag— to theIDictionary<string, string>shape thatGeneratedDictionaryFlagrequires:Those types are identical at runtime (nullable annotations are erased) but nullably-distinct to the compiler, so under
#nullable enable+TreatWarningsAsErrorsit's CS8619 — a build break for net10 consumers. Discovered upgrading WolverineFx to JasperFx 2.1.2 (dotnet build wolverine.slnx -c Releasefailed 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 typedIDictionary<string, string>, whileConfigFlagisDictionary<string, string?>.Fix
Emit
#nullable disablein the generated parser. Machine-generated parser code shouldn't participate in nullable analysis, and the generator already renders member types viaFullyQualifiedFormat(which emits no?annotations), so this introduces no CS8632. Runtime behavior is unchanged.Test
InputParserGeneratorTests.dictionary_flag_parser_compiles_clean_under_nullableruns the generator on aDictionary<string, string?>flag and asserts the generated parser carries#nullable disableand produces no CS8619 underNullableContextOptions.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