diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a8002bbd..c6a3a5b982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fixed mantis for bitwise enums in Go. [#3936](https://github.com/microsoft/kiota/issues/3936) +- Keyword in enum names for go should not be escaped. [#2877](https://github.com/microsoft/kiota/issues/2877) ## [1.11.1] - 2024-02-05 diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 71e2df6164..c6b2a501f6 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -93,10 +93,11 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance generatedCode, new GoReservedNamesProvider(), x => $"{x}Escaped", - shouldReplaceCallback: x => x is not CodeProperty currentProp || + shouldReplaceCallback: x => (x is not CodeEnumOption && x is not CodeEnum) && // enums and enum options start with uppercase + (x is not CodeProperty currentProp || !(currentProp.Parent is CodeClass parentClass && parentClass.IsOfKind(CodeClassKind.QueryParameters, CodeClassKind.ParameterSet) && - currentProp.Access == AccessModifier.Public)); // Go reserved keywords are all lowercase and public properties are uppercased when we don't provide accessors (models) + currentProp.Access == AccessModifier.Public))); // Go reserved keywords are all lowercase and public properties are uppercased when we don't provide accessors (models) ReplaceReservedExceptionPropertyNames(generatedCode, new GoExceptionsReservedNamesProvider(), x => $"{x}Escaped"); cancellationToken.ThrowIfCancellationRequested(); AddPropertiesAndMethodTypesImports( diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index f5d0297b00..49c0e45252 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -48,7 +48,9 @@ public async Task AddsInnerClasses() await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Go }, root); Assert.Equal(2, requestBuilder.GetChildElements(true).Count()); } - [Theory(Skip = "Fixing this test is a breaking change - https://github.com/microsoft/kiota/issues/2877")] + + + [Theory] [InlineData("break")] [InlineData("case")] public async Task EnumWithReservedName_IsNotRenamed(string input)