Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] StringV is not castable to classes implementing ScalarValue<string> #183

Open
Texnomic opened this issue Jan 19, 2022 · 0 comments
Open

Comments

@Texnomic
Copy link

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:

  1. Making StringV not sealed
  2. Replacing IsAssignableFrom check with string or ScalarValue<string> check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant