Skip to content

Commit

Permalink
Align inheritance converter liquid with actual implementation, #1729
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoSuter committed Nov 19, 2024
1 parent 4e5c49a commit d287acb
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public class JsonInheritanceConverter<TBase> : System.Text.Json.Serialization.Js
throw new System.InvalidOperationException("Could not find subtype of '" + objectType.Name + "' with discriminator '" + discriminatorValue + "'.");
}

private System.Type GetObjectSubtype(System.Type objectType, string discriminator)
private System.Type GetObjectSubtype(System.Type baseType, string discriminatorValue)
{
foreach (var attribute in System.Reflection.CustomAttributeExtensions.GetCustomAttributes<JsonInheritanceAttribute>(System.Reflection.IntrospectionExtensions.GetTypeInfo(objectType), true))
foreach (var attribute in System.Reflection.CustomAttributeExtensions.GetCustomAttributes<JsonInheritanceAttribute>(System.Reflection.IntrospectionExtensions.GetTypeInfo(baseType), true))
{
if (attribute.Key == discriminator)
if (attribute.Key == discriminatorValue)
return attribute.Type;
}

Expand All @@ -122,7 +122,7 @@ public class JsonInheritanceConverter<TBase> : System.Text.Json.Serialization.Js
return attribute.Key;
}

return objectType.Name;
return null;
}
}
{%- else -%}
Expand Down

0 comments on commit d287acb

Please sign in to comment.