feat(csharp): add options to disable DateOnly and TimeOnly generation for System.Text.Json by findyoucef · Pull Request #2842 · glideapps/quicktype

Description

Adds two new C# renderer options to control whether DateOnly and TimeOnly types are emitted when generating System.Text.Json code. Also updates the renderer to conditionally register their converters and refreshes ajv and esbuild dependencies.

Related Issue

#2629

Motivation and Context

Projects targeting .NET Standard lack DateOnly and TimeOnly, causing compilation errors in generated code. This change adds --no-dateonly and --no-timeonly options so users can disable these types for better cross-platform compatibility.

Previous Behaviour / Output

Generated code always included:

public DateOnly StartDate { get; set; }
options.Converters.Add(new DateOnlyConverter());

Which fails on .NET Standard.

New Behaviour / Output

With flags:

quicktype --lang csharp --framework system-text-json --no-dateonly --no-timeonly

Output now omits DateOnly/TimeOnly and related converters:

public DateTime StartDate { get; set; }
// No DateOnlyConverter registration

How Has This Been Tested?

  • Verified .NET 7 (default behavior) and .NET Standard 2.0 (flags enabled) compile successfully.
  • Generated C# code compatible with .NET Standard by disabling unsupported DateOnly/TimeOnly types.

Summary

Adds no-dateonly and no-timeonly C# options for System.Text.Json codegen.

Impact

Allows generating C# code compatible with .NET Standard by disabling unsupported DateOnly/TimeOnly types.