Changeset 3554


Ignore:
Timestamp:
04/28/10 14:19:57 (12 years ago)
Author:
epitzer
Message:

circumvent code generation for hooks on 64bit systems, this is a bug in the CLR (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs

    r3553 r3554  
    5151    }
    5252
     53    private static object[] emptyArgs = new object[0];
     54
    5355    public static IEnumerable<Hook> CollectHooks(HookType hookType, Type type) {
    5456      if (type.BaseType != null)
     
    6062            MethodInfo methodInfo = memberInfo as MethodInfo;
    6163            if (memberInfo.MemberType != MemberTypes.Method || memberInfo == null)
    62               throw new ArgumentException("Storable hooks must be methods");       
    63             DynamicMethod dm = new DynamicMethod("", null, new[] { typeof(object) }, type);
    64             ILGenerator ilgen = dm.GetILGenerator();
    65             ilgen.Emit(OpCodes.Ldarg_1);
    66             ilgen.Emit(OpCodes.Call, methodInfo);
    67             ilgen.Emit(OpCodes.Ret);
    68             yield return (Hook)dm.CreateDelegate(typeof(Hook));
     64              throw new ArgumentException("Storable hooks must be methods");
     65            if (System.IntPtr.Size == 4) {
     66              DynamicMethod dm = new DynamicMethod("", null, new[] { typeof(object) }, type);
     67              ILGenerator ilgen = dm.GetILGenerator();
     68              ilgen.Emit(OpCodes.Ldarg_1);
     69              ilgen.Emit(OpCodes.Call, methodInfo);
     70              ilgen.Emit(OpCodes.Ret);
     71              yield return (Hook)dm.CreateDelegate(typeof(Hook));
     72            } else {
     73              yield return new Hook(o => methodInfo.Invoke(o, emptyArgs));
     74            }
    6975          }
    7076        }
Note: See TracChangeset for help on using the changeset viewer.