Open trrwilson opened 2 weeks ago
@trrwilson :( unfortunately this is known issue for quite a long time. Here is another issue tracking this: https://github.com/Azure/autorest.csharp/issues/5146
@JoshLove-msft do you know how and when we could deal with this? As far as I know, the new generator should be able to handle this case, right?
Yes, the new generator has support for multi-level discriminators.
Problem summary
When defining a discriminated type that extends another discriminated type, the generated constructors for the downstream types don't set the right values, which results in malformed serialization.
Repro
Standalone project: csharp-emitter-double-discriminator-repro.zip
Example models (from
main.tsp
):With the above, the public
Dog()
constructor is an instance of the issue.More details
From the
README
included in the above repro .zip:Search for and open
Dog.cs
and observe the generated constructors:While the internal constructor is correct and properly sets the inner discriminator of
Breed
to the provided value while invoking the parent type'sbase
constructor to set the outer discriminator oftaxonomic_family
, the public constructor has multiple issues:base
constructor at alltaxonomic_value
to any valuebreed
) to the intended value of outer discriminator (taxonomic_family
)As a result of this, serialized instances of
Dog
are very malformed: