Skip to content

Commit

Permalink
Merge branch 'hotfix/copy_ctor_net5'
Browse files Browse the repository at this point in the history
  • Loading branch information
KeRNeLith committed Sep 4, 2022
2 parents b6b274c + bf2afc1 commit 2a7af90
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ deploy:
# NuGet
- provider: NuGet
api_key:
secure: zP8NG9npOCKDveAxWgK3a2Nb95gE5tk08i5ksxQKJpzqg0WsbOsK6vfxUjsjmlM+
secure: oFnALyCb2Y/Ls9YXoDlQgsLiaHLIVoZmS9d3Ip/+HQy3Z/0AtNl46nfyhvS5CB99
on:
configuration: Release
APPVEYOR_REPO_TAG: true
Expand Down
17 changes: 16 additions & 1 deletion src/ImmediateReflection/Delegates/DelegatesFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions src/ImmediateReflection/ImmediateReflection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ See benchmarks here: https://kernelith.github.io/ImmediateReflection/documentati

<IsPackable>true</IsPackable>
<PackageId>ImmediateReflection</PackageId>
<PackageReleaseNotes>➟ Release 1.6.0
<PackageReleaseNotes>➟ 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).</PackageReleaseNotes>
- Fix wrong generated IL code for copy constructor under .NET5+ target.</PackageReleaseNotes>
<PackageTags>C# Reflection Fast Immediate Performance Delegate Dynamic</PackageTags>
</PropertyGroup>

Expand Down

0 comments on commit 2a7af90

Please sign in to comment.