From 018a6ac47f078981b1a0e136606f35e4b73a0fdb Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Tue, 31 Jan 2023 18:04:46 +0000 Subject: [PATCH] Don't prefix with an underscore Java fields --- CHANGELOG.md | 19 ++++++++--------- src/Kiota.Builder/Refiners/JavaRefiner.cs | 3 ++- .../Refiners/JavaLanguageRefinerTests.cs | 21 +++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e67fbc3d91..0131f57e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Fixed a bug where most of the Java fields have been prefixed with an underscore. - Using fully qualified identifier for java.util.function.Consumer to avoid conflicts in Java. - Removed response handler parameter from PHP request executor methods. [1856](https://github.com/microsoft/kiota/issues/1856) - Fixed minor typo in adding Accept header for PHP. @@ -220,7 +221,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for range (2XX) responses. [#1699](https://github.com/microsoft/kiota/issues/1699) - Added none output formatter to CLI commons. (Shell) -- Added 'Accept' field of http request header in Ruby. [#1660](https://github.com/microsoft/kiota/issues/1660) +- Added 'Accept' field of http request header in Ruby. [#1660](https://github.com/microsoft/kiota/issues/1660) - Added support for text serialization in Python. [#1406](https://github.com/microsoft/kiota/issues/1406) - Added support for composed types (union, intersection) in CSharp, Java and Go. [#1411](https://github.com/microsoft/kiota/issues/1411) - Added support for implicit discriminator mapping. @@ -229,9 +230,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fixed a bug where Go clients would panic in case of nil response value. -- Fixed a bug to properly add request headers to Nethttp requests in Ruby. +- Fixed a bug to properly add request headers to Nethttp requests in Ruby. - Fixed a bug to properly reject invalid URLs in Ruby. -- Fixed an issue with require statements being generated instead of require relative in Ruby. +- Fixed an issue with require statements being generated instead of require relative in Ruby. - Updated AdditionDataHolder with the correct namespace. (Ruby) - Removed/fixed passing in the current instance to fields deserializers in Ruby. [#1663](https://github.com/microsoft/kiota/issues/1663) - Fix issue with duplicate variable declaration in command handlers (Shell) @@ -283,7 +284,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Defined the Access Token Provider Interface for Ruby authentication. [#1638](https://github.com/microsoft/kiota/issues/1638) - Reduce code verbosity on Go Getters and Setters. [G0#26][https://github.com/microsoftgraph/msgraph-sdk-go-core/issues/26] - ## [0.3.0] - 2022-07-08 ### Added @@ -539,12 +539,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a bug in Go generator where temporary url template parameters would not be used preventing the use of raw urls. - Fixed a bug where the Go http client configuration would impact non-kiota requests. -- Fixed bug where installing python abstractions failed due to missing dependencies #1289 -- Modified python test matrix to include python 3.10 #1289 -- Added return statement to AnonymousAuthenticationProvider in python abstractions #1289 -- Fixed bug in enabling backing store for parse node factory by passing ParseNodeFactoryRegistry to method call #1289 +- Fixed bug where installing python abstractions failed due to missing dependencies #1289 +- Modified python test matrix to include python 3.10 #1289 +- Added return statement to AnonymousAuthenticationProvider in python abstractions #1289 +- Fixed bug in enabling backing store for parse node factory by passing ParseNodeFactoryRegistry to method call #1289 - Fixed errors in python serialization due to to responses as json instead of json strings #1290 -- Added python version 3.10 to testing matrix #1290 +- Added python version 3.10 to testing matrix #1290 - Fixed bug with inconsistent Java namespace and directory name casing #1267 - Fixed typeOf string check in JsonParseNode Typescript. - Fixed shell stream output getting processed by output formatters when no file path is provided #1291 @@ -565,7 +565,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adds PHP League Authentication Provider for PHP #1201 - Added Shell language support #738 - ### Changed - Fixed a bug where request body would get dropped by the compression handler in Go diff --git a/src/Kiota.Builder/Refiners/JavaRefiner.cs b/src/Kiota.Builder/Refiners/JavaRefiner.cs index 91cbc37d67..c171cf8390 100644 --- a/src/Kiota.Builder/Refiners/JavaRefiner.cs +++ b/src/Kiota.Builder/Refiners/JavaRefiner.cs @@ -39,7 +39,8 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance _configuration.UsesBackingStore, true, "get", - "set" + "set", + string.Empty ); ReplaceReservedNames(generatedCode, new JavaReservedNamesProvider(), x => $"{x}_escaped"); AddPropertiesAndMethodTypesImports(generatedCode, true, false, true); diff --git a/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs index 0879a8810c..85745112fa 100644 --- a/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs @@ -465,6 +465,27 @@ public async Task CorrectsCoreType() Assert.Contains(additionalDataHolderDefaultName[1..], model.StartBlock.Implements.Select(static x => x.Name).ToList()); } [Fact] + public async Task ProduceCorrectNames() + { + var model = root.AddClass(new CodeClass + { + Name = "model", + Kind = CodeClassKind.Model + }).First(); + var custom = new CodeProperty + { + Name = "custom", + Kind = CodePropertyKind.Custom, + Type = new CodeType + { + Name = "string", + } + }; + model.AddProperty(custom); + await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Java }, root); + Assert.True(string.IsNullOrEmpty(model.Properties.First(static x => "custom".Equals(x.Name))!.NamePrefix)); + } + [Fact] public async Task AddsMethodsOverloads() { var builder = root.AddClass(new CodeClass