Skip to content

Commit

Permalink
Update Transmute() code in all affected reflection apis, with fix for…
Browse files Browse the repository at this point in the history
… overlapping metadata tokens, i don't have the OCD to try and reproduce a test case for this, though i have a feeling it would have something to do with the number of classes / fields / members / properties that are delcared inside a single module

bumping version number to 1.3.3
  • Loading branch information
hannasm committed Jan 30, 2017
1 parent a2c7954 commit 1add490
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ExpressiveReflection/ConstructorReflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Binary file modified ExpressiveReflection/ExpressiveReflection.Sources.nuspec
Binary file not shown.
2 changes: 1 addition & 1 deletion ExpressiveReflection/MemberReflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion ExpressiveReflection/MethodReflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ExpressiveReflection/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<package >
<metadata>
<id>ExpressiveReflection</id>
<version>1.3.2</version>
<version>1.3.3</version>
<authors>hannasm</authors>
<owners>hannasm</owners>
<licenseUrl>https://github.com/hannasm/ExpressiveReflectionDotnet/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/hannasm/ExpressiveReflectionDotnet</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Tools to simplify coding with the .NET reflection APIs.</description>
<releaseNotes>
* 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
Expand Down
4 changes: 2 additions & 2 deletions ExpressiveReflection/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1add490

Please sign in to comment.