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/appveyor.yml b/appveyor.yml
index c0d2424..7c0d106 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -186,7 +186,7 @@ deploy:
# NuGet
- provider: NuGet
api_key:
- secure: zP8NG9npOCKDveAxWgK3a2Nb95gE5tk08i5ksxQKJpzqg0WsbOsK6vfxUjsjmlM+
+ secure: oFnALyCb2Y/Ls9YXoDlQgsLiaHLIVoZmS9d3Ip/+HQy3Z/0AtNl46nfyhvS5CB99
on:
configuration: Release
APPVEYOR_REPO_TAG: true
diff --git a/src/ImmediateReflection/Delegates/DelegatesFactory.cs b/src/ImmediateReflection/Delegates/DelegatesFactory.cs
index 59d0718..9f2b011 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
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