Skip to content

Generic base codec instantiation tries to use the generic type parameters from the derived type #9357

@willg1983

Description

@willg1983

Describe The Bug

Consider these type hierarchies:

DerivedGeneric<T>: Base<T>
DerivedNoGeneric : Base<int>

Lets assume there is a BaseCodec<T> for Base<T> lets assume there is not a codec for DerivedGeneric and DerivedNoGeneric in this example.

serializer.CanSerialize(typeof(DerivedGeneric<R>)) returns false
serializer.CanSerialize(typeof(DerivedNoGeneric)) throws: System.ArgumentException : The number of generic arguments provided doesn't equal the arity of the generic type definition. (Parameter 'instantiation')

CodecProvider tries to instantiate a base codec using the generic arguments of the parent type, which works when the parent has generic arguments but not when it doesn't.

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