Skip to content

Commit

Permalink
- fixes a conflict when adding types wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet committed Sep 21, 2023
1 parent f8fd487 commit cdb013c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Kiota.Builder/CodeDOM/CodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private T HandleDuplicatedExceptions<T>(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) &&
Expand All @@ -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;
Expand Down

0 comments on commit cdb013c

Please sign in to comment.