Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/cli build #5769

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/Kiota.Builder/Refiners/CliRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
];
}
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading