From 1761ccce81de84c8f605bc3fa4104e2e557d267c Mon Sep 17 00:00:00 2001 From: Dominique Schuppli Date: Tue, 9 Dec 2025 16:49:11 +0100 Subject: [PATCH 1/2] Switch to C# language version 14 --- buildscripts/common.props | 2 +- .../DynamicProxy.Tests/CustomModifiersTestCase.cs | 8 ++++---- .../Generators/Emitters/SimpleAST/FieldReference.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/buildscripts/common.props b/buildscripts/common.props index b748dd3df0..81a3e26d1b 100644 --- a/buildscripts/common.props +++ b/buildscripts/common.props @@ -1,7 +1,7 @@ - 13.0 + 14.0 $(NoWarn);CS1591;CS3014;CS3003;CS3001;CS3021 $(NoWarn);CS0612;CS0618 git diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/CustomModifiersTestCase.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/CustomModifiersTestCase.cs index a432a3a753..20e3881f41 100644 --- a/src/Castle.Core.Tests/DynamicProxy.Tests/CustomModifiersTestCase.cs +++ b/src/Castle.Core.Tests/DynamicProxy.Tests/CustomModifiersTestCase.cs @@ -150,7 +150,7 @@ public void ReflectionReturnsCorrectModoptOnParamTypeForGeneratedType(string typ var modopts = this.generatedTypes[typeName].GetMethod("Foo").GetParameters()[0].GetOptionalCustomModifiers(); - CollectionAssert.AreEqual(expected: CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix].Reverse(), actual: modopts); + CollectionAssert.AreEqual(expected: Enumerable.Reverse(CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix]), actual: modopts); // ^ The emission of custom modifiers performed by DynamicProxy is currently geared towards // the CLR, which reports custom modifiers in reverse order. On Mono, before version 5.16, // Reflection would not report custom modifiers at all; this has now changed. But unlike the @@ -183,7 +183,7 @@ public void ReflectionReturnsCorrectModreqsOnParamTypeForGeneratedType(string ty var modreqs = this.generatedTypes[typeName].GetMethod("Foo").GetParameters()[0].GetRequiredCustomModifiers(); Assume.That(modreqs.Length > 0); // If this fails on mono/linux we have to revisit the commits and issues for IL method custom modifiers. https://github.com/castleproject/Core/issues/277 - CollectionAssert.AreEqual(expected: CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix].Reverse(), actual: modreqs); + CollectionAssert.AreEqual(expected: Enumerable.Reverse(CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix]), actual: modreqs); // ^ see comment about `.Reverse()` above. } @@ -205,7 +205,7 @@ public void ReflectionReturnsCorrectModoptOnReturnTypeForGeneratedType(string ty var modopts = this.generatedTypes[typeName].GetMethod("Foo").ReturnParameter.GetOptionalCustomModifiers(); Assume.That(modopts.Length > 0); // If this fails on mono/linux we have to revisit the commits and issues for IL method custom modifiers. https://github.com/castleproject/Core/issues/277 - CollectionAssert.AreEqual(expected: CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix].Reverse(), actual: modopts); + CollectionAssert.AreEqual(expected: Enumerable.Reverse(CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix]), actual: modopts); // ^ see comment about `.Reverse()` above. } @@ -227,7 +227,7 @@ public void ReflectionReturnsCorrectModreqOnReturnTypeForGeneratedType(string ty var modreqs = this.generatedTypes[typeName].GetMethod("Foo").ReturnParameter.GetRequiredCustomModifiers(); Assume.That(modreqs.Length > 0); // If this fails on mono/linux we have to revisit the commits and issues for IL method custom modifiers. https://github.com/castleproject/Core/issues/277 - CollectionAssert.AreEqual(expected: CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix].Reverse(), actual: modreqs); + CollectionAssert.AreEqual(expected: Enumerable.Reverse(CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix]), actual: modreqs); // ^ see comment about `.Reverse()` above. } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FieldReference.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FieldReference.cs index 837a02bdfc..ebd0112df1 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FieldReference.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FieldReference.cs @@ -53,7 +53,7 @@ public FieldBuilder FieldBuilder public FieldInfo Reference { - get { return field; } + get { return @field; } } public override void LoadAddressOfReference(ILGenerator gen) From 4f624b018e77eed10a4b3cfc9920a658ed50f5a1 Mon Sep 17 00:00:00 2001 From: Dominique Schuppli Date: Tue, 9 Dec 2025 18:07:58 +0100 Subject: [PATCH 2/2] CI: C# language version 14 requires .NET 10 SDK Notes regarding GitHub Actions: * Builds would work even without adding `10.0.x` because the `windows- latest` runner image currently comes with .NET 10 SDK pre-installed. Still good to list it explicitly in case that changes in the future. Notes regarding AppVeyor: * Not installing via `apt-get install dotnet-sdk-10.0` because that would lead to older runtimes being uninstalled. * Installing to `/usr/local/dotnet` SDK as it would not get detected in `~/.dotnet`. --- .github/workflows/build.yml | 1 + appveyor.yml | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f11dbaa6a..ef401c0e00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,7 @@ jobs: dotnet-version: | 8.0.x 9.0.x + 10.0.x # ----- # Build diff --git a/appveyor.yml b/appveyor.yml index b34b33082b..867a666387 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,6 +18,12 @@ for: only: - image: Ubuntu2204 + # install .NET 10 SDK + install: + - curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh + - chmod +x ./dotnet-install.sh + - sudo ./dotnet-install.sh --channel 10.0 --install-dir /usr/share/dotnet + # build and run tests build_script: - uname -a @@ -46,6 +52,10 @@ for: Update-AppveyorBuild -Version ($env:APPVEYOR_REPO_TAG_NAME).TrimStart("v") } + # install .NET 10 SDK + install: + - cmd: choco install dotnet-10.0-sdk + # build and run tests build_script: - cmd: build.cmd