From f39f2e5e95bb92b930879f28cab270c433401224 Mon Sep 17 00:00:00 2001 From: Philip Gichuhi Date: Tue, 3 Oct 2023 11:26:18 +0300 Subject: [PATCH] Apply code review suggestion --- src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs | 3 +-- tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index c9b1e4e2f0..ba248fa6c8 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -479,8 +479,7 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co if (!supportsInnerClasses) { var @namespace = codeClass.GetImmediateParentOfType(); - var existingClass = @namespace.FindChildByName(codeComposedType.Name, false); - if (existingClass != null && existingClass.OriginalComposedType == null) + if (@namespace.FindChildByName(codeComposedType.Name, false) is CodeClass { OriginalComposedType: null }) codeComposedType.Name = $"{codeComposedType.Name}Wrapper"; newClass = @namespace.AddClass(new CodeClass { diff --git a/tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs index ddebaaac77..d18d1e4990 100644 --- a/tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs @@ -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("UnionWrapper", false)); } @@ -289,5 +288,4 @@ public async Task DoesNotCreateDuplicateComposedTypeWrapperIfOneAlreadyExists() Assert.True(root.FindChildByName("Union", false) is CodeClass unionTypeWrapper && unionTypeWrapper.OriginalComposedType != null); Assert.True(root.FindChildByName("UnionWrapper", false) is null); } - }