You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Search for and open Dog.cs and observe the generated constructors:
/// <summary> Initializes a new instance of <see cref="Dog"/>. </summary>publicDog(){Breed="canidae";}/// <summary> Initializes a new instance of <see cref="Dog"/>. </summary>/// <param name="taxonomicFamily"></param>/// <param name="serializedAdditionalRawData"> Keeps track of any properties unknown to the library. </param>/// <param name="breed"></param>internalDog(string taxonomicFamily,IDictionary<string,BinaryData> serializedAdditionalRawData,string breed):base(taxonomicFamily,serializedAdditionalRawData){Breed=breed;}
While the internal constructor is correct and properly sets the inner discriminator of Breed to the provided value while invoking the parent type's base constructor to set the outer discriminator of taxonomic_family, the public constructor has multiple issues:
It doesn't invoke the base constructor at all
It doesn't set the outer discriminator of taxonomic_value to any value
It instead sets the inner discriminator (breed) to the intended value of outer discriminator (taxonomic_family)
As a result of this, serialized instances of Dog are very malformed:
{
"taxonomic_family": null,
"breed": "canidae"
}
The text was updated successfully, but these errors were encountered:
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:The text was updated successfully, but these errors were encountered: