From e3bd9f7e4e93ab68365b1d067fa72ecc76897485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Mon, 6 Mar 2023 12:10:35 +0100 Subject: [PATCH] fix(dotnet): target netcoreapp3.1 with RollForward --- .../ComplianceTests.cs | 2 +- .../Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj | 3 ++- .../src/Amazon.JSII.Runtime/Services/TypeCache.cs | 2 +- packages/jsii-pacmak/lib/targets/dotnet.ts | 2 +- .../jsii-pacmak/lib/targets/dotnet/filegenerator.ts | 2 ++ .../__snapshots__/examples.test.js.snap | 6 ++++-- .../prerelease-identifiers.test.js.snap | 12 ++++++++---- .../__snapshots__/target-dotnet.test.js.snap | 12 ++++++++---- 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs index f3d7014761..2ef4cc956f 100644 --- a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs +++ b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs @@ -937,7 +937,7 @@ public void OptionalAndVariadicArgumentsTest() [Fact(DisplayName = Prefix + nameof(JsiiAgentIsCorrect))] public void JsiiAgentIsCorrect() { - Assert.Equal("DotNet/" + Environment.Version + "/.NETCoreApp,Version=v6.0/1.0.0.0", JsiiAgent.Value); + Assert.Equal("DotNet/" + Environment.Version + "/.NETCoreApp,Version=v3.1/1.0.0.0", JsiiAgent.Value); } [Fact(DisplayName = Prefix + nameof(ReceiveInstanceOfPrivateClass))] diff --git a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj index 0f3cc2845d..3267772fb4 100644 --- a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj +++ b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj @@ -2,7 +2,8 @@ - net6.0 + netcoreapp3.1 + Major Amazon.JSII.Runtime .NET Runtime for JSII icon.png diff --git a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Services/TypeCache.cs b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Services/TypeCache.cs index 987747c172..d04e5278e3 100644 --- a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Services/TypeCache.cs +++ b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Services/TypeCache.cs @@ -202,7 +202,7 @@ void CacheTypes(Assembly assembly) } } - return e.Types; + return e.Types ?? Array.Empty(); } } } diff --git a/packages/jsii-pacmak/lib/targets/dotnet.ts b/packages/jsii-pacmak/lib/targets/dotnet.ts index f9f6409c88..70727b8c9b 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet.ts @@ -18,7 +18,7 @@ import { toReleaseVersion } from './version-utils'; import { TargetName } from '.'; -export const TARGET_FRAMEWORK = 'net6.0'; +export const TARGET_FRAMEWORK = 'netcoreapp3.1'; /** * Build .NET packages all together, by generating an aggregate solution file diff --git a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts index c7332d93ea..c51fcb5b70 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts @@ -112,6 +112,8 @@ export class FileGenerator { propertyGroup.ele('Nullable', 'enable'); propertyGroup.ele('SymbolPackageFormat', 'snupkg'); propertyGroup.ele('TargetFramework', TARGET_FRAMEWORK); + // Transparently rolll forward across major SDK releases if needed + propertyGroup.ele('RollForward', 'Major'); const itemGroup1 = rootNode.ele('ItemGroup'); const embeddedResource = itemGroup1.ele('EmbeddedResource'); diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap index 0d133a3a7b..2daa7b47c7 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap @@ -88,7 +88,8 @@ exports[`diamond-struct-parameter.ts: /dotnet/Example.Test.Demo/Example. true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -1622,7 +1623,8 @@ exports[`nested-types.ts: /dotnet/Example.Test.Demo/Example.Test.Demo.cs true enable snupkg - net6.0 + netcoreapp3.1 + Major diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap index b4e941b6bc..7e5af6ef15 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap @@ -77,7 +77,8 @@ exports[`foo@1.2.3 depends on bar@^2.0.0-rc.42: /dotnet/Com.Acme.Foo/Com true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -586,7 +587,8 @@ exports[`foo@1.2.3 depends on bar@^4.5.6-pre.1337: /dotnet/Com.Acme.Foo/ true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -1095,7 +1097,8 @@ exports[`foo@2.0.0-rc.42: /dotnet/Com.Acme.Foo/Com.Acme.Foo.csproj 1`] = true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -1581,7 +1584,8 @@ exports[`foo@4.5.6-pre.1337: /dotnet/Com.Acme.Foo/Com.Acme.Foo.csproj 1` true enable snupkg - net6.0 + netcoreapp3.1 + Major diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap index a17723f325..68e20130d1 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap @@ -50,7 +50,8 @@ exports[`Generated code for "@scope/jsii-calc-base": /dotnet/Amazon.JSII true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -569,7 +570,8 @@ exports[`Generated code for "@scope/jsii-calc-base-of-base": /dotnet/Ama true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -1068,7 +1070,8 @@ exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII. true enable snupkg - net6.0 + netcoreapp3.1 + Major @@ -3331,7 +3334,8 @@ exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.Calcu true enable snupkg - net6.0 + netcoreapp3.1 + Major