// readme

Aviationexam.GeneratedJsonConverters.SourceGenerator

Motivation for this library are polymorphic contracts with discriminator property not present as first property.

i.e. this JSON

{
    "baseProperty": 1,
    "$type": 2,
    "anotherLeafProperty": 2
}

is deserialized correctly into AnotherLeafContract using this library.

And string based enum serialization.

Install

<ItemGroup>
    <PackageReference Include="Aviationexam.GeneratedJsonConverters.SourceGenerator" Version="0.1.0" />
</ItemGroup>

The generated converters derive from public types in Aviationexam.GeneratedJsonConverters.Abstractions, which the generator package brings in as a dependency. netstandard2.0 projects get Aviationexam.GeneratedJsonConverters.Abstractions.NetStandard instead, built from the same sources under a different assembly name. Do not mark the reference PrivateAssets="all": projects referencing yours need the abstractions assembly at runtime. The analyzer and its build properties stay private by default.

A netstandard2.0-only library used by net8.0+ applications must reference the netstandard2.0 abstractions itself, because those applications restore the…