[csharp][generichost] Write the selected member of an anyOf with a discriminator
With the C# generichost library, a model with anyOf and a discriminator is read into the right member but written as {}, so request bodies built from it go out empty. In JsonConverter.mustache the anyOf writer was skipped for every model with a discriminator, and the discriminator branch of Write only handled oneOf.
I removed the ^model.discriminator guard around the anyOf writer. Read fills only the member the discriminator picks, so Write now emits that member's properties, same as oneOf.
Tested with the schema from the issue in a .NET 9 container, both subtypes serialize back to the original JSON. Added testAnyOfDiscriminatorWritesSelectedSubtype to CSharpClientCodegenTest. Regenerating the generichost sample configs changes no files.
Fixes #25154
cc @devhl-labs @mandrean @shibayan @Blackclaws @lucamazzanti
Assisted by Claude/Codex.
Summary by cubic
Fixes C# generichost serialization so anyOf models with a discriminator write the selected member instead of an empty object.
The anyOf writer in JsonConverter.mustache was skipped for every model with a discriminator, and the discriminator branch of Write only handled oneOf. Removing the guard lets Write emit the properties of the member the discriminator picks, matching oneOf behavior.
- Adds
testAnyOfDiscriminatorWritesSelectedSubtypetoCSharpClientCodegenTestto verify serialization of the selected subtype.