From 771fbf1d0f7700d033716a9aad85a420d1cd6b4a Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 20 Sep 2023 15:02:34 -0400 Subject: [PATCH] - fixes a conflict when adding types wrappers --- src/Kiota.Builder/CodeDOM/CodeBlock.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Kiota.Builder/CodeDOM/CodeBlock.cs b/src/Kiota.Builder/CodeDOM/CodeBlock.cs index be31a2b068..1b7255977f 100644 --- a/src/Kiota.Builder/CodeDOM/CodeBlock.cs +++ b/src/Kiota.Builder/CodeDOM/CodeBlock.cs @@ -75,6 +75,7 @@ private T HandleDuplicatedExceptions(T element, CodeElement returnedValue) wh if (returnedValue == element) return element; if (element is CodeMethod currentMethod) + { if (currentMethod.IsOfKind(CodeMethodKind.IndexerBackwardCompatibility) && returnedValue is CodeProperty cProp && cProp.IsOfKind(CodePropertyKind.RequestBuilder) && @@ -99,6 +100,21 @@ returnedValue is CodeProperty cProp && return result2; } } + } + else if (element is CodeProperty currentProperty) + { + if (currentProperty.Kind is CodePropertyKind.Custom && + returnedValue is CodeClass returnedClass && returnedClass.Kind is CodeClassKind.Model && + InnerChildElements.TryAdd($"{element.Name}-property", currentProperty)) + return element; // inline type property: transforming union type to wrapper class + } + else if (element is CodeClass currentClass) + { + if (currentClass.Kind is CodeClassKind.Model && + returnedValue is CodeProperty returnedProperty && returnedProperty.Kind is CodePropertyKind.Custom && + InnerChildElements.TryAdd($"{element.Name}-model", currentClass)) + return element; // inline type property: transforming wrapper class to union type + } if (element.GetType() == returnedValue.GetType()) return (T)returnedValue;