Skip to content

Commit

Permalink
Add .net framework 4.8 support (OpenAPITools#13504)
Browse files Browse the repository at this point in the history
* add .net framework 4.8 support

* add dependency, test in appveyor

* update doc
  • Loading branch information
wing328 authored Sep 26, 2022
1 parent ac7ebf6 commit d46189b
Show file tree
Hide file tree
Showing 288 changed files with 40,168 additions and 1 deletion.
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ build_script:
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClientCore\Org.OpenAPITools.sln
# build C# API client (.net framework 4.7)
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-net47\Org.OpenAPITools.sln
# build C# API client (.net framework 4.8)
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-net48\Org.OpenAPITools.sln
# build C# API client (.net 5.0)
- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-net5.0\Org.OpenAPITools.sln
# build C# API client (.net 5.0 with ConditionalSerialization)
Expand Down Expand Up @@ -84,6 +86,8 @@ test_script:
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.7)
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net framework 4.8)
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API client (.net 5.0)
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
# test C# API Client using conditional-serialization
Expand Down
11 changes: 11 additions & 0 deletions bin/configs/csharp-netcore-OpenAPIClient-net48.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# for .net standard
generatorName: csharp-netcore
outputDir: samples/client/petstore/csharp-netcore/OpenAPIClient-net48
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp-netcore
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
useOneOfDiscriminatorLookup: true
targetFramework: net48
2 changes: 1 addition & 1 deletion docs/generators/csharp-netcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|releaseNote|Release note, default to 'Minor update'.| |Minor update|
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|sourceFolder|source folder for generated code| |src|
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<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>**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><dt>**net6.0**</dt><dd>.NET 6.0 compatible</dd></dl>|netstandard2.0|
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<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>**netcoreapp3.1**</dt><dd>.NET Core 3.1 compatible</dd><dt>**net47**</dt><dd>.NET Framework 4.7 compatible</dd><dt>**net48**</dt><dd>.NET Framework 4.8 compatible</dd><dt>**net5.0**</dt><dd>.NET 5.0 compatible</dd><dt>**net6.0**</dt><dd>.NET 6.0 compatible</dd></dl>|netstandard2.0|
|useCollection|Deserialize array types to Collection&lt;T&gt; instead of List&lt;T&gt;.| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
FrameworkStrategy.NETSTANDARD_2_1,
FrameworkStrategy.NETCOREAPP_3_1,
FrameworkStrategy.NETFRAMEWORK_4_7,
FrameworkStrategy.NETFRAMEWORK_4_8,
FrameworkStrategy.NET_5_0,
FrameworkStrategy.NET_6_0
);
Expand Down Expand Up @@ -731,6 +732,7 @@ public void processOpts() {
if (!additionalProperties.containsKey(CodegenConstants.NULLABLE_REFERENCE_TYPES) && !strategies.stream().anyMatch(s ->
s.equals(FrameworkStrategy.NETCOREAPP_3_1) ||
s.equals(FrameworkStrategy.NET_5_0) ||
s.equals(FrameworkStrategy.NETFRAMEWORK_4_8) ||
s.equals(FrameworkStrategy.NETFRAMEWORK_4_7))) {
// starting in .net 6.0, NRT is enabled by default. If not specified, lets enable NRT to match the framework's default
setNullableReferenceTypes(true);
Expand Down Expand Up @@ -1241,6 +1243,8 @@ private static abstract class FrameworkStrategy {
};
static FrameworkStrategy NETFRAMEWORK_4_7 = new FrameworkStrategy("net47", ".NET Framework 4.7 compatible", "net47", Boolean.FALSE) {
};
static FrameworkStrategy NETFRAMEWORK_4_8 = new FrameworkStrategy("net48", ".NET Framework 4.8 compatible", "net48", Boolean.FALSE) {
};
static FrameworkStrategy NET_5_0 = new FrameworkStrategy("net5.0", ".NET 5.0 compatible", "net5.0", Boolean.FALSE) {
};
static FrameworkStrategy NET_6_0 = new FrameworkStrategy("net6.0", ".NET 6.0 compatible", "net6.0", Boolean.FALSE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@

<ItemGroup>
<None Remove="System.Web" />
{{#net48}}
<None Remove="System.Net.Http" />
{{/net48}}
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web" />
{{#net48}}
<Reference Include="System.Net.Http" />
{{/net48}}
</ItemGroup>
</Project>
Loading

0 comments on commit d46189b

Please sign in to comment.