我有这个非常简单的属性(这是一个使用Prism Notifications and Interactions的WPF项目)
public bool ConfirmNavigation
{
get { return _confirmNavigation; }
set { _confirmNavigation = value; base.RaisePropertyChanged<bool>(() => ConfirmNavigation); }
}
生成的IL显示如下。令我困惑的是这条线 -
IL_000a:框MyNamespace.MyClass
MyClass是class
,不是 a struct
。是什么给了什么?
.property instance bool ConfirmNavigation()
.get instance bool MyNamespace.MyClass::get_ConfirmNavigation()
{
.locals init (
[0] bool CS$1$0000
)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldfld bool MyNamespace.MyClass::_confirmNavigation
IL_0007: stloc.0
IL_0008: br.s IL_000a
IL_000a: ldloc.0
IL_000b: ret
}
.set instance void MyNamespace.MyClass::set_ConfirmNavigation(bool)
{
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.1
IL_0003: stfld bool MyNamespace.MyClass::_confirmNavigation
IL_0008: ldarg.0
IL_0009: ldarg.0
***IL_000a: box MyNamespace.MyClass***
IL_000f: ldtoken MyNamespace.MyClass
IL_0014: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0019: call class [System.Core]System.Linq.Expressions.ConstantExpression [System.Core]System.Linq.Expressions.Expression::Constant(object, class [mscorlib]System.Type)
IL_001e: ldtoken method instance bool MyNamespace.MyClass::get_ConfirmNavigation()
IL_0023: call class [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle(valuetype [mscorlib]System.RuntimeMethodHandle)
IL_0028: castclass [mscorlib]System.Reflection.MethodInfo
IL_002d: call class [System.Core]System.Linq.Expressions.MemberExpression [System.Core]System.Linq.Expressions.Expression::Property(class [System.Core]System.Linq.Expressions.Expression, class [mscorlib]System.Reflection.MethodInfo)
IL_0032: ldc.i4.0
IL_0033: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_0038: call class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`1<bool>> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`1<bool>>(class [System.Core]System.Linq.Expressions.Expression, class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_003d: call instance void [Microsoft.Practices.Prism]Microsoft.Practices.Prism.ViewModel.NotificationObject::RaisePropertyChanged<bool>(class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`1<bool>>)
IL_0042: nop
IL_0043: ret
}