Closed nullpainter closed 2 years ago
Actually, this can be replicated without an additional property and just with additional input bytes. The first model above but with the input BrownBearTrailer
results in the same behaviour.
I think I may have answered my own question - using a single field in my model and using Subtype
instead of SerializeWhen
did the trick.
I am parsing a data structure where a fixed-length section may have a different shape depending on a discriminator property. I am using a combination of
SerializeWhen
andSerializeWhen
withComparisonOperator.NotEqual
. This is working as expected unless there are fields after the conditional fields.Fot the sample class:
The inputs
BrownBear
andBlackBear
correctly populates theAnimal
property withBear
. Likewise, the inputGreenPear
correctly populates theFruit
property withPear
.However when the class is changed to add an additional property:
The input
BrownBearTrailer
results in theAnimal
property being correctly set, but theFruit
property set toTrai
and theTrailer
property set toler
.Am I misusing these properties, or is there something else I need to do to say that the two
Animal
andFruit
properties map to the same bytes?