Skip to content

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

@Texnomic

Description

@Texnomic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions