Skip to content

Commit

Permalink
Fix compiler warning: replace int->ulong cast with int->uint->ulong t…
Browse files Browse the repository at this point in the history
…o avoid sign-extension and prefer zero-extension. Now, UniqueToken is literally a binary combination of two numbers.
  • Loading branch information
borzov committed Aug 8, 2024
1 parent b7f16f3 commit 3623320
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions GrEmit/Utils/HackHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public static Type GetValueTypeForNullableOrNull(Type mayBeNullable)
//NOTE MetadataToken's reassigned on compilation !!! use inside appdomain
public static ulong GetMemberUniqueToken(MemberInfo mi)
{
return ((ulong)mi.Module.MetadataToken) << 32 | (ulong)mi.MetadataToken;
return ((ulong)mi.Module.MetadataToken << 32) | (uint)mi.MetadataToken;
}

//BUG может быть одинаков для типов из разных сборок
public static ulong GetTypeUniqueToken(Type type)
{
return ((ulong)type.Module.MetadataToken) << 32 | (ulong)type.MetadataToken;
return ((ulong)type.Module.MetadataToken << 32) | (uint)type.MetadataToken;
}

public static ConstructorInfo GetObjectConstruction<T>(Expression<Func<T>> constructorCall,
Expand Down

0 comments on commit 3623320

Please sign in to comment.