public void Instance_ValueType_Field() { var instance = new ReferenceType(); MemberUtils.GenerateSetMethod(ReferenceType.PropertyInfo_Instance_ValueType_Field)(instance, Magic_ValueType); Assert.Equal(Magic_ValueType, instance.Instance_ValueType_Field); }
public void SwissILSetField() { var swiss = MemberUtils.GenerateSetMethod(_field); for (var i = 0; i < Reps; i++) { swiss(this, 3); } }
public void SwissILSetProperty() { var swiss = MemberUtils.GenerateSetMethod(_property); for (var i = 0; i < Reps; i++) { swiss(this, 3); } }
public void Code(PropertyInfo property) { property.SetValue(this, "abcd"); var setMethodInfo = property.GetSetMethod(true); var instance = Expression.Parameter(typeof(object), "instance"); var value = Expression.Parameter(typeof(object), "value"); var instanceCast = (!property.DeclaringType.GetTypeInfo().IsValueType) ? Expression.TypeAs(instance, property.DeclaringType) : Expression.Convert(instance, property.DeclaringType); var valueCast = (!property.PropertyType.GetTypeInfo().IsValueType) ? Expression.TypeAs(value, property.PropertyType) : Expression.Convert(value, property.PropertyType); var expressionSet = Expression.Lambda <SetMethod>(Expression.Call(instanceCast, setMethodInfo, valueCast), new ParameterExpression[] { instance, value }).Compile(); expressionSet(this, "abcd"); var ilSet = MemberUtils.GenerateSetMethod(property); ilSet(this, "abcd"); }
public void Static_ValueType_Property() { MemberUtils.GenerateSetMethod(ReferenceType.PropertyInfo_Static_ValueType_Property)(null, Magic_ValueType); Assert.Equal(Magic_ValueType, ReferenceType.Static_ValueType_Property); }
public SetMethod FieldCreateSetViaSwissIL() => MemberUtils.GenerateSetMethod(_field);
public SetMethod PropCreateSetViaSwissIL() => MemberUtils.GenerateSetMethod(_property);
public void Static_ReferenceType_Field() { MemberUtils.GenerateSetMethod(ReferenceType.FieldInfo_Static_ReferenceType_Field)(null, Magic_ReferenceType); Assert.Equal(Magic_ReferenceType, ReferenceType.Static_ReferenceType_Field); }