Skip to content

C#: add opt-in nullable reference type output - #3098

Open
foobra wants to merge 1 commit into
glideapps:masterfrom
foobra:agent/csharp-nullable-reference-types
Open

C#: add opt-in nullable reference type output#3098
foobra wants to merge 1 commit into
glideapps:masterfrom
foobra:agent/csharp-nullable-reference-types

Conversation

@foobra

@foobra foobra commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Closes #3097.

What changed

  • Add the opt-in --nullable-reference-types C# renderer option.
  • Keep the existing output unchanged when the option is omitted.
  • Emit nullable reference annotations for optional properties.
  • Enable nullable-reference compiler directives and warning suppression when the option is enabled.
  • For Newtonsoft.Json, avoid Required.DisallowNull on optional properties in this mode.
  • Make the generated Newtonsoft FromJson result nullable in this mode.
  • Add unit, type-level, and C# fixture coverage.

The option is intended for projects compiling with C# 8 or later. It can be combined with the existing --csharp-version 5/6 setting when consumers need the older generated syntax plus nullable reference annotations.

Validation

  • npm run build
  • Targeted Vitest tests: 13 passed
  • Biome check: passed
  • The C# fixture suite was attempted but could not run locally because this environment has .NET 6 and .NET 10 installed while the fixture targets .NET 8.

@github-actions

Copy link
Copy Markdown

Generated-output differences

8 files differ — 0 modified, 8 new, 0 deleted
23642 changed lines — +23642 / −0

Open the generated-output report →

@foobra
foobra marked this pull request as ready for review July 31, 2026 05:03
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.

C#: add an opt-in Newtonsoft-compatible nullable reference output mode

1 participant