From 831f47232badf97ea62d293899dce8b8adf59d56 Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 16 Jul 2024 02:47:23 -0400 Subject: [PATCH 1/5] Create token file using file name given as param --- .../csharp-api-parser/CSharpAPIParser/CSharpAPIParser.csproj | 2 +- .../parsers/csharp-api-parser/CSharpAPIParser/Program.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/CSharpAPIParser.csproj b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/CSharpAPIParser.csproj index 2fa0ca2222c..d4936c4de62 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/CSharpAPIParser.csproj +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/CSharpAPIParser.csproj @@ -4,7 +4,7 @@ Exe true CSharpAPIParserForAPIView - net7.0 + net8.0 CSharpAPIParser enable enable diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs index 5c4d9f58de6..b260c37c088 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs @@ -113,9 +113,9 @@ static async Task HandlePackageFileParsing(Stream stream, FileInfo packageFilePa return; } - var parsedFileName = string.IsNullOrEmpty(outputFileName) ? assemblySymbol.Name : outputFileName; + var parsedFileName = string.IsNullOrEmpty(outputFileName) ? $"{assemblySymbol.Name}.json.tgz" : Path.GetFileName(outputFileName); var treeTokenCodeFile = new CSharpAPIParser.TreeToken.CodeFileBuilder().Build(assemblySymbol, runAnalysis, dependencies); - var gzipJsonTokenFilePath = Path.Combine(OutputDirectory.FullName, $"{parsedFileName}.json.tgz"); + var gzipJsonTokenFilePath = Path.Combine(OutputDirectory.FullName, parsedFileName); var options = new JsonSerializerOptions() From 09ba1a0be56261cd8d1bf656457337c3fb9542fa Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 16 Jul 2024 04:27:38 -0400 Subject: [PATCH 2/5] Fix code file name --- .../parsers/csharp-api-parser/CSharpAPIParser/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs index b260c37c088..4d353678893 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs @@ -113,9 +113,9 @@ static async Task HandlePackageFileParsing(Stream stream, FileInfo packageFilePa return; } - var parsedFileName = string.IsNullOrEmpty(outputFileName) ? $"{assemblySymbol.Name}.json.tgz" : Path.GetFileName(outputFileName); + var parsedFileName = string.IsNullOrEmpty(outputFileName) ? assemblySymbol.Name : Path.GetFileName(outputFileName); var treeTokenCodeFile = new CSharpAPIParser.TreeToken.CodeFileBuilder().Build(assemblySymbol, runAnalysis, dependencies); - var gzipJsonTokenFilePath = Path.Combine(OutputDirectory.FullName, parsedFileName); + var gzipJsonTokenFilePath = Path.Combine(OutputDirectory.FullName, $"{parsedFileName}.json.tgz"); var options = new JsonSerializerOptions() From c5b40b23c0a7edcc7f6f31fad4140a415b7fdecf Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 16 Jul 2024 07:14:13 -0400 Subject: [PATCH 3/5] Add await --- .../csharp-api-parser/CSharpAPIParser/Program.cs | 10 ++++------ 1 file changed, 4 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 4d353678893..33b0518b411 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs @@ -113,7 +113,7 @@ static async Task HandlePackageFileParsing(Stream stream, FileInfo packageFilePa return; } - var parsedFileName = string.IsNullOrEmpty(outputFileName) ? assemblySymbol.Name : Path.GetFileName(outputFileName); + var parsedFileName = string.IsNullOrEmpty(outputFileName) ? assemblySymbol.Name : outputFileName; var treeTokenCodeFile = new CSharpAPIParser.TreeToken.CodeFileBuilder().Build(assemblySymbol, runAnalysis, dependencies); var gzipJsonTokenFilePath = Path.Combine(OutputDirectory.FullName, $"{parsedFileName}.json.tgz"); @@ -123,11 +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); + JsonSerializer.Serialize(new Utf8JsonWriter(gZipStream, new JsonWriterOptions { Indented = false }), treeTokenCodeFile, options); Console.WriteLine($"TokenCodeFile File {gzipJsonTokenFilePath} Generated Successfully."); Console.WriteLine(); From 0e36767d1fa593463c6729bb87b709aca048097f Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 16 Jul 2024 07:19:18 -0400 Subject: [PATCH 4/5] Add await --- .../parsers/csharp-api-parser/CSharpAPIParser/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs index 33b0518b411..a2250a14189 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs @@ -126,7 +126,7 @@ static async Task HandlePackageFileParsing(Stream stream, FileInfo packageFilePa await using FileStream gzipFileStream = new FileStream(gzipJsonTokenFilePath, FileMode.Create, FileAccess.Write); await using GZipStream gZipStream = new GZipStream(gzipFileStream, CompressionLevel.Optimal); JsonSerializer.Serialize(new Utf8JsonWriter(gZipStream, new JsonWriterOptions { Indented = false }), treeTokenCodeFile, options); - + await Task.Delay(1000); Console.WriteLine($"TokenCodeFile File {gzipJsonTokenFilePath} Generated Successfully."); Console.WriteLine(); } From 3aec3cb5c4fc44ab03df561ebf5186f02c7bba1d Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 16 Jul 2024 07:26:37 -0400 Subject: [PATCH 5/5] Add await and change to asynchronous serialization --- .../parsers/csharp-api-parser/CSharpAPIParser/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs index a2250a14189..7915231c8cd 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/Program.cs @@ -125,8 +125,7 @@ static async Task HandlePackageFileParsing(Stream stream, FileInfo packageFilePa await using FileStream gzipFileStream = new FileStream(gzipJsonTokenFilePath, FileMode.Create, FileAccess.Write); await using GZipStream gZipStream = new GZipStream(gzipFileStream, CompressionLevel.Optimal); - JsonSerializer.Serialize(new Utf8JsonWriter(gZipStream, new JsonWriterOptions { Indented = false }), treeTokenCodeFile, options); - await Task.Delay(1000); + await JsonSerializer.SerializeAsync(gZipStream, treeTokenCodeFile, options); Console.WriteLine($"TokenCodeFile File {gzipJsonTokenFilePath} Generated Successfully."); Console.WriteLine(); }