From 2aa1e6b8b1a6a4545219098b0c4c41fbb32711e7 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 13 Nov 2024 06:53:29 -0500 Subject: [PATCH 1/3] fix: restores missing using for CLI generation Signed-off-by: Vincent Biret --- src/Kiota.Builder/Refiners/CliRefiner.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Kiota.Builder/Refiners/CliRefiner.cs b/src/Kiota.Builder/Refiners/CliRefiner.cs index d8fe315c45..aae91ea4f3 100644 --- a/src/Kiota.Builder/Refiners/CliRefiner.cs +++ b/src/Kiota.Builder/Refiners/CliRefiner.cs @@ -404,15 +404,17 @@ private static CodeType CreateCommandType(CodeTypeBase.CodeTypeCollectionKind co } private static readonly AdditionalUsingEvaluator[] additionalUsingEvaluators = - { - new(x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + [ + new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "System.CommandLine", "Command", "RootCommand", "IConsole"), - new(x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "Microsoft.Kiota.Cli.Commons.IO", "IOutputFormatter", "IOutputFormatterFactory", "FormatterType", "PageLinkData", "IPagingService"), - new(x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "System.Text", "Encoding"), - new(x => x is CodeMethod { Kind: CodeMethodKind.RequestExecutor or CodeMethodKind.RequestGenerator }, - "Microsoft.Kiota.Cli.Commons.Extensions", "GetRequestAdapter") - }; + new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + "System.Linq", "Enumerable"), + new (static x => x is CodeMethod { Kind: CodeMethodKind.RequestExecutor or CodeMethodKind.RequestGenerator }, + "Microsoft.Kiota.Cli.Commons.Extensions", "GetRequestAdapter"), + ]; } From 2e362f6ad6cce4ec8088418270d53ee45fb34f88 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 13 Nov 2024 06:53:49 -0500 Subject: [PATCH 2/3] fix: switches to non-obsolete method in CLI generation Signed-off-by: Vincent Biret --- src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs b/src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs index da96ec88a5..5372d7a114 100644 --- a/src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs @@ -641,7 +641,7 @@ protected virtual void WriteCommandHandlerBody(CodeMethod codeElement, CodeClass if (requestBodyParamType?.TypeDefinition is CodeClass) { writer.WriteLine($"using var stream = new MemoryStream(Encoding.UTF8.GetBytes({requestBodyParam.Name}));"); - writer.WriteLine($"var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode(\"{generatorMethod.RequestBodyContentType.SanitizeDoubleQuote()}\", stream);"); + writer.WriteLine($"var parseNode = await ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNodeAsync(\"{generatorMethod.RequestBodyContentType.SanitizeDoubleQuote()}\", stream, {CancellationTokenParamName});"); var typeString = conventions.GetTypeString(requestBodyParamType, requestBodyParam, false); From 3ac7ab43323e6184f7b1b3cd5297efe37924099a Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 13 Nov 2024 07:47:07 -0500 Subject: [PATCH 3/3] chore: formatting --- src/Kiota.Builder/Refiners/CliRefiner.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Kiota.Builder/Refiners/CliRefiner.cs b/src/Kiota.Builder/Refiners/CliRefiner.cs index aae91ea4f3..8db2891caa 100644 --- a/src/Kiota.Builder/Refiners/CliRefiner.cs +++ b/src/Kiota.Builder/Refiners/CliRefiner.cs @@ -405,16 +405,16 @@ private static CodeType CreateCommandType(CodeTypeBase.CodeTypeCollectionKind co private static readonly AdditionalUsingEvaluator[] additionalUsingEvaluators = [ - new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + new(static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "System.CommandLine", "Command", "RootCommand", "IConsole"), - new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + new(static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "Microsoft.Kiota.Cli.Commons.IO", "IOutputFormatter", "IOutputFormatterFactory", "FormatterType", "PageLinkData", "IPagingService"), - new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + new(static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "System.Text", "Encoding"), - new (static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, + new(static x => x is CodeClass { Kind: CodeClassKind.RequestBuilder }, "System.Linq", "Enumerable"), - new (static x => x is CodeMethod { Kind: CodeMethodKind.RequestExecutor or CodeMethodKind.RequestGenerator }, + new(static x => x is CodeMethod { Kind: CodeMethodKind.RequestExecutor or CodeMethodKind.RequestGenerator }, "Microsoft.Kiota.Cli.Commons.Extensions", "GetRequestAdapter"), ]; }