From 4eb8a63499a0f2affe8b6969db6b8e664d689ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Rab=C3=A9rin?= Date: Mon, 29 Aug 2022 10:58:41 +0200 Subject: [PATCH 1/3] Fix copy constructor delegate while using under .NET5+ target. --- .../Delegates/DelegatesFactory.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ImmediateReflection/Delegates/DelegatesFactory.cs b/src/ImmediateReflection/Delegates/DelegatesFactory.cs index a861756..2d62207 100644 --- a/src/ImmediateReflection/Delegates/DelegatesFactory.cs +++ b/src/ImmediateReflection/Delegates/DelegatesFactory.cs @@ -146,6 +146,20 @@ private static bool TryGetParamsConstructorAsDefault( typeof(object).GetMethod(nameof(GetType)) ?? throw new InvalidOperationException($"{nameof(GetType)} not found."); + [NotNull] + private static readonly MethodInfo TypeEqualsMethod = + typeof(Type).GetMethod( + "op_Equality", + BindingFlags.Static | BindingFlags.Public, + null, + new[] { typeof(Type), typeof(Type) }, + null) ?? throw new InvalidOperationException("Cannot find == operator method on Type."); + + [NotNull] + private static readonly MethodInfo GetTypeFromHandleMethod = + typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle)) + ?? throw new InvalidOperationException($"{nameof(Type.GetTypeFromHandle)} not found."); + [Pure] [NotNull] [ContractAnnotation("type:null => halt")] @@ -205,7 +219,8 @@ void CheckParameterIsOfRightType() generator.Emit(OpCodes.Ldarg_0); CallMethod(generator, GetTypeMethod); generator.Emit(OpCodes.Ldtoken, type); - generator.Emit(OpCodes.Ceq); + CallMethod(generator, GetTypeFromHandleMethod); + CallMethod(generator, TypeEqualsMethod); generator.Emit(OpCodes.Brtrue_S, paramIsValid); // Throw Argument exception => wrong parameter type From c5e7de047365952a10dd4ea017a5a7eebaa95351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Rab=C3=A9rin?= Date: Sun, 4 Sep 2022 23:43:15 +0200 Subject: [PATCH 2/3] Write release notes. --- RELEASE_NOTES.md | 4 ++++ src/ImmediateReflection/ImmediateReflection.csproj | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 386b6eb..7ad6f9e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,9 @@ # Release notes +## What's new in 1.6.1 September 4 2022 +### Fixes: +* Fix wrong generated IL code for copy constructor under .NET5+ target. + ## What's new in 1.6.0 August 31 2020 ### Fixes: * ImmediateType properly handle type having redefined properties with a type different from initial type. diff --git a/src/ImmediateReflection/ImmediateReflection.csproj b/src/ImmediateReflection/ImmediateReflection.csproj index 23f1418..2bee1fc 100644 --- a/src/ImmediateReflection/ImmediateReflection.csproj +++ b/src/ImmediateReflection/ImmediateReflection.csproj @@ -31,15 +31,9 @@ See benchmarks here: https://kernelith.github.io/ImmediateReflection/documentati true ImmediateReflection - ➟ Release 1.6.0 + ➟ Release 1.6.1 Fixes: -- ImmediateType properly handle type having redefined properties with a type different from initial type. - -New: -- Use signing key to strong name library assemby. - -Misc: -- JetBrains.Annotations are embedded in the assembly (internal). +- Fix wrong generated IL code for copy constructor under .NET5+ target. C# Reflection Fast Immediate Performance Delegate Dynamic From bf2afc1a5517c3db65f7ed15c125fdb3b971aafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Rab=C3=A9rin?= Date: Mon, 25 Oct 2021 23:03:53 +0200 Subject: [PATCH 3/3] Update Nuget API key. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ccd3381..abd899e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -186,7 +186,7 @@ deploy: # NuGet - provider: NuGet api_key: - secure: QZmft3MtBUFBdw5iPCm/P2qvbSxuCoI18Rhzp619NMWGvAQbf5C3rX78ecu8qHcm + secure: oFnALyCb2Y/Ls9YXoDlQgsLiaHLIVoZmS9d3Ip/+HQy3Z/0AtNl46nfyhvS5CB99 on: configuration: Release APPVEYOR_REPO_TAG: true