Skip to content

Commit

Permalink
Apply code review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndiritu committed Oct 5, 2023
1 parent 87759f0 commit f39f2e5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 1 addition & 2 deletions src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,7 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co
if (!supportsInnerClasses)
{
var @namespace = codeClass.GetImmediateParentOfType<CodeNamespace>();
var existingClass = @namespace.FindChildByName<CodeClass>(codeComposedType.Name, false);
if (existingClass != null && existingClass.OriginalComposedType == null)
if (@namespace.FindChildByName<CodeClass>(codeComposedType.Name, false) is CodeClass { OriginalComposedType: null })
codeComposedType.Name = $"{codeComposedType.Name}Wrapper";
newClass = @namespace.AddClass(new CodeClass
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ public async Task RenamesComposedTypeWrapperWhenSimilarClassExistsInNamespace()
Name = "property",
Type = composedType
});

await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.PHP }, root);
Assert.NotNull(root.FindChildByName<CodeClass>("UnionWrapper", false));
}
Expand Down Expand Up @@ -289,5 +288,4 @@ public async Task DoesNotCreateDuplicateComposedTypeWrapperIfOneAlreadyExists()
Assert.True(root.FindChildByName<CodeClass>("Union", false) is CodeClass unionTypeWrapper && unionTypeWrapper.OriginalComposedType != null);
Assert.True(root.FindChildByName<CodeClass>("UnionWrapper", false) is null);
}

}

0 comments on commit f39f2e5

Please sign in to comment.