// private ParameterInfo[] indexParameters; public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, string name, PropertyAttributes attributes, Type propertyType, Type[] arguments) { this.parentTypeEmitter = parentTypeEmitter; // DYNPROXY-73 - AmbiguousMatchException for properties // This is a workaround for a framework limitation in CLR 2.0 // This limitation was removed in CLR 2.0 SP1, but we don't want to // tie ourselves to that version. This perform the lookup for the new overload // dynamically, so we have a nice fallback on vanilla CLR 2.0 if (TypeBuilderMethods.DefineProperty == null || true) // TODO { DefineProperty_Clr2_0 oldDefineProperty = parentTypeEmitter.TypeBuilder.DefineProperty; builder = oldDefineProperty(name, attributes, propertyType, arguments); } else { var newDefinedProperty = (DefineProperty_Clr_2_0_SP1) Delegate.CreateDelegate(typeof(DefineProperty_Clr_2_0_SP1), parentTypeEmitter.TypeBuilder, TypeBuilderMethods.DefineProperty); builder = newDefinedProperty( name, attributes, CallingConventions.HasThis, propertyType, null, null, arguments, null, null); } }
// private ParameterInfo[] indexParameters; public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, string name, PropertyAttributes attributes, Type propertyType, Type[] arguments) { this.parentTypeEmitter = parentTypeEmitter; // DYNPROXY-73 - AmbiguousMatchException for properties // This is a workaround for a framework limitation in CLR 2.0 // This limitation was removed in CLR 2.0 SP1, but we don't want to // tie ourselves to that version. This perform the lookup for the new overload // dynamically, so we have a nice fallback on vanilla CLR 2.0 // @mbrit - 2012-05-30 - it appears in WinRT, the old version works OK... new version is baffling... #if !NETFX_CORE bool isWinRt = false; #else bool isWinRt = true; #endif if (TypeBuilderMethods.DefineProperty == null || isWinRt) { DefineProperty_Clr2_0 oldDefineProperty = parentTypeEmitter.TypeBuilder.DefineProperty; builder = oldDefineProperty(name, attributes, propertyType, arguments); } else { #if !NETFX_CORE var newDefinedProperty = (DefineProperty_Clr_2_0_SP1) Delegate.CreateDelegate(typeof(DefineProperty_Clr_2_0_SP1), parentTypeEmitter.TypeBuilder, TypeBuilderMethods.DefineProperty); builder = newDefinedProperty( name, attributes, CallingConventions.HasThis, propertyType, null, null, arguments, null, null); #endif } }