faunadb-csharp
faunadb-csharp copied to clipboard
[Bug] StringV is not castable to classes implementing ScalarValue<string>
StringV is sealed class, so the only way to create a derived class is to inherit from ScalarValue<string>. The internal Decoder works one way only: ScalarValue<string> Derived Class to StringV but not the other way around.
Digging deeper into internal decoder implementation, the root cause is the usage of
typeof(StringV).IsAssignableFrom(typeof(DerivedClass))
typeof(DerivedClass).IsAssignableFrom(typeof(StringV))
which in both ways evaluates to false and throws Invalid Cast Exception.
This can be fixed in one of two ways:
- Making
StringVnot sealed - Replacing
IsAssignableFromcheck withstringorScalarValue<string>check.