From d287acbcf271dee1b2f1e58e7afe0e5450f7b424 Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Tue, 19 Nov 2024 14:37:09 +0100 Subject: [PATCH] Align inheritance converter liquid with actual implementation, #1729 --- .../Templates/JsonInheritanceConverter.liquid | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Templates/JsonInheritanceConverter.liquid b/src/NJsonSchema.CodeGeneration.CSharp/Templates/JsonInheritanceConverter.liquid index df07bfae9..26cb4bc93 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Templates/JsonInheritanceConverter.liquid +++ b/src/NJsonSchema.CodeGeneration.CSharp/Templates/JsonInheritanceConverter.liquid @@ -103,11 +103,11 @@ public class JsonInheritanceConverter : 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(System.Reflection.IntrospectionExtensions.GetTypeInfo(objectType), true)) + foreach (var attribute in System.Reflection.CustomAttributeExtensions.GetCustomAttributes(System.Reflection.IntrospectionExtensions.GetTypeInfo(baseType), true)) { - if (attribute.Key == discriminator) + if (attribute.Key == discriminatorValue) return attribute.Type; } @@ -122,7 +122,7 @@ public class JsonInheritanceConverter : System.Text.Json.Serialization.Js return attribute.Key; } - return objectType.Name; + return null; } } {%- else -%}