diff --git a/CHANGELOG.md b/CHANGELOG.md index 250104a864..1242ca01e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replaces the use of "new" by "override" and "virtual" in CSharp models. - Fixed query parameters type mapping for arrays. [#3354](https://github.com/microsoft/kiota/issues/3354) - The lock file now contains the relative path to the description in case of local path. [#3151](https://github.com/microsoft/kiota/issues/3151) +- Fixes a bug where query parameters would be missing in CSharp for ebc clients. [#3583](https://github.com/microsoft/kiota/issues/3583) - Fixed bug where base64url and decimal types would not be generated properly in Java. - Fixed bug where symbol name cleanup would not work on forward single quotes characters [#3426](https://github.com/microsoft/kiota/issues/3426). - Fixed a bug where a "models" API path segment in the description would derail generation. [#3400](https://github.com/microsoft/kiota/issues/3400) diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 07edb94940..302b49b746 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -665,7 +665,7 @@ public async Task ApplyLanguageRefinement(GenerationConfiguration config, CodeNa public async Task CreateLanguageSourceFilesAsync(GenerationLanguage language, CodeNamespace generatedCode, CancellationToken cancellationToken) { - var languageWriter = LanguageWriter.GetLanguageWriter(language, config.OutputPath, config.ClientNamespaceName, config.UsesBackingStore); + var languageWriter = LanguageWriter.GetLanguageWriter(language, config.OutputPath, config.ClientNamespaceName, config.UsesBackingStore, config.ExcludeBackwardCompatible); var stopwatch = new Stopwatch(); stopwatch.Start(); var codeRenderer = CodeRenderer.GetCodeRender(config); diff --git a/src/Kiota.Builder/Writers/CSharp/CSharpWriter.cs b/src/Kiota.Builder/Writers/CSharp/CSharpWriter.cs index 287b4db588..69ffd206b8 100644 --- a/src/Kiota.Builder/Writers/CSharp/CSharpWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CSharpWriter.cs @@ -3,7 +3,7 @@ namespace Kiota.Builder.Writers.CSharp; public class CSharpWriter : LanguageWriter { - public CSharpWriter(string rootPath, string clientNamespaceName) + public CSharpWriter(string rootPath, string clientNamespaceName, bool excludeBackwardCompatible = false) { PathSegmenter = new CSharpPathSegmenter(rootPath, clientNamespaceName); var conventionService = new CSharpConventionService(); @@ -11,7 +11,7 @@ public CSharpWriter(string rootPath, string clientNamespaceName) AddOrReplaceCodeElementWriter(new CodeBlockEndWriter(conventionService)); AddOrReplaceCodeElementWriter(new CodeEnumWriter(conventionService)); AddOrReplaceCodeElementWriter(new CodeIndexerWriter(conventionService)); - AddOrReplaceCodeElementWriter(new CodeMethodWriter(conventionService)); + AddOrReplaceCodeElementWriter(new CodeMethodWriter(conventionService, excludeBackwardCompatible)); AddOrReplaceCodeElementWriter(new CodePropertyWriter(conventionService)); AddOrReplaceCodeElementWriter(new CodeTypeWriter(conventionService)); diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index 4cff2235f1..80fda84510 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -422,7 +422,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if (requestParams.requestConfiguration != null) { - writer.StartBlock($"if ({requestParams.requestConfiguration.Name} != null) {{"); + writer.StartBlock($"if ({requestParams.requestConfiguration.Name} != null) {{"); // TODO for v2, since we're moving to generics, this whole block can be moved to request information avoiding duplication var requestConfigType = conventions.GetTypeString(requestParams.requestConfiguration.Type, codeElement, false, true, false).ToFirstCharacterUpperCase(); writer.WriteLines($"var {RequestConfigVarName} = new {requestConfigType}();", $"{requestParams.requestConfiguration.Name}.Invoke({RequestConfigVarName});"); diff --git a/src/Kiota.Builder/Writers/LanguageWriter.cs b/src/Kiota.Builder/Writers/LanguageWriter.cs index aec67a15a0..91e661d6ad 100644 --- a/src/Kiota.Builder/Writers/LanguageWriter.cs +++ b/src/Kiota.Builder/Writers/LanguageWriter.cs @@ -170,11 +170,11 @@ protected void AddOrReplaceCodeElementWriter(ICodeElementWriter writer) wh Writers[typeof(T)] = writer; } private readonly Dictionary Writers = new(); // we have to type as object because dotnet doesn't have type capture i.e eq for `? extends CodeElement` - public static LanguageWriter GetLanguageWriter(GenerationLanguage language, string outputPath, string clientNamespaceName, bool usesBackingStore = false) + public static LanguageWriter GetLanguageWriter(GenerationLanguage language, string outputPath, string clientNamespaceName, bool usesBackingStore = false, bool excludeBackwardCompatible = false) { return language switch { - GenerationLanguage.CSharp => new CSharpWriter(outputPath, clientNamespaceName), + GenerationLanguage.CSharp => new CSharpWriter(outputPath, clientNamespaceName, excludeBackwardCompatible), GenerationLanguage.Java => new JavaWriter(outputPath, clientNamespaceName), GenerationLanguage.TypeScript => new TypeScriptWriter(outputPath, clientNamespaceName, usesBackingStore), GenerationLanguage.Ruby => new RubyWriter(outputPath, clientNamespaceName), diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs index 16945ceff1..d1325bb57b 100644 --- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs @@ -26,7 +26,7 @@ public class CodeMethodWriterTests : IDisposable private const string ParamName = "paramName"; public CodeMethodWriterTests() { - writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.CSharp, DefaultPath, DefaultName); + writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.CSharp, DefaultPath, DefaultName, excludeBackwardCompatible: true); tw = new StringWriter(); writer.SetTextWriter(tw); root = CodeNamespace.InitRootNamespace();