Table of Contents

NBMsgPack010: [DerivedTypeShape] should specify an assignable type

DerivedTypeShapeAttribute should specify a type that is assignable to the type the attribute is applied to.

Learn more about subtype unions.

Example violations

[DerivedTypeShape(typeof(DerivedType), Tag = 1)] // DerivedType is not in fact derived from BaseType
class BaseType
{
}

[GenerateShape]
class DerivedType
{
}

Resolution

Remove the attribute or specify a type that is actually derived from the applied type.

In the fixed code below, the DerivedType is actually fixed to derive from BaseType.

[DerivedTypeShape(typeof(DerivedType), Tag = 1)]
class BaseType
{
}

[GenerateShape]
class DerivedType : BaseType
{
}