From 028718f5adb109876a6c5488fb649ab5d5fff296 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 27 Sep 2024 10:33:27 +0000
Subject: [PATCH 1/7] Update dependency Refitter.Core to 1.3.2
---
src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj b/src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
index 5872a4165c..893868c270 100644
--- a/src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
+++ b/src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
@@ -21,7 +21,7 @@
-
+
From dcdfafc1b12b2df8322581f9a0ae5b980842b1db Mon Sep 17 00:00:00 2001
From: Christian Helle
Date: Mon, 30 Sep 2024 09:39:34 +0200
Subject: [PATCH 2/7] Add GenerateMultipleFiles property to refitter options
Introduce a new property `GenerateMultipleFiles` across several
classes and interfaces to support the generation of multiple files.
This property is added to the `DefaultRefitterOptions` class, the
`IRefitterOptions` interface, and the `RefitterOptions` class.
Additionally, the `RefitterOptionsPage` class is updated to include
this property with appropriate metadata for display and description
in the UI.
---
.../Options/Refitter/DefaultRefitterOptions.cs | 1 +
.../Options/Refitter/IRefitterOptions.cs | 1 +
.../Options/Refitter/RefitterOptions.cs | 2 ++
.../Options/Refitter/RefitterOptionsPage.cs | 5 +++++
4 files changed, 9 insertions(+)
diff --git a/src/Core/ApiClientCodeGen.Core/Options/Refitter/DefaultRefitterOptions.cs b/src/Core/ApiClientCodeGen.Core/Options/Refitter/DefaultRefitterOptions.cs
index 5248b2e618..86ffa39935 100644
--- a/src/Core/ApiClientCodeGen.Core/Options/Refitter/DefaultRefitterOptions.cs
+++ b/src/Core/ApiClientCodeGen.Core/Options/Refitter/DefaultRefitterOptions.cs
@@ -12,4 +12,5 @@ public class DefaultRefitterOptions : IRefitterOptions
public bool GenerateInternalTypes { get; set; }
public bool UseCancellationTokens { get; set; }
public bool GenerateHeaderParameters { get; set; } = true;
+ public bool GenerateMultipleFiles { get; set; }
}
\ No newline at end of file
diff --git a/src/Core/ApiClientCodeGen.Core/Options/Refitter/IRefitterOptions.cs b/src/Core/ApiClientCodeGen.Core/Options/Refitter/IRefitterOptions.cs
index 4166324f90..f89104f811 100644
--- a/src/Core/ApiClientCodeGen.Core/Options/Refitter/IRefitterOptions.cs
+++ b/src/Core/ApiClientCodeGen.Core/Options/Refitter/IRefitterOptions.cs
@@ -9,5 +9,6 @@ public interface IRefitterOptions
bool GenerateInternalTypes { get; set; }
bool UseCancellationTokens { get; set; }
bool GenerateHeaderParameters { get; set; }
+ bool GenerateMultipleFiles { get; set; }
}
}
\ No newline at end of file
diff --git a/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptions.cs b/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptions.cs
index 77d29c1249..a5f2e7f481 100644
--- a/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptions.cs
+++ b/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptions.cs
@@ -22,6 +22,7 @@ public RefitterOptions(IRefitterOptions? options = null)
GenerateInternalTypes = options.GenerateInternalTypes;
UseCancellationTokens = options.UseCancellationTokens;
GenerateHeaderParameters = options.GenerateHeaderParameters;
+ GenerateMultipleFiles = options.GenerateMultipleFiles;
}
catch (Exception e)
{
@@ -40,5 +41,6 @@ public RefitterOptions(IRefitterOptions? options = null)
public bool GenerateInternalTypes { get; set; }
public bool UseCancellationTokens { get; set; }
public bool GenerateHeaderParameters { get; set; }
+ public bool GenerateMultipleFiles { get; set; }
}
}
\ No newline at end of file
diff --git a/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptionsPage.cs b/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptionsPage.cs
index 638321c531..82abc6cbd2 100644
--- a/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptionsPage.cs
+++ b/src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/Refitter/RefitterOptionsPage.cs
@@ -46,5 +46,10 @@ public class RefitterOptionsPage : DialogPage, IRefitterOptions
[DisplayName("Generate Header Parameters")]
[Description("Set this to TRUE to generate [Header] parameters (default: TRUE)")]
public bool GenerateHeaderParameters { get; set; } = true;
+
+ [Category(Name)]
+ [DisplayName("Generate Multiple Files")]
+ [Description("Set this to TRUE to generate multiple files (default: FALSE)")]
+ public bool GenerateMultipleFiles { get; set; }
}
}
\ No newline at end of file
From 962afb4945ffb1b0b1082c1f8b684d118a542118 Mon Sep 17 00:00:00 2001
From: Christian Helle
Date: Mon, 30 Sep 2024 12:42:03 +0200
Subject: [PATCH 3/7] Update Refitter version to 1.3.2 in VSIX and VSMac
projects
---
src/VSIX/ApiClientCodeGen.VSIX.Dev17/VSCommandTable.vsct | 4 ++--
src/VSIX/ApiClientCodeGen.VSIX/VSCommandTable.vsct | 4 ++--
.../ApiClientCodeGen.VSMac/Properties/Manifest.addin.xml | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/VSIX/ApiClientCodeGen.VSIX.Dev17/VSCommandTable.vsct b/src/VSIX/ApiClientCodeGen.VSIX.Dev17/VSCommandTable.vsct
index 1a8deacafb..df130ac6f0 100644
--- a/src/VSIX/ApiClientCodeGen.VSIX.Dev17/VSCommandTable.vsct
+++ b/src/VSIX/ApiClientCodeGen.VSIX.Dev17/VSCommandTable.vsct
@@ -59,7 +59,7 @@
@@ -119,7 +119,7 @@
diff --git a/src/VSIX/ApiClientCodeGen.VSIX/VSCommandTable.vsct b/src/VSIX/ApiClientCodeGen.VSIX/VSCommandTable.vsct
index 1a8deacafb..df130ac6f0 100644
--- a/src/VSIX/ApiClientCodeGen.VSIX/VSCommandTable.vsct
+++ b/src/VSIX/ApiClientCodeGen.VSIX/VSCommandTable.vsct
@@ -59,7 +59,7 @@
@@ -119,7 +119,7 @@
diff --git a/src/VSMac/ApiClientCodeGen.VSMac/Properties/Manifest.addin.xml b/src/VSMac/ApiClientCodeGen.VSMac/Properties/Manifest.addin.xml
index 59c36681fe..664febec4f 100644
--- a/src/VSMac/ApiClientCodeGen.VSMac/Properties/Manifest.addin.xml
+++ b/src/VSMac/ApiClientCodeGen.VSMac/Properties/Manifest.addin.xml
@@ -43,7 +43,7 @@
defaultHandler="ApiClientCodeGen.VSMac.Commands.Handlers.AddNewKiotaCommandHandler" />
Date: Mon, 30 Sep 2024 12:42:14 +0200
Subject: [PATCH 4/7] Update Refitter version to 1.3.2 in CLI Tool
---
src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs b/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs
index 843e32127e..b38a4b0c9d 100644
--- a/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs
+++ b/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs
@@ -6,7 +6,7 @@
namespace Rapicgen.CLI.Commands.CSharp;
-[Command("refitter", Description = "Refitter (v1.3.0)")]
+[Command("refitter", Description = "Refitter (v1.3.2)")]
public class RefitterCommand : CodeGeneratorCommand
{
private readonly IRefitterCodeGeneratorFactory factory;
From c6995b1b34e80525bffb9c490989f110379acc9c Mon Sep 17 00:00:00 2001
From: Christian Helle
Date: Mon, 30 Sep 2024 12:42:21 +0200
Subject: [PATCH 5/7] Update RefitterCodeGenerator.cs to generate multiple
files and update Refitter version to 1.3.2
---
.../Generators/Refitter/RefitterCodeGenerator.cs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs b/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs
index 273705fae7..21d30f2c9f 100644
--- a/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs
+++ b/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs
@@ -60,7 +60,8 @@ public string GenerateCode(IProgressReporter? pGenerateProgress)
GenerateXmlDocCodeComments = options.GenerateXmlDocCodeComments,
ReturnIApiResponse = options.ReturnIApiResponse,
UseCancellationTokens = options.UseCancellationTokens,
- GenerateOperationHeaders = options.GenerateHeaderParameters
+ GenerateOperationHeaders = options.GenerateHeaderParameters,
+ GenerateMultipleFiles = options.GenerateMultipleFiles
};
File.WriteAllText(
@@ -89,7 +90,7 @@ public string GenerateCode(IProgressReporter? pGenerateProgress)
var output = GeneratedCode.PrefixAutogeneratedCodeHeader(
code,
"Refitter",
- "v1.3.0");
+ "v1.3.2");
if (inputFile.EndsWith(".refitter"))
{
From e3fd619e3088e082d3ec743f3f7af9ad31559e3a Mon Sep 17 00:00:00 2001
From: Christian Helle
Date: Mon, 30 Sep 2024 16:50:10 +0200
Subject: [PATCH 6/7] Update Refitter to v1.3.2 in docs
---
README.md | 4 ++--
docs/CLI.md | 2 +-
docs/Marketplace.md | 2 +-
docs/Marketplace2022.md | 2 +-
docs/VisualStudioForMac.md | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 7063ee8fed..7c36d8f813 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ The output file is the result of merging all the files generated using the Swagg
- ***AutoRestCodeGenerator*** - Generates a single file C# REST API Client using **AutoRest v3.0.0-beta.20210504.2** for OpenAPI v3 and **AutoRest v2.0.4417** for OpenAPI v2. The resulting file is the equivalent of using the AutoRest CLI tool with:
`--csharp --input-file=[swagger file] --output-file=[output file] --namespace=[default namespace] --add-credentials`
-- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.0**.
+- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.2**.
The output file contains a Refit interface generated by [Refitter](https://github.com/christianhelle/refitter) and contracts generated using [NSwag.CodeGeneration.CSharp](https://github.com/RSuter/NSwag/wiki/CSharpClientGenerator) [nuget package](https://www.nuget.org/packages/NSwag.CodeGeneration.CSharp/)
### Dependencies
@@ -309,7 +309,7 @@ Commands:
kiota Microsoft Kiota (v1.18.0)
nswag NSwag (v14.1.0)
openapi OpenAPI Generator (v7.8.0)
- refitter Refitter (v1.3.0)
+ refitter Refitter (v1.3.2)
swagger Swagger Codegen CLI (v3.0.34)
Run 'csharp [command] -?|-h|--help' for more information about a command.
diff --git a/docs/CLI.md b/docs/CLI.md
index 7241e35d67..78464ebdbd 100644
--- a/docs/CLI.md
+++ b/docs/CLI.md
@@ -73,7 +73,7 @@ Commands:
kiota Microsoft Kiota (v1.18.0)
nswag NSwag (v14.1.0)
openapi OpenAPI Generator (v7.8.0)
- refitter Refitter (v1.3.0)
+ refitter Refitter (v1.3.2)
swagger Swagger Codegen CLI (v3.0.34)
Run 'csharp [command] -?|-h|--help' for more information about a command.
diff --git a/docs/Marketplace.md b/docs/Marketplace.md
index eeb4cfc86d..82ef606c4e 100644
--- a/docs/Marketplace.md
+++ b/docs/Marketplace.md
@@ -41,7 +41,7 @@ The output file is the result of merging all the files generated using the Swagg
- ***AutoRestCodeGenerator*** - Generates a single file C# REST API Client using **AutoRest v3.0.0-beta.20210504.2** for OpenAPI v3 and **AutoRest v2.0.4417** for OpenAPI v2. The resulting file is the equivalent of using the AutoRest CLI tool with:
`--csharp --input-file=[swagger file] --output-file=[output file] --namespace=[default namespace] --add-credentials`
-- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.0**.
+- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.2**.
The output file contains a Refit interface generated by [Refitter](https://github.com/christianhelle/refitter) and contracts generated using [NSwag.CodeGeneration.CSharp](https://github.com/RSuter/NSwag/wiki/CSharpClientGenerator) [nuget package](https://www.nuget.org/packages/NSwag.CodeGeneration.CSharp/)
### Dependencies
diff --git a/docs/Marketplace2022.md b/docs/Marketplace2022.md
index f18dd686bb..49195fa6f4 100644
--- a/docs/Marketplace2022.md
+++ b/docs/Marketplace2022.md
@@ -41,7 +41,7 @@ The output file is the result of merging all the files generated using the Swagg
- ***AutoRestCodeGenerator*** - Generates a single file C# REST API Client using **AutoRest v3.0.0-beta.20210504.2** for OpenAPI v3 and **AutoRest v2.0.4417** for OpenAPI v2. The resulting file is the equivalent of using the AutoRest CLI tool with:
`--csharp --input-file=[swagger file] --output-file=[output file] --namespace=[default namespace] --add-credentials`
-- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.0**.
+- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.2**.
The output file contains a Refit interface generated by [Refitter](https://github.com/christianhelle/refitter) and contracts generated using [NSwag.CodeGeneration.CSharp](https://github.com/RSuter/NSwag/wiki/CSharpClientGenerator) [nuget package](https://www.nuget.org/packages/NSwag.CodeGeneration.CSharp/)
### Dependencies
diff --git a/docs/VisualStudioForMac.md b/docs/VisualStudioForMac.md
index 9884393aa1..e89a32e47a 100644
--- a/docs/VisualStudioForMac.md
+++ b/docs/VisualStudioForMac.md
@@ -29,7 +29,7 @@ The output file is the result of merging all the files generated using the Swagg
The resulting file is the equivalent of using the AutoRest CLI tool with:+
`--csharp --input-file=[swagger file] --output-file=[output file] --namespace=[default namespace] --add-credentials`
-- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.0**.
+- ***RefitterCodeGenerator*** - Generates a single file C# REST API Client inteface for [Refit](https://github.com/reactiveui/refit) using [Refitter.Core](https://github.com/christianhelle/refitter) [nuget package](https://www.nuget.org/packages/Refitter.Core/) **v1.3.2**.
The output file contains a Refit interface generated by [Refitter](https://github.com/christianhelle/refitter) and contracts generated using [NSwag.CodeGeneration.CSharp](https://github.com/RSuter/NSwag/wiki/CSharpClientGenerator) [nuget package](https://www.nuget.org/packages/NSwag.CodeGeneration.CSharp/)
### Dependencies
From 0885ae0e2715d55393bfdccb839234cf8cb78e77 Mon Sep 17 00:00:00 2001
From: Christian Helle
Date: Mon, 30 Sep 2024 21:15:16 +0200
Subject: [PATCH 7/7] Implement Refitter multiple files output from CLI tool
---
.../Commands/CSharp/RefitterCommand.cs | 7 +++
.../Commands/CodeGeneratorCommand.cs | 6 ++
.../Refitter/RefitterCodeGenerator.cs | 57 +++++++++++++------
3 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs b/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs
index b38a4b0c9d..a7520a0958 100644
--- a/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs
+++ b/src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/RefitterCommand.cs
@@ -86,4 +86,11 @@ public bool NoOperationHeaders
get => !options.GenerateHeaderParameters;
set => options.GenerateHeaderParameters = !value;
}
+
+ [Option(ShortName = "mf", LongName = "multiple-files", Description = "Generate multiple files")]
+ public bool GenerateMultipleFiles
+ {
+ get => options.GenerateMultipleFiles;
+ set => options.GenerateMultipleFiles = value;
+ }
}
diff --git a/src/CLI/ApiClientCodeGen.CLI/Commands/CodeGeneratorCommand.cs b/src/CLI/ApiClientCodeGen.CLI/Commands/CodeGeneratorCommand.cs
index f3cb8f7f10..a36a667354 100644
--- a/src/CLI/ApiClientCodeGen.CLI/Commands/CodeGeneratorCommand.cs
+++ b/src/CLI/ApiClientCodeGen.CLI/Commands/CodeGeneratorCommand.cs
@@ -58,6 +58,12 @@ public int OnExecute()
var generator = CreateGenerator();
var code = generator.GenerateCode(progressReporter);
+ if (string.IsNullOrWhiteSpace(code))
+ {
+ console.WriteSignature();
+ return ResultCodes.Success;
+ }
+
File.WriteAllText(OutputFile, code);
var fileInfo = new FileInfo(OutputFile);
diff --git a/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs b/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs
index 21d30f2c9f..5888f95085 100644
--- a/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs
+++ b/src/Core/ApiClientCodeGen.Core/Generators/Refitter/RefitterCodeGenerator.cs
@@ -45,9 +45,9 @@ public string GenerateCode(IProgressReporter? pGenerateProgress)
var refitterFile = fileInfo.Name.Replace(fileInfo.Extension, ".refitter");
if (File.Exists(refitterFile))
{
- settings = Serializer
- .Deserialize(
- File.ReadAllText(refitterFile));
+ settings = Serializer.Deserialize(
+ File.ReadAllText(refitterFile)
+ );
}
else
{
@@ -83,16 +83,8 @@ public string GenerateCode(IProgressReporter? pGenerateProgress)
pGenerateProgress?.Progress(50);
using var context = new DependencyContext("Refitter", Serialize(settings));
- var code = generator.Generate();
- context.Succeeded();
- pGenerateProgress?.Progress(90);
- var output = GeneratedCode.PrefixAutogeneratedCodeHeader(
- code,
- "Refitter",
- "v1.3.2");
-
- if (inputFile.EndsWith(".refitter"))
+ if (settings.GenerateMultipleFiles)
{
var fileInfo = new FileInfo(inputFile);
var outputFolder = fileInfo.Directory.FullName;
@@ -105,14 +97,43 @@ public string GenerateCode(IProgressReporter? pGenerateProgress)
}
}
- File.WriteAllText(
- Path.Combine(
- outputFolder,
- fileInfo.Name.Replace(fileInfo.Extension, ".cs")),
- output);
+ var results = generator.GenerateMultipleFiles();
+ foreach (var file in results.Files)
+ {
+ File.WriteAllText(Path.Combine(outputFolder, file.Filename), file.Content);
+ }
+
+ return string.Empty;
}
+ else
+ {
+ var code = generator.Generate();
+ context.Succeeded();
+
+ pGenerateProgress?.Progress(90);
+ var output = GeneratedCode.PrefixAutogeneratedCodeHeader(code, "Refitter", "v1.3.2");
- return output;
+ if (inputFile.EndsWith(".refitter"))
+ {
+ var fileInfo = new FileInfo(inputFile);
+ var outputFolder = fileInfo.Directory.FullName;
+ if (settings.OutputFolder != RefitGeneratorSettings.DefaultOutputFolder)
+ {
+ outputFolder = Path.Combine(outputFolder, settings.OutputFolder);
+ if (!Directory.Exists(outputFolder))
+ {
+ Directory.CreateDirectory(outputFolder);
+ }
+ }
+
+ File.WriteAllText(
+ Path.Combine(outputFolder, fileInfo.Name.Replace(fileInfo.Extension, ".cs")),
+ output
+ );
+ }
+
+ return output;
+ }
}
private static string Serialize(RefitGeneratorSettings settings)