diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index be1c767ee7..b7b984bb10 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -146,7 +146,8 @@ current.Parent is CodeClass parentClass && var refinedName = refineAccessorName(currentProperty.Name); if (!refinedName.Equals(currentProperty.Name, StringComparison.Ordinal) && - !parentClass.Properties.Any(property => !property.Name.Equals(property.Name, StringComparison.Ordinal) && refinedName.Equals(property.Name, StringComparison.Ordinal)))// ensure the refinement won't generate a duplicate + !parentClass.Properties.Any(property => !currentProperty.Name.Equals(property.Name, StringComparison.Ordinal) && + refinedName.Equals(property.Name, StringComparison.OrdinalIgnoreCase)))// ensure the refinement won't generate a duplicate { if (string.IsNullOrEmpty(currentProperty.SerializationName)) currentProperty.SerializationName = currentProperty.Name; diff --git a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs index 33099b3b28..6bb1989bea 100644 --- a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs @@ -122,7 +122,7 @@ public async Task InlineParentOnErrorClassesWhichAlreadyInherit() }; await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CSharp }, root); - Assert.Contains(model.Properties, x => x.Name.Equals("otherProp")); + Assert.Contains(model.Properties, x => x.Name.Equals("OtherProp")); Assert.Contains(model.Methods, x => x.Name.Equals("otherMethod")); Assert.Contains(model.Usings, x => x.Name.Equals("otherNs")); } @@ -230,10 +230,10 @@ public async Task DoesNotEscapesReservedKeywordsForClassOrPropertyKindEnhanced() // Assert Assert.Equal("fileObject1", reservedModel.Name);// classes/models will be renamed if reserved without conflicts Assert.Equal("fileObject", reservedObjectModel.Name);// original stays the same - Assert.Equal("alias", property.Name);// property names don't bring issue in dotnet - Assert.Equal("file", secondProperty.Name);// property names don't bring issue in dotnet + Assert.Equal("Alias", property.Name);// property names don't bring issue in dotnet + Assert.Equal("File", secondProperty.Name);// property names don't bring issue in dotnet Assert.Equal("fileObject1", secondProperty.Type.Name);// property type was renamed - Assert.Equal("fileObject", thirdProperty.Name);// property names don't bring issue in dotnet + Assert.Equal("FileObject", thirdProperty.Name);// property names don't bring issue in dotnet Assert.Equal("fileObject", thirdProperty.Type.Name);// property type was renamed } @@ -494,7 +494,7 @@ public async Task DisambiguatePropertiesWithClassNames() } }).First(); await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CSharp }, root); - Assert.Equal("modelProp", propToAdd.Name); + Assert.Equal("ModelProp", propToAdd.Name); Assert.Equal("model", propToAdd.SerializationName); } [Fact] @@ -530,7 +530,7 @@ public async Task AvoidsPropertyNameReplacementIfDuplicatedGenerated() } }).First(); await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CSharp }, root); - Assert.Equal("summary", firstProperty.Name);// remains as is. No refinement needed + Assert.Equal("Summary", firstProperty.Name);// remains as is. No refinement needed Assert.Equal("_summary", secondProperty.Name);// No refinement as it will create a duplicate with firstProperty Assert.Equal("Replaced", thirdProperty.Name);// Base case. Proper refinements }