Skip to content

Commit 62eecab

Browse files
authored
[csharp-netcore] add .Net 5.0 support (#8467)
* add net5.0 support to csharp-netcore client gen * update doc * update samples
1 parent 8b2ac7b commit 62eecab

58 files changed

Lines changed: 11010 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ build_script:
4646
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClientCore\Org.OpenAPITools.sln
4747
# build C# API client (.net framework 4.7)
4848
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-net47\Org.OpenAPITools.sln
49+
# build C# API client (.net 5.0)
50+
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-net5.0\Org.OpenAPITools.sln
4951
# build C# API client
5052
- nuget restore samples\client\petstore\csharp\OpenAPIClient\Org.OpenAPITools.sln
5153
- msbuild samples\client\petstore\csharp\OpenAPIClient\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
@@ -65,6 +67,8 @@ test_script:
6567
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
6668
# test C# API client (.net framework 4.7)
6769
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
70+
# test C# API client (.net 5.0)
71+
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
6872
# test c# API client
6973
- nunit3-console samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
7074
# test c# API client (with PropertyChanged)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# for .net standard
2+
generatorName: csharp-netcore
3+
outputDir: samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0
4+
# TODO switch to http signature spec after fixing compilation issues
5+
#inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
6+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
7+
templateDir: modules/openapi-generator/src/main/resources/csharp-netcore
8+
additionalProperties:
9+
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
10+
useCompareNetObjects: true
11+
disallowAdditionalPropertiesIfNotPresent: false
12+
useOneOfDiscriminatorLookup: true
13+
targetFramework: net5.0

docs/generators/csharp-netcore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2828
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
2929
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
3030
|sourceFolder|source folder for generated code| |src|
31-
|targetFramework|The target .NET framework version.|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4 compatible</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5 compatible</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6 compatible</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0 compatible</dd><dt>**netstandard2.1**</dt><dd>.NET Standard 2.1 compatible</dd><dt>**netcoreapp2.0**</dt><dd>.NET Core 2.0 compatible</dd><dt>**netcoreapp2.1**</dt><dd>.NET Core 2.1 compatible</dd><dt>**netcoreapp3.0**</dt><dd>.NET Core 3.0 compatible</dd><dt>**netcoreapp3.1**</dt><dd>.NET Core 3.1 compatible</dd><dt>**net47**</dt><dd>.NET Framework 4.7 compatible</dd></dl>|netstandard2.0|
31+
|targetFramework|The target .NET framework version.|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4 compatible</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5 compatible</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6 compatible</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0 compatible</dd><dt>**netstandard2.1**</dt><dd>.NET Standard 2.1 compatible</dd><dt>**netcoreapp2.0**</dt><dd>.NET Core 2.0 compatible</dd><dt>**netcoreapp2.1**</dt><dd>.NET Core 2.1 compatible</dd><dt>**netcoreapp3.0**</dt><dd>.NET Core 3.0 compatible</dd><dt>**netcoreapp3.1**</dt><dd>.NET Core 3.1 compatible</dd><dt>**net47**</dt><dd>.NET Framework 4.7 compatible</dd><dt>**net5.0**</dt><dd>.NET 5.0 compatible</dd></dl>|netstandard2.0|
3232
|useCollection|Deserialize array types to Collection&lt;T&gt; instead of List&lt;T&gt;.| |false|
3333
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
3434
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.| |false|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
6363
FrameworkStrategy.NETCOREAPP_2_1,
6464
FrameworkStrategy.NETCOREAPP_3_0,
6565
FrameworkStrategy.NETCOREAPP_3_1,
66-
FrameworkStrategy.NETFRAMEWORK_4_7
66+
FrameworkStrategy.NETFRAMEWORK_4_7,
67+
FrameworkStrategy.NET_5_0
6768
);
6869
private static FrameworkStrategy defaultFramework = FrameworkStrategy.NETSTANDARD_2_0;
6970
protected final Map<String, String> frameworks;
@@ -908,6 +909,8 @@ private static abstract class FrameworkStrategy {
908909
};
909910
static FrameworkStrategy NETFRAMEWORK_4_7 = new FrameworkStrategy("net47", ".NET Framework 4.7 compatible", "net47", Boolean.FALSE) {
910911
};
912+
static FrameworkStrategy NET_5_0 = new FrameworkStrategy("net5.0", ".NET 5.0 compatible", "net5.0", Boolean.FALSE) {
913+
};
911914
protected String name;
912915
protected String description;
913916
protected String testTargetFramework;

0 commit comments

Comments
 (0)