Skip to content

Commit 2a7af90

Browse files
committed
Merge branch 'hotfix/copy_ctor_net5'
2 parents b6b274c + bf2afc1 commit 2a7af90

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

RELEASE_NOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release notes
22

3+
## What's new in 1.6.1 September 4 2022
4+
### Fixes:
5+
* Fix wrong generated IL code for copy constructor under .NET5+ target.
6+
37
## What's new in 1.6.0 August 31 2020
48
### Fixes:
59
* ImmediateType properly handle type having redefined properties with a type different from initial type.

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ deploy:
186186
# NuGet
187187
- provider: NuGet
188188
api_key:
189-
secure: zP8NG9npOCKDveAxWgK3a2Nb95gE5tk08i5ksxQKJpzqg0WsbOsK6vfxUjsjmlM+
189+
secure: oFnALyCb2Y/Ls9YXoDlQgsLiaHLIVoZmS9d3Ip/+HQy3Z/0AtNl46nfyhvS5CB99
190190
on:
191191
configuration: Release
192192
APPVEYOR_REPO_TAG: true

src/ImmediateReflection/Delegates/DelegatesFactory.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ private static bool TryGetParamsConstructorAsDefault(
146146
typeof(object).GetMethod(nameof(GetType))
147147
?? throw new InvalidOperationException($"{nameof(GetType)} not found.");
148148

149+
[NotNull]
150+
private static readonly MethodInfo TypeEqualsMethod =
151+
typeof(Type).GetMethod(
152+
"op_Equality",
153+
BindingFlags.Static | BindingFlags.Public,
154+
null,
155+
new[] { typeof(Type), typeof(Type) },
156+
null) ?? throw new InvalidOperationException("Cannot find == operator method on Type.");
157+
158+
[NotNull]
159+
private static readonly MethodInfo GetTypeFromHandleMethod =
160+
typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle))
161+
?? throw new InvalidOperationException($"{nameof(Type.GetTypeFromHandle)} not found.");
162+
149163
[Pure]
150164
[NotNull]
151165
[ContractAnnotation("type:null => halt")]
@@ -205,7 +219,8 @@ void CheckParameterIsOfRightType()
205219
generator.Emit(OpCodes.Ldarg_0);
206220
CallMethod(generator, GetTypeMethod);
207221
generator.Emit(OpCodes.Ldtoken, type);
208-
generator.Emit(OpCodes.Ceq);
222+
CallMethod(generator, GetTypeFromHandleMethod);
223+
CallMethod(generator, TypeEqualsMethod);
209224
generator.Emit(OpCodes.Brtrue_S, paramIsValid);
210225

211226
// Throw Argument exception => wrong parameter type

src/ImmediateReflection/ImmediateReflection.csproj

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,9 @@ See benchmarks here: https://kernelith.github.io/ImmediateReflection/documentati
3131

3232
<IsPackable>true</IsPackable>
3333
<PackageId>ImmediateReflection</PackageId>
34-
<PackageReleaseNotes>➟ Release 1.6.0
34+
<PackageReleaseNotes>➟ Release 1.6.1
3535
Fixes:
36-
- ImmediateType properly handle type having redefined properties with a type different from initial type.
37-
38-
New:
39-
- Use signing key to strong name library assemby.
40-
41-
Misc:
42-
- JetBrains.Annotations are embedded in the assembly (internal).</PackageReleaseNotes>
36+
- Fix wrong generated IL code for copy constructor under .NET5+ target.</PackageReleaseNotes>
4337
<PackageTags>C# Reflection Fast Immediate Performance Delegate Dynamic</PackageTags>
4438
</PropertyGroup>
4539

0 commit comments

Comments
 (0)