Open uflowie opened 1 month ago
Is this causing a real world problem? Your controllers should typically never return just an object and not an ActionRest, in order to support NotFound, etc.
Our controllers aren't returning just an object, they are returning a Result
Right but based on what you're writing above, if they returned ActionResult<Result<T>>
everything would work correctly.
ActionResult<Result<T>>
does not work either, only ActionResult<T>
When serializing a derived type as its base type, System.Text.Json will use an extra type discriminator field to communicate the actual type of the serialized data. Given a base class
Base
and a derived typeDerived
, I have observed the following behavior:Base
will correctly include the type discriminator.ActionResult<Base>
will include the type discriminator.Result<Base>
will include the properties of the derived type but it will NOT include the type discriminator.Minimal reproducible example: https://github.com/uflowie/ResultLostTypeDiscriminator