[Bug] StringV is not castable to classes implementing ScalarValue<string>
Texnomic opened this issue · comments
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
StringV
not sealed - Replacing
IsAssignableFrom
check withstring
orScalarValue<string>
check.