diff --git a/ExpressiveReflection/ConstructorReflection.cs b/ExpressiveReflection/ConstructorReflection.cs index 35084b2..ba86142 100644 --- a/ExpressiveReflection/ConstructorReflection.cs +++ b/ExpressiveReflection/ConstructorReflection.cs @@ -24,7 +24,7 @@ public ConstructorInfo Transmute(ConstructorInfo other, params Type[] newGeneric var type = other.DeclaringType.GetGenericTypeDefinition().MakeGenericType(newGenericArgs); - var transmuted = type.GetConstructors().Where(c => c.MetadataToken == other.MetadataToken).Single(); + var transmuted = type.GetConstructors().Where(c => c.MetadataToken == other.MetadataToken && c.Module == other.Module).Single(); return transmuted; } diff --git a/ExpressiveReflection/ExpressiveReflection.Sources.nuspec b/ExpressiveReflection/ExpressiveReflection.Sources.nuspec index a8f1a1e..05f1363 100644 Binary files a/ExpressiveReflection/ExpressiveReflection.Sources.nuspec and b/ExpressiveReflection/ExpressiveReflection.Sources.nuspec differ diff --git a/ExpressiveReflection/MemberReflection.cs b/ExpressiveReflection/MemberReflection.cs index 857a410..51d4079 100644 --- a/ExpressiveReflection/MemberReflection.cs +++ b/ExpressiveReflection/MemberReflection.cs @@ -27,7 +27,7 @@ public MemberInfo Transmute(MemberInfo target, params Type[] newGenericArgs) } var type = target.DeclaringType.GetGenericTypeDefinition().MakeGenericType(newGenericArgs); - var transmuted = type.GetMembers().Where(m => m.MetadataToken == target.MetadataToken).Single(); + var transmuted = type.GetMembers().Where(m => m.MetadataToken == target.MetadataToken && m.Module == target.Module).Single(); return transmuted; } diff --git a/ExpressiveReflection/MethodReflection.cs b/ExpressiveReflection/MethodReflection.cs index 9a4682c..85c61a3 100644 --- a/ExpressiveReflection/MethodReflection.cs +++ b/ExpressiveReflection/MethodReflection.cs @@ -36,7 +36,7 @@ public MethodInfo Transmute(MethodInfo target, Type[] typeArgsForType, Type[] ty newType = declaringType; } - var newMethod = newType.GetMethods().Where(m => m.MetadataToken == target.MetadataToken).Single(); + var newMethod = newType.GetMethods().Where(m => m.MetadataToken == target.MetadataToken && m.Module == target.Module).Single(); if (newMethod.IsGenericMethodDefinition) { newMethod = newMethod.MakeGenericMethod(typeArgsForMethod); diff --git a/ExpressiveReflection/Package.nuspec b/ExpressiveReflection/Package.nuspec index 1cb57c2..4fbf798 100644 --- a/ExpressiveReflection/Package.nuspec +++ b/ExpressiveReflection/Package.nuspec @@ -2,7 +2,7 @@ ExpressiveReflection - 1.3.2 + 1.3.3 hannasm hannasm https://github.com/hannasm/ExpressiveReflectionDotnet/blob/master/LICENSE @@ -10,6 +10,7 @@ false Tools to simplify coding with the .NET reflection APIs. + * 1.3.3 - Fix issues with Transmute(), where two separate members defined on the same type have the same metadata toekn, because the two members are declared in different modules and by chance they happened to overlap * 1.3.2 - Implemented a MemberReflection.Transmute() method to complement the other Transmute() offerings * 1.3.2 - rewrite constructorReflection.Transmute() to use same MetadataToken trick that the MethodReflection.Transmtue() relies on * 1.3.1 - Fix for bug in MethodReflection.Transmute() leading to completely random method derivations being returned diff --git a/ExpressiveReflection/Properties/AssemblyInfo.cs b/ExpressiveReflection/Properties/AssemblyInfo.cs index b4d7f8c..e0df73f 100644 --- a/ExpressiveReflection/Properties/AssemblyInfo.cs +++ b/ExpressiveReflection/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.2")] -[assembly: AssemblyFileVersion("1.3.2")] +[assembly: AssemblyVersion("1.3.3")] +[assembly: AssemblyFileVersion("1.3.3")] diff --git a/README.md b/README.md index 2e16ab2..ca12b87 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Versioning -This is version 1.3.2 of the expressive reflection library. +This is version 1.3.3 of the expressive reflection library. -This package is available from nuget at: https://www.nuget.org/packages/ExpressiveReflection/1.3.2 +This package is available from nuget at: https://www.nuget.org/packages/ExpressiveReflection/1.3.3 -This package is also available from nuget as an embeddable sources package at: https://www.nuget.org/packages/ExpressiveReflection.Sources/1.3.2 +This package is also available from nuget as an embeddable sources package at: https://www.nuget.org/packages/ExpressiveReflection.Sources/1.3.3 -The source for this release is available on github at: https://github.com/hannasm/ExpressiveReflectionDotNet/releases/tag/1.3.2 +The source for this release is available on github at: https://github.com/hannasm/ExpressiveReflectionDotNet/releases/tag/1.3.3 # ExpressiveReflectionDotnet This is a .NET library for simplifying reflection / metadata programming and making @@ -49,6 +49,9 @@ The ExpressiveReflection.Reflection class exposes all of the reflection methods There is a fairly comprehensive set of unit tests, and additionald examples demonstrating functionality can be found there. # Changelog +## 1.3.3 + * 1.3.3 - Fix issues with Transmute(), where two separate members defined on the same type have the same metadata toekn, because the two members are declared in different modules and by chance they happened to overlap + ## 1.3.2 * 1.3.2 - Implemented a MemberReflection.Transmute() method to complement the other Transmute() offerings * 1.3.2 - rewrite constructorReflection.Transmute() to use same MetadataToken trick that the MethodReflection.Transmtue() relies on