From 03aaf19f98c3448f27d4fc652cbd2d94ec87e41a Mon Sep 17 00:00:00 2001 From: Praven Kuttappan <55455725+praveenkuttappan@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:54:10 -0400 Subject: [PATCH] Create token file using file name given as param (#8642) * Add await and change to asynchronous serialization --- .../parsers/csharp-api-parser/CSharpAPIParser/Program.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs index 5c4d9f58de6..7915231c8cd 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs @@ -123,12 +123,9 @@ static async Task HandlePackageFileParsing(Stream stream, FileInfo packageFilePa DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }; - { - using FileStream gzipFileStream = new FileStream(gzipJsonTokenFilePath, FileMode.Create, FileAccess.Write); - using GZipStream gZipStream = new GZipStream(gzipFileStream, CompressionLevel.Optimal); - JsonSerializer.Serialize(new Utf8JsonWriter(gZipStream, new JsonWriterOptions { Indented = false }), treeTokenCodeFile, options); - } - + await using FileStream gzipFileStream = new FileStream(gzipJsonTokenFilePath, FileMode.Create, FileAccess.Write); + await using GZipStream gZipStream = new GZipStream(gzipFileStream, CompressionLevel.Optimal); + await JsonSerializer.SerializeAsync(gZipStream, treeTokenCodeFile, options); Console.WriteLine($"TokenCodeFile File {gzipJsonTokenFilePath} Generated Successfully."); Console.WriteLine(); }