Skip to content

Commit

Permalink
Merge pull request #211 from kaenganxt/ulongFix
Browse files Browse the repository at this point in the history
Handle methods returning a ulong or an enum with base type long/ulong correctly
  • Loading branch information
pardeike authored Sep 23, 2019
2 parents 53f5182 + fb8fc58 commit 6683055
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Harmony/Internal/DynamicTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ internal static LocalBuilder[] DeclareLocalVariables(MethodBase original, ILGene
internal static LocalBuilder DeclareLocalVariable(ILGenerator generator, Type type)
{
if (type.IsByRef) type = type.GetElementType();
if (type.IsEnum) type = Enum.GetUnderlyingType(type);

if (AccessTools.IsClass(type))
{
Expand All @@ -92,7 +93,7 @@ internal static LocalBuilder DeclareLocalVariable(ILGenerator generator, Type ty
Emitter.Emit(generator, OpCodes.Ldc_R4, (float)0);
else if (type == typeof(double))
Emitter.Emit(generator, OpCodes.Ldc_R8, (double)0);
else if (type == typeof(long))
else if (type == typeof(long) || type == typeof(ulong))
Emitter.Emit(generator, OpCodes.Ldc_I8, (long)0);
else
Emitter.Emit(generator, OpCodes.Ldc_I4, 0);
Expand Down

0 comments on commit 6683055

Please sign in to comment.