Imported Upstream version 5.20.0.180

Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-02-04 20:11:37 +00:00
parent 0e2d47d1c8
commit 0510252385
3360 changed files with 83827 additions and 39243 deletions

View File

@@ -11,6 +11,6 @@ namespace System.Reflection
{
return false;
}
#endif
#endif
}
}

View File

@@ -1,146 +0,0 @@
//
// System.Reflection/ConstructorInfo.cs
//
// Author:
// Paolo Molaro (lupus@ximian.com)
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Reflection {
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_ConstructorInfo))]
[Serializable]
[ClassInterface(ClassInterfaceType.None)]
#if MOBILE
public abstract class ConstructorInfo : MethodBase {
#else
public abstract class ConstructorInfo : MethodBase, _ConstructorInfo {
#endif
[ComVisible (true)]
public static readonly string ConstructorName = ".ctor";
[ComVisible (true)]
public static readonly string TypeConstructorName = ".cctor";
protected ConstructorInfo() {
}
[ComVisible (true)]
public override MemberTypes MemberType {
get {return MemberTypes.Constructor;}
}
[DebuggerStepThrough]
[DebuggerHidden]
public object Invoke (object[] parameters)
{
return Invoke (BindingFlags.CreateInstance, null, parameters ?? EmptyArray<object>.Value, null);
}
public abstract object Invoke (BindingFlags invokeAttr, Binder binder, object[] parameters,
CultureInfo culture);
#if !MOBILE
void _ConstructorInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
}
Type _ConstructorInfo.GetType ()
{
// Required or object::GetType becomes virtual final
return base.GetType ();
}
void _ConstructorInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException ();
}
void _ConstructorInfo.GetTypeInfoCount (out uint pcTInfo)
{
throw new NotImplementedException ();
}
void _ConstructorInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException ();
}
object _ConstructorInfo.Invoke_2 (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
return this.Invoke (obj, invokeAttr, binder, parameters, culture);
}
object _ConstructorInfo.Invoke_3 (object obj, object[] parameters)
{
return base.Invoke (obj, parameters);
}
object _ConstructorInfo.Invoke_4 (BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
return this.Invoke (invokeAttr, binder, parameters, culture);
}
object _ConstructorInfo.Invoke_5 (object[] parameters)
{
return this.Invoke (parameters);
}
#endif
public override bool Equals (object obj)
{
return obj == (object) this;
}
public override int GetHashCode ()
{
return base.GetHashCode ();
}
public static bool operator == (ConstructorInfo left, ConstructorInfo right)
{
if ((object)left == (object)right)
return true;
if ((object)left == null ^ (object)right == null)
return false;
return left.Equals (right);
}
public static bool operator != (ConstructorInfo left, ConstructorInfo right)
{
if ((object)left == (object)right)
return false;
if ((object)left == null ^ (object)right == null)
return true;
return !left.Equals (right);
}
}
}

View File

@@ -1,105 +0,0 @@
//
// System.Reflection/CustomAttributeNamedArgument.cs
//
// Author:
// Zoltan Varga (vargaz@gmail.com)
// Carlos Alberto Cortez (calberto.cortez@gmail.com)
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Reflection {
[ComVisible (true)]
[Serializable]
public struct CustomAttributeNamedArgument {
CustomAttributeTypedArgument typedArgument;
MemberInfo memberInfo;
public
CustomAttributeNamedArgument (MemberInfo memberInfo, object value)
{
this.memberInfo = memberInfo;
this.typedArgument = (CustomAttributeTypedArgument) value;
}
public CustomAttributeNamedArgument (MemberInfo memberInfo, CustomAttributeTypedArgument typedArgument)
{
this.memberInfo = memberInfo;
this.typedArgument = typedArgument;
}
public MemberInfo MemberInfo {
get {
return memberInfo;
}
}
public CustomAttributeTypedArgument TypedValue {
get {
return typedArgument;
}
}
public bool IsField {
get { return memberInfo.MemberType == MemberTypes.Field; }
}
public string MemberName {
get { return memberInfo.Name; }
}
public override string ToString ()
{
return memberInfo.Name + " = " + typedArgument.ToString ();
}
public override bool Equals (object obj)
{
if (!(obj is CustomAttributeNamedArgument))
return false;
CustomAttributeNamedArgument other = (CustomAttributeNamedArgument) obj;
return other.memberInfo == memberInfo &&
typedArgument.Equals (other.typedArgument);
}
public override int GetHashCode ()
{
return (memberInfo.GetHashCode () << 16) + typedArgument.GetHashCode ();
}
public static bool operator == (CustomAttributeNamedArgument left, CustomAttributeNamedArgument right)
{
return left.Equals (right);
}
public static bool operator != (CustomAttributeNamedArgument left, CustomAttributeNamedArgument right)
{
return !left.Equals (right);
}
}
}

View File

@@ -1,125 +0,0 @@
//
// System.Reflection/CustomAttributeTypedArgument.cs
//
// Author:
// Zoltan Varga (vargaz@gmail.com)
// Carlos Alberto Cortez (calberto.cortez@gmail.com)
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
using System.Collections.ObjectModel;
namespace System.Reflection {
[ComVisible (true)]
[Serializable]
public struct CustomAttributeTypedArgument {
Type argumentType;
object value;
public
CustomAttributeTypedArgument (Type argumentType, object value)
{
if (argumentType == null)
throw new ArgumentNullException ("argumentType");
this.argumentType = argumentType;
this.value = value;
// MS seems to convert arrays into a ReadOnlyCollection
if (value is Array) {
Array a = (Array)value;
Type etype = a.GetType ().GetElementType ();
CustomAttributeTypedArgument[] new_value = new CustomAttributeTypedArgument [a.GetLength (0)];
for (int i = 0; i < new_value.Length; ++i)
new_value [i] = new CustomAttributeTypedArgument (etype, a.GetValue (i));
this.value = new ReadOnlyCollection <CustomAttributeTypedArgument> (new_value);
}
}
public CustomAttributeTypedArgument (object value)
{
if (value == null)
throw new ArgumentNullException ("value");
this.argumentType = value.GetType ();
this.value = value;
}
public Type ArgumentType {
get {
return argumentType;
}
}
public object Value {
get {
return value;
}
}
public override string ToString ()
{
string val = value != null ? value.ToString () : String.Empty;
if (argumentType == typeof (string))
return "\"" + val + "\"";
if (argumentType == typeof (Type))
return "typeof (" + val + ")";
if (argumentType.IsEnum)
return "(" + argumentType.Name + ")" + val;
return val;
}
public override bool Equals (object obj)
{
if (!(obj is CustomAttributeTypedArgument))
return false;
CustomAttributeTypedArgument other = (CustomAttributeTypedArgument) obj;
return other.argumentType == argumentType &&
value != null ? value.Equals (other.value) : (object) other.value == null;
}
public override int GetHashCode ()
{
return (argumentType.GetHashCode () << 16) + (value != null ? value.GetHashCode () : 0);
}
public static bool operator == (CustomAttributeTypedArgument left, CustomAttributeTypedArgument right)
{
return left.Equals (right);
}
public static bool operator != (CustomAttributeTypedArgument left, CustomAttributeTypedArgument right)
{
return !left.Equals (right);
}
}
}

View File

@@ -33,51 +33,10 @@ using System.Runtime.InteropServices;
namespace System.Reflection {
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_EventInfo))]
[Serializable]
[ClassInterface(ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
public abstract class EventInfo : MemberInfo {
#else
public abstract class EventInfo : MemberInfo, _EventInfo {
#endif
public abstract partial class EventInfo : MemberInfo {
AddEventAdapter cached_add_event;
public abstract EventAttributes Attributes {get;}
public
virtual
Type EventHandlerType {
get {
ParameterInfo[] p;
MethodInfo add = GetAddMethod (true);
p = add.GetParametersInternal ();
if (p.Length > 0) {
Type t = p [0].ParameterType;
/* is it alwasys the first arg?
if (!t.IsSubclassOf (typeof (System.Delegate)))
throw new Exception ("no delegate in event");*/
return t;
}
return null;
}
}
public
virtual
bool IsMulticast {get {return true;}}
public bool IsSpecialName {get {return (Attributes & EventAttributes.SpecialName ) != 0;}}
public override MemberTypes MemberType {
get {return MemberTypes.Event;}
}
protected EventInfo() {
}
[DebuggerHidden]
[DebuggerStepThrough]
public
@@ -112,97 +71,6 @@ namespace System.Reflection {
#endif
}
public MethodInfo GetAddMethod() {
return GetAddMethod (false);
}
public abstract MethodInfo GetAddMethod(bool nonPublic);
public MethodInfo GetRaiseMethod() {
return GetRaiseMethod (false);
}
public abstract MethodInfo GetRaiseMethod( bool nonPublic);
public MethodInfo GetRemoveMethod() {
return GetRemoveMethod (false);
}
public abstract MethodInfo GetRemoveMethod( bool nonPublic);
public virtual MethodInfo[] GetOtherMethods (bool nonPublic) {
// implemented by the derived class
return EmptyArray<MethodInfo>.Value;
}
public MethodInfo[] GetOtherMethods () {
return GetOtherMethods (false);
}
[DebuggerHidden]
[DebuggerStepThrough]
public
virtual
void RemoveEventHandler (object target, Delegate handler)
{
MethodInfo remove = GetRemoveMethod ();
if (remove == null)
throw new InvalidOperationException ("Cannot remove a handler to an event that doesn't have a visible remove method");
remove.Invoke (target, new object [] {handler});
}
public override bool Equals (object obj)
{
return obj == (object) this;
}
public override int GetHashCode ()
{
return base.GetHashCode ();
}
public static bool operator == (EventInfo left, EventInfo right)
{
if ((object)left == (object)right)
return true;
if ((object)left == null ^ (object)right == null)
return false;
return left.Equals (right);
}
public static bool operator != (EventInfo left, EventInfo right)
{
if ((object)left == (object)right)
return false;
if ((object)left == null ^ (object)right == null)
return true;
return !left.Equals (right);
}
#if !MOBILE
void _EventInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
}
Type _EventInfo.GetType ()
{
// Required or object::GetType becomes virtual final
return base.GetType ();
}
void _EventInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException ();
}
void _EventInfo.GetTypeInfoCount (out uint pcTInfo)
{
throw new NotImplementedException ();
}
void _EventInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException ();
}
#endif
delegate void AddEventAdapter (object _this, Delegate dele);
// this optimization cause problems with full AOT
@@ -220,6 +88,8 @@ namespace System.Reflection {
throw new TargetException ("Cannot add a handler to a non static event with a null target");
if (!(obj is T))
throw new TargetException ("Object doesn't match target");
if (!(dele is D))
throw new ArgumentException ($"Object of type {dele.GetType ()} cannot be converted to type {typeof (D)}.");
addEvent ((T)obj, (D)dele);
}
@@ -269,16 +139,6 @@ namespace System.Reflection {
}
#endif
public virtual MethodInfo AddMethod {
get { return GetAddMethod (true); }
}
public virtual MethodInfo RaiseMethod {
get { return GetRaiseMethod (true); }
}
public virtual MethodInfo RemoveMethod {
get { return GetRemoveMethod (true); }
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern EventInfo internal_from_handle_type (IntPtr event_handle, IntPtr type_handle);

View File

@@ -35,113 +35,8 @@ using System.Runtime.InteropServices;
namespace System.Reflection {
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_FieldInfo))]
[Serializable]
[ClassInterface(ClassInterfaceType.None)]
#if MOBILE
public abstract class FieldInfo : MemberInfo {
#else
public abstract class FieldInfo : MemberInfo, _FieldInfo {
#endif
public abstract FieldAttributes Attributes {get;}
public abstract RuntimeFieldHandle FieldHandle {get;}
protected FieldInfo () {}
public abstract Type FieldType { get; }
public abstract object GetValue(object obj);
public override MemberTypes MemberType {
get { return MemberTypes.Field;}
}
public bool IsLiteral
{
get {return (Attributes & FieldAttributes.Literal) != 0;}
}
public bool IsStatic
{
get {return (Attributes & FieldAttributes.Static) != 0;}
}
public bool IsInitOnly
{
get {return (Attributes & FieldAttributes.InitOnly) != 0;}
}
public Boolean IsPublic
{
get
{
return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public;
}
}
public Boolean IsPrivate
{
get
{
return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private;
}
}
public Boolean IsFamily
{
get
{
return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family;
}
}
public Boolean IsAssembly
{
get
{
return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly;
}
}
public Boolean IsFamilyAndAssembly
{
get {
return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem;
}
}
public Boolean IsFamilyOrAssembly
{
get
{
return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem;
}
}
public Boolean IsPinvokeImpl
{
get
{
return (Attributes & FieldAttributes.PinvokeImpl) == FieldAttributes.PinvokeImpl;
}
}
public Boolean IsSpecialName
{
get
{
return (Attributes & FieldAttributes.SpecialName) == FieldAttributes.SpecialName;
}
}
public Boolean IsNotSerialized
{
get
{
return (Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized;
}
}
public abstract void SetValue (object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture);
[DebuggerHidden]
[DebuggerStepThrough]
public void SetValue (object obj, object value)
{
SetValue (obj, value, 0, null, null);
}
partial class FieldInfo : MemberInfo {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern FieldInfo internal_from_handle_type (IntPtr field_handle, IntPtr type_handle);
@@ -164,33 +59,11 @@ namespace System.Reflection {
return fi;
}
//
// Note: making this abstract imposes an implementation requirement
// on any class that derives from it. However, since it's also
// internal, that means only classes inside corlib can derive
// from FieldInfo. See
//
// errors/cs0534-4.cs errors/CS0534-4-lib.cs
//
// class/Microsoft.JScript/Microsoft.JScript/JSFieldInfo.cs
//
internal virtual int GetFieldOffset ()
{
throw new SystemException ("This method should not be called");
}
[CLSCompliant(false)]
public virtual object GetValueDirect (TypedReference obj)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
}
[CLSCompliant(false)]
public virtual void SetValueDirect (TypedReference obj, object value)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern MarshalAsAttribute get_marshal_info ();
@@ -263,101 +136,5 @@ namespace System.Reflection {
return attrsData;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern Type[] GetTypeModifiers (bool optional);
public virtual Type[] GetOptionalCustomModifiers () {
Type[] types = GetTypeModifiers (true);
if (types == null)
return Type.EmptyTypes;
return types;
}
public virtual Type[] GetRequiredCustomModifiers () {
Type[] types = GetTypeModifiers (false);
if (types == null)
return Type.EmptyTypes;
return types;
}
public virtual object GetRawConstantValue ()
{
throw new NotSupportedException ("This non-CLS method is not implemented.");
}
public override bool Equals (object obj)
{
return obj == (object) this;
}
public override int GetHashCode ()
{
return base.GetHashCode ();
}
public static bool operator == (FieldInfo left, FieldInfo right)
{
if ((object)left == (object)right)
return true;
if ((object)left == null ^ (object)right == null)
return false;
return left.Equals (right);
}
public static bool operator != (FieldInfo left, FieldInfo right)
{
if ((object)left == (object)right)
return false;
if ((object)left == null ^ (object)right == null)
return true;
return !left.Equals (right);
}
public virtual bool IsSecurityCritical {
get {
throw new NotSupportedException ();
}
}
public virtual bool IsSecuritySafeCritical {
get {
throw new NotSupportedException ();
}
}
public virtual bool IsSecurityTransparent {
get {
throw new NotSupportedException ();
}
}
#if !MOBILE
void _FieldInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
}
Type _FieldInfo.GetType ()
{
// Required or object::GetType becomes virtual final
return base.GetType ();
}
void _FieldInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException ();
}
void _FieldInfo.GetTypeInfoCount (out uint pcTInfo)
{
throw new NotImplementedException ();
}
void _FieldInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException ();
}
#endif
}
}

View File

@@ -1,42 +0,0 @@
//
// System.Reflection.ModuleResolveEventHandler
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2003 Ximian, Inc (http://www.ximian.com)
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Reflection
{
[ComVisible (true)]
[Serializable]
public delegate Module ModuleResolveEventHandler (object sender, ResolveEventArgs e);
}

View File

@@ -209,5 +209,16 @@ namespace System.Reflection {
public override IList<CustomAttributeData> GetCustomAttributesData () {
return CustomAttributeData.GetCustomAttributes (this);
}
public override int MetadataToken {
get {
return get_metadata_token (this);
}
}
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoEvent> (other);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern int get_metadata_token (MonoEvent monoEvent);
}
}

View File

@@ -318,5 +318,25 @@ namespace System.Reflection {
get { return get_core_clr_security_level () == 1; }
}
#endif
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoField> (other);
public override int MetadataToken {
get {
return get_metadata_token (this);
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern int get_metadata_token (MonoField monoField);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern Type[] GetTypeModifiers (bool optional);
public override Type[] GetOptionalCustomModifiers () => GetCustomModifiers (true);
public override Type[] GetRequiredCustomModifiers () => GetCustomModifiers (false);
private Type[] GetCustomModifiers (bool optional) => GetTypeModifiers (optional) ?? Type.EmptyTypes;
}
}

View File

@@ -33,6 +33,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using InteropServicesCallingConvention = System.Runtime.InteropServices.CallingConvention;
using System.Runtime.Serialization;
#if !FULL_AOT_RUNTIME
using System.Reflection.Emit;
@@ -106,9 +107,9 @@ namespace System.Reflection {
static internal ParameterInfo GetReturnParameterInfo (MonoMethod method)
{
return ParameterInfo.New (GetReturnType (method.mhandle), method, get_retval_marshal (method.mhandle));
return MonoParameterInfo.New (GetReturnType (method.mhandle), method, get_retval_marshal (method.mhandle));
}
};
}
abstract class RuntimeMethodInfo : MethodInfo, ISerializable
{
@@ -143,7 +144,7 @@ namespace System.Reflection {
sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, format));
sbName.Append("(");
ParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, serialization);
MonoParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, serialization);
sbName.Append(")");
return sbName.ToString();
@@ -220,6 +221,9 @@ namespace System.Reflection {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern MonoMethod get_base_method (MonoMethod method, bool definition);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern int get_metadata_token (MonoMethod method);
public override MethodInfo GetBaseDefinition ()
{
return get_base_method (this, true);
@@ -246,6 +250,12 @@ namespace System.Reflection {
return MonoMethodInfo.GetReturnParameterInfo (this);
}
}
public override int MetadataToken {
get {
return get_metadata_token (this);
}
}
public override MethodImplAttributes GetMethodImplementationFlags ()
{
@@ -287,6 +297,15 @@ namespace System.Reflection {
[DebuggerStepThrough]
public override Object Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
if (!IsStatic) {
if (!DeclaringType.IsInstanceOfType (obj)) {
if (obj == null)
throw new TargetException ("Non-static method requires a target.");
else
throw new TargetException ("Object does not match target type.");
}
}
if (binder == null)
binder = Type.DefaultBinder;
@@ -309,6 +328,8 @@ namespace System.Reflection {
} catch (MethodAccessException) {
throw;
#endif
} catch (OverflowException) {
throw;
} catch (Exception e) {
throw new TargetInvocationException (e);
}
@@ -446,18 +467,96 @@ namespace System.Reflection {
if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
attrsData [count++] = new CustomAttributeData ((typeof (PreserveSigAttribute)).GetConstructor (Type.EmptyTypes));
if ((info.attrs & MethodAttributes.PinvokeImpl) != 0) {
this.GetPInvoke (out PInvokeAttributes flags, out string entryPoint, out string dllName);
var ctorArgs = new CustomAttributeTypedArgument[] { new CustomAttributeTypedArgument(typeof(string), dllName) };
attrsData [count++] = new CustomAttributeData (
(typeof (FieldOffsetAttribute)).GetConstructor (new[] { typeof (string) }),
ctorArgs,
EmptyArray<CustomAttributeNamedArgument>.Value); //FIXME Get named params
}
if ((info.attrs & MethodAttributes.PinvokeImpl) != 0)
attrsData [count++] = GetDllImportAttributeData ();
return attrsData;
}
private CustomAttributeData GetDllImportAttributeData ()
{
if ((Attributes & MethodAttributes.PinvokeImpl) == 0)
return null;
string entryPoint, dllName = null;
PInvokeAttributes flags = 0;
GetPInvoke (out flags, out entryPoint, out dllName);
CharSet charSet;
switch (flags & PInvokeAttributes.CharSetMask) {
case PInvokeAttributes.CharSetNotSpec:
charSet = CharSet.None;
break;
case PInvokeAttributes.CharSetAnsi:
charSet = CharSet.Ansi;
break;
case PInvokeAttributes.CharSetUnicode:
charSet = CharSet.Unicode;
break;
case PInvokeAttributes.CharSetAuto:
charSet = CharSet.Auto;
break;
// Invalid: default to CharSet.None
default:
charSet = CharSet.None;
break;
}
InteropServicesCallingConvention callingConvention;
switch (flags & PInvokeAttributes.CallConvMask) {
case PInvokeAttributes.CallConvWinapi:
callingConvention = InteropServicesCallingConvention.Winapi;
break;
case PInvokeAttributes.CallConvCdecl:
callingConvention = InteropServicesCallingConvention.Cdecl;
break;
case PInvokeAttributes.CallConvStdcall:
callingConvention = InteropServicesCallingConvention.StdCall;
break;
case PInvokeAttributes.CallConvThiscall:
callingConvention = InteropServicesCallingConvention.ThisCall;
break;
case PInvokeAttributes.CallConvFastcall:
callingConvention = InteropServicesCallingConvention.FastCall;
break;
// Invalid: default to CallingConvention.Cdecl
default:
callingConvention = InteropServicesCallingConvention.Cdecl;
break;
}
bool exactSpelling = (flags & PInvokeAttributes.NoMangle) != 0;
bool setLastError = (flags & PInvokeAttributes.SupportsLastError) != 0;
bool bestFitMapping = (flags & PInvokeAttributes.BestFitMask) == PInvokeAttributes.BestFitEnabled;
bool throwOnUnmappableChar = (flags & PInvokeAttributes.ThrowOnUnmappableCharMask) == PInvokeAttributes.ThrowOnUnmappableCharEnabled;
bool preserveSig = (GetMethodImplementationFlags () & MethodImplAttributes.PreserveSig) != 0;
var ctorArgs = new CustomAttributeTypedArgument [] {
new CustomAttributeTypedArgument (typeof (string), dllName),
};
var attrType = typeof (DllImportAttribute);
var namedArgs = new CustomAttributeNamedArgument [] {
new CustomAttributeNamedArgument (attrType.GetField ("EntryPoint"), entryPoint),
new CustomAttributeNamedArgument (attrType.GetField ("CharSet"), charSet),
new CustomAttributeNamedArgument (attrType.GetField ("ExactSpelling"), exactSpelling),
new CustomAttributeNamedArgument (attrType.GetField ("SetLastError"), setLastError),
new CustomAttributeNamedArgument (attrType.GetField ("PreserveSig"), preserveSig),
new CustomAttributeNamedArgument (attrType.GetField ("CallingConvention"), callingConvention),
new CustomAttributeNamedArgument (attrType.GetField ("BestFitMapping"), bestFitMapping),
new CustomAttributeNamedArgument (attrType.GetField ("ThrowOnUnmappableChar"), throwOnUnmappableChar)
};
return new CustomAttributeData (
attrType.GetConstructor (new[] { typeof (string) }),
ctorArgs,
namedArgs);
}
public override MethodInfo MakeGenericMethod (Type [] methodInstantiation)
{
if (methodInstantiation == null)
@@ -560,6 +659,8 @@ namespace System.Reflection {
public override bool IsSecuritySafeCritical {
get { return get_core_clr_security_level () == 1; }
}
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoMethod> (other);
}
@@ -700,6 +801,8 @@ namespace System.Reflection {
} catch (MethodAccessException) {
throw;
#endif
} catch (OverflowException) {
throw;
} catch (Exception e) {
throw new TargetInvocationException (e);
}
@@ -809,6 +912,8 @@ namespace System.Reflection {
public extern int get_core_clr_security_level ();
#endif
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoCMethod> (other);
public override bool IsSecurityTransparent {
get { return get_core_clr_security_level () == 0; }
}
@@ -820,5 +925,14 @@ namespace System.Reflection {
public override bool IsSecuritySafeCritical {
get { return get_core_clr_security_level () == 1; }
}
public override int MetadataToken {
get {
return get_metadata_token (this);
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern int get_metadata_token (MonoCMethod method);
}
}

View File

@@ -48,7 +48,36 @@ namespace System.Reflection
[Serializable]
[ClassInterfaceAttribute (ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
class MonoParameterInfo : RuntimeParameterInfo {
class MonoParameterInfo : RuntimeParameterInfo {
internal MarshalAsAttribute marshalAs;
internal static void FormatParameters (StringBuilder sb, ParameterInfo[] p, CallingConventions callingConvention, bool serialization)
{
for (int i = 0; i < p.Length; ++i) {
if (i > 0)
sb.Append (", ");
Type t = p[i].ParameterType;
string typeName = t.FormatTypeName (serialization);
// Legacy: Why use "ByRef" for by ref parameters? What language is this?
// VB uses "ByRef" but it should precede (not follow) the parameter name.
// Why don't we just use "&"?
if (t.IsByRef && !serialization) {
sb.Append (typeName.TrimEnd (new char[] { '&' }));
sb.Append (" ByRef");
} else {
sb.Append (typeName);
}
}
if ((callingConvention & CallingConventions.VarArgs) != 0) {
if (p.Length > 0)
sb.Append (", ");
sb.Append ("...");
}
}
#if !FULL_AOT_RUNTIME
internal MonoParameterInfo (ParameterBuilder pb, Type type, MemberInfo member, int position) {
@@ -87,8 +116,7 @@ namespace System.Reflection
this.NameImpl = pinfo.Name;
this.PositionImpl = pinfo.Position;
this.AttrsImpl = pinfo.Attributes;
this.DefaultValueImpl = pinfo.GetDefaultValueImpl ();
//this.parent = pinfo;
this.DefaultValueImpl = GetDefaultValueImpl (pinfo);
}
/* to build a ParameterInfo for the return type of a method */
@@ -104,12 +132,12 @@ namespace System.Reflection
public override
object DefaultValue {
get {
if (ClassImpl == typeof (Decimal)) {
if (ClassImpl == typeof (Decimal) || ClassImpl == typeof (Decimal?)) {
/* default values for decimals are encoded using a custom attribute */
DecimalConstantAttribute[] attrs = (DecimalConstantAttribute[])GetCustomAttributes (typeof (DecimalConstantAttribute), false);
if (attrs.Length > 0)
return attrs [0].Value;
} else if (ClassImpl == typeof (DateTime)) {
} else if (ClassImpl == typeof (DateTime) || ClassImpl == typeof (DateTime?)) {
/* default values for DateTime are encoded using a custom attribute */
DateTimeConstantAttribute[] attrs = (DateTimeConstantAttribute[])GetCustomAttributes (typeof (DateTimeConstantAttribute), false);
if (attrs.Length > 0)
@@ -160,6 +188,11 @@ namespace System.Reflection
return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
}
internal object GetDefaultValueImpl (ParameterInfo pinfo)
{
FieldInfo field = typeof (ParameterInfo).GetField ("DefaultValueImpl", BindingFlags.Instance | BindingFlags.NonPublic);
return field.GetValue (pinfo);
}
public
override
@@ -171,6 +204,8 @@ namespace System.Reflection
return CustomAttributeData.GetCustomAttributes (this);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern int GetMetadataToken ();
public
override
@@ -181,6 +216,72 @@ namespace System.Reflection
return types;
}
internal object[] GetPseudoCustomAttributes ()
{
int count = 0;
if (IsIn)
count ++;
if (IsOut)
count ++;
if (IsOptional)
count ++;
if (marshalAs != null)
count ++;
if (count == 0)
return null;
object[] attrs = new object [count];
count = 0;
if (IsIn)
attrs [count ++] = new InAttribute ();
if (IsOut)
attrs [count ++] = new OutAttribute ();
if (IsOptional)
attrs [count ++] = new OptionalAttribute ();
if (marshalAs != null)
attrs [count ++] = marshalAs.Copy ();
return attrs;
}
internal CustomAttributeData[] GetPseudoCustomAttributesData ()
{
int count = 0;
if (IsIn)
count++;
if (IsOut)
count++;
if (IsOptional)
count++;
if (marshalAs != null)
count++;
if (count == 0)
return null;
CustomAttributeData[] attrsData = new CustomAttributeData [count];
count = 0;
if (IsIn)
attrsData [count++] = new CustomAttributeData ((typeof (InAttribute)).GetConstructor (Type.EmptyTypes));
if (IsOut)
attrsData [count++] = new CustomAttributeData ((typeof (OutAttribute)).GetConstructor (Type.EmptyTypes));
if (IsOptional)
attrsData [count++] = new CustomAttributeData ((typeof (OptionalAttribute)).GetConstructor (Type.EmptyTypes));
if (marshalAs != null) {
var ctorArgs = new CustomAttributeTypedArgument[] { new CustomAttributeTypedArgument (typeof (UnmanagedType), marshalAs.Value) };
attrsData [count++] = new CustomAttributeData (
(typeof (MarshalAsAttribute)).GetConstructor (new[] { typeof (UnmanagedType) }),
ctorArgs,
EmptyArray<CustomAttributeNamedArgument>.Value);//FIXME Get named params
}
return attrsData;
}
public
override
Type[] GetRequiredCustomModifiers () {
@@ -202,5 +303,30 @@ namespace System.Reflection
return true;
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Type[] GetTypeModifiers (bool optional);
#if !FULL_AOT_RUNTIME
internal static ParameterInfo New (ParameterBuilder pb, Type type, MemberInfo member, int position)
{
return new MonoParameterInfo (pb, type, member, position);
}
#endif
internal static ParameterInfo New (ParameterInfo pinfo, Type type, MemberInfo member, int position)
{
return new MonoParameterInfo (pinfo, type, member, position);
}
internal static ParameterInfo New (ParameterInfo pinfo, MemberInfo member)
{
return new MonoParameterInfo (pinfo, member);
}
internal static ParameterInfo New (Type type, MemberInfo member, MarshalAsAttribute marshalAs)
{
return new MonoParameterInfo (type, member, marshalAs);
}
}
}

View File

@@ -120,7 +120,7 @@ namespace System.Reflection {
var pi = GetIndexParameters ();
if (pi.Length > 0) {
sbName.Append (" [");
ParameterInfo.FormatParameters (sbName, pi, 0, serialization);
MonoParameterInfo.FormatParameters (sbName, pi, 0, serialization);
sbName.Append ("]");
}
@@ -274,7 +274,7 @@ namespace System.Reflection {
var dest = new ParameterInfo [length];
for (int i = 0; i < length; ++i) {
dest [i] = ParameterInfo.New (src [i], this);
dest [i] = MonoParameterInfo.New (src [i], this);
}
return dest;
}
@@ -359,16 +359,7 @@ namespace System.Reflection {
}
getterType = getterDelegateType.MakeGenericType (typeVector);
#if MOBILE
// with Silverlight a coreclr failure (e.g. Transparent caller creating a delegate on a Critical method)
// would normally throw an ArgumentException, so we set throwOnBindFailure to false and check for a null
// delegate that we can transform into a MethodAccessException
getterDelegate = Delegate.CreateDelegate (getterType, method, false);
if (getterDelegate == null)
throw new MethodAccessException ();
#else
getterDelegate = Delegate.CreateDelegate (getterType, method);
#endif
adapterFrame = typeof (MonoProperty).GetMethod (frameName, BindingFlags.Static | BindingFlags.NonPublic);
adapterFrame = adapterFrame.MakeGenericMethod (typeVector);
return (GetterAdapter)Delegate.CreateDelegate (typeof (GetterAdapter), getterDelegate, adapterFrame, true);
@@ -381,9 +372,9 @@ namespace System.Reflection {
#if !FULL_AOT_RUNTIME
if (cached_getter == null) {
MethodInfo method = GetGetMethod (true);
if (method == null)
throw new ArgumentException ($"Get Method not found for '{Name}'");
if (!DeclaringType.IsValueType && !method.ContainsGenericParameters) { //FIXME find a way to build an invoke delegate for value types.
if (method == null)
throw new ArgumentException ("Get Method not found for '" + Name + "'");
cached_getter = CreateGetterDelegate (method);
// The try-catch preserves the .Invoke () behaviour
try {
@@ -411,7 +402,7 @@ namespace System.Reflection {
MethodInfo method = GetGetMethod (true);
if (method == null)
throw new ArgumentException ("Get Method not found for '" + Name + "'");
throw new ArgumentException ($"Get Method not found for '{Name}'");
try {
if (index == null || index.Length == 0)
@@ -462,5 +453,29 @@ namespace System.Reflection {
public override IList<CustomAttributeData> GetCustomAttributesData () {
return CustomAttributeData.GetCustomAttributes (this);
}
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoProperty> (other);
public override int MetadataToken {
get {
return get_metadata_token (this);
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern int get_metadata_token (MonoProperty monoProperty);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern PropertyInfo internal_from_handle_type (IntPtr event_handle, IntPtr type_handle);
internal static PropertyInfo GetPropertyFromHandle (Mono.RuntimePropertyHandle handle, RuntimeTypeHandle reflectedType)
{
if (handle.Value == IntPtr.Zero)
throw new ArgumentException ("The handle is invalid.");
PropertyInfo pi = internal_from_handle_type (handle.Value, reflectedType.Value);
if (pi == null)
throw new ArgumentException ("The property handle and the type handle are incompatible.");
return pi;
}
}
}

View File

@@ -1,317 +0,0 @@
// System.Reflection.ParameterInfo
//
// Authors:
// Sean MacIsaac (macisaac@ximian.com)
// Marek Safar (marek.safar@gmail.com)
//
// (C) 2001 Ximian, Inc.
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
// Copyright 2013 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !FULL_AOT_RUNTIME
using System.Reflection.Emit;
#endif
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
namespace System.Reflection
{
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_ParameterInfo))]
[Serializable]
[ClassInterfaceAttribute (ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
public partial class ParameterInfo : ICustomAttributeProvider
#if !MOBILE
, _ParameterInfo
#endif
, IObjectReference
{
protected Type ClassImpl;
protected object DefaultValueImpl;
protected MemberInfo MemberImpl;
protected string NameImpl;
protected int PositionImpl;
protected ParameterAttributes AttrsImpl;
internal MarshalAsAttribute marshalAs;
protected ParameterInfo () {
}
public override string ToString() => ClassImpl.FormatTypeName() + " " + Name;
internal static void FormatParameters (StringBuilder sb, ParameterInfo[] p, CallingConventions callingConvention, bool serialization)
{
for (int i = 0; i < p.Length; ++i) {
if (i > 0)
sb.Append (", ");
Type t = p[i].ParameterType;
string typeName = t.FormatTypeName (serialization);
// Legacy: Why use "ByRef" for by ref parameters? What language is this?
// VB uses "ByRef" but it should precede (not follow) the parameter name.
// Why don't we just use "&"?
if (t.IsByRef && !serialization) {
sb.Append (typeName.TrimEnd (new char[] { '&' }));
sb.Append (" ByRef");
} else {
sb.Append (typeName);
}
}
if ((callingConvention & CallingConventions.VarArgs) != 0) {
if (p.Length > 0)
sb.Append (", ");
sb.Append ("...");
}
}
public virtual Type ParameterType {
get {return ClassImpl;}
}
public virtual ParameterAttributes Attributes {
get {return AttrsImpl;}
}
public bool IsIn {
get {
return (Attributes & ParameterAttributes.In) != 0;
}
}
#if FEATURE_USE_LCID
public bool IsLcid {
get {
return (Attributes & ParameterAttributes.Lcid) != 0;
}
}
#endif
public bool IsOptional {
get {
return (Attributes & ParameterAttributes.Optional) != 0;
}
}
public bool IsOut {
get {
return (Attributes & ParameterAttributes.Out) != 0;
}
}
public bool IsRetval {
get {
return (Attributes & ParameterAttributes.Retval) != 0;
}
}
public virtual MemberInfo Member {
get {return MemberImpl;}
}
public virtual string Name {
get {return NameImpl;}
}
public virtual int Position {
get {return PositionImpl;}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern int GetMetadataToken ();
internal object[] GetPseudoCustomAttributes () {
int count = 0;
if (IsIn)
count ++;
if (IsOut)
count ++;
if (IsOptional)
count ++;
if (marshalAs != null)
count ++;
if (count == 0)
return null;
object[] attrs = new object [count];
count = 0;
if (IsIn)
attrs [count ++] = new InAttribute ();
if (IsOptional)
attrs [count ++] = new OptionalAttribute ();
if (IsOut)
attrs [count ++] = new OutAttribute ();
if (marshalAs != null)
attrs [count ++] = marshalAs.Copy ();
return attrs;
}
internal CustomAttributeData[] GetPseudoCustomAttributesData ()
{
int count = 0;
if (IsIn)
count++;
if (IsOut)
count++;
if (IsOptional)
count++;
if (marshalAs != null)
count++;
if (count == 0)
return null;
CustomAttributeData[] attrsData = new CustomAttributeData [count];
count = 0;
if (IsIn)
attrsData [count++] = new CustomAttributeData ((typeof (InAttribute)).GetConstructor (Type.EmptyTypes));
if (IsOptional)
attrsData [count++] = new CustomAttributeData ((typeof (OptionalAttribute)).GetConstructor (Type.EmptyTypes));
if (IsOut)
attrsData [count++] = new CustomAttributeData ((typeof (OutAttribute)).GetConstructor (Type.EmptyTypes));
if (marshalAs != null) {
var ctorArgs = new CustomAttributeTypedArgument[] { new CustomAttributeTypedArgument (typeof (UnmanagedType), marshalAs.Value) };
attrsData [count++] = new CustomAttributeData (
(typeof (MarshalAsAttribute)).GetConstructor (new[] { typeof( UnmanagedType) }),
ctorArgs,
EmptyArray<CustomAttributeNamedArgument>.Value);//FIXME Get named params
}
return attrsData;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Type[] GetTypeModifiers (bool optional);
internal object GetDefaultValueImpl ()
{
return DefaultValueImpl;
}
public virtual IEnumerable<CustomAttributeData> CustomAttributes {
get { return GetCustomAttributesData (); }
}
public virtual bool HasDefaultValue {
get { throw new NotImplementedException (); }
}
#if !MOBILE
void _ParameterInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
}
void _ParameterInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException ();
}
void _ParameterInfo.GetTypeInfoCount (out uint pcTInfo)
{
throw new NotImplementedException ();
}
void _ParameterInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams,
IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException ();
}
#endif
public virtual object DefaultValue {
get { throw new NotImplementedException (); }
}
public virtual object RawDefaultValue {
get { throw new NotImplementedException (); }
}
public virtual int MetadataToken {
get { return 0x8000000; }
}
public virtual object[] GetCustomAttributes (bool inherit)
{
return new object [0];
}
public virtual object[] GetCustomAttributes (Type attributeType, bool inherit)
{
return new object [0];
}
public object GetRealObject (StreamingContext context)
{
throw new NotImplementedException ();
}
public virtual bool IsDefined( Type attributeType, bool inherit) {
return false;
}
public virtual Type[] GetRequiredCustomModifiers () {
return new Type [0];
}
public virtual Type[] GetOptionalCustomModifiers () {
return new Type [0];
}
public virtual IList<CustomAttributeData> GetCustomAttributesData () {
throw new NotImplementedException ();
}
#if !FULL_AOT_RUNTIME
internal static ParameterInfo New (ParameterBuilder pb, Type type, MemberInfo member, int position)
{
return new MonoParameterInfo (pb, type, member, position);
}
#endif
internal static ParameterInfo New (ParameterInfo pinfo, Type type, MemberInfo member, int position)
{
return new MonoParameterInfo (pinfo, type, member, position);
}
internal static ParameterInfo New (ParameterInfo pinfo, MemberInfo member)
{
return new MonoParameterInfo (pinfo, member);
}
internal static ParameterInfo New (Type type, MemberInfo member, MarshalAsAttribute marshalAs)
{
return new MonoParameterInfo (type, member, marshalAs);
}
}
}

View File

@@ -1,213 +0,0 @@
//
// System.Reflection/PropertyInfo.cs
//
// Author:
// Paolo Molaro (lupus@ximian.com)
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace System.Reflection {
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_PropertyInfo))]
[Serializable]
[ClassInterface(ClassInterfaceType.None)]
#if MOBILE
public abstract class PropertyInfo : MemberInfo {
#else
public abstract class PropertyInfo : MemberInfo, _PropertyInfo {
#endif
public abstract PropertyAttributes Attributes { get; }
public abstract bool CanRead { get; }
public abstract bool CanWrite { get; }
public virtual MethodInfo GetMethod {
get { return GetGetMethod(true); }
}
public virtual MethodInfo SetMethod {
get { return GetSetMethod(true); }
}
public bool IsSpecialName {
get {return (Attributes & PropertyAttributes.SpecialName) != 0;}
}
public override MemberTypes MemberType {
get {return MemberTypes.Property;}
}
public abstract Type PropertyType { get; }
protected PropertyInfo () { }
public MethodInfo[] GetAccessors ()
{
return GetAccessors (false);
}
public abstract MethodInfo[] GetAccessors (bool nonPublic);
public MethodInfo GetGetMethod()
{
return GetGetMethod (false);
}
public abstract MethodInfo GetGetMethod(bool nonPublic);
public abstract ParameterInfo[] GetIndexParameters();
public MethodInfo GetSetMethod()
{
return GetSetMethod (false);
}
public abstract MethodInfo GetSetMethod (bool nonPublic);
[DebuggerHidden]
[DebuggerStepThrough]
public virtual object GetValue (object obj, object[] index)
{
return GetValue(obj, BindingFlags.Default, null, index, null);
}
[DebuggerHidden]
[DebuggerStepThrough]
public object GetValue (object obj)
{
return GetValue(obj, BindingFlags.Default, null, null, null);
}
public abstract object GetValue (object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture);
[DebuggerHidden]
[DebuggerStepThrough]
public virtual void SetValue (object obj, object value, object[] index)
{
SetValue (obj, value, BindingFlags.Default, null, index, null);
}
[DebuggerHidden]
[DebuggerStepThrough]
public void SetValue (object obj, object value)
{
SetValue (obj, value, BindingFlags.Default, null, null, null);
}
public abstract void SetValue (object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture);
public virtual Type[] GetOptionalCustomModifiers () {
return Type.EmptyTypes;
}
public virtual Type[] GetRequiredCustomModifiers () {
return Type.EmptyTypes;
}
static NotImplementedException CreateNIE ()
{
return new NotImplementedException ();
}
public virtual object GetConstantValue () {
throw CreateNIE ();
}
public virtual object GetRawConstantValue() {
throw CreateNIE ();
}
public override bool Equals (object obj)
{
return obj == (object) this;
}
public override int GetHashCode ()
{
return base.GetHashCode ();
}
public static bool operator == (PropertyInfo left, PropertyInfo right)
{
if ((object)left == (object)right)
return true;
if ((object)left == null ^ (object)right == null)
return false;
return left.Equals (right);
}
public static bool operator != (PropertyInfo left, PropertyInfo right)
{
if ((object)left == (object)right)
return false;
if ((object)left == null ^ (object)right == null)
return true;
return !left.Equals (right);
}
#if !MOBILE
void _PropertyInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
}
Type _PropertyInfo.GetType ()
{
// Required or object::GetType becomes virtual final
return base.GetType ();
}
void _PropertyInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException ();
}
void _PropertyInfo.GetTypeInfoCount (out uint pcTInfo)
{
throw new NotImplementedException ();
}
void _PropertyInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException ();
}
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern PropertyInfo internal_from_handle_type (IntPtr event_handle, IntPtr type_handle);
internal static PropertyInfo GetPropertyFromHandle (Mono.RuntimePropertyHandle handle, RuntimeTypeHandle reflectedType)
{
if (handle.Value == IntPtr.Zero)
throw new ArgumentException ("The handle is invalid.");
PropertyInfo pi = internal_from_handle_type (handle.Value, reflectedType.Value);
if (pi == null)
throw new ArgumentException ("The property handle and the type handle are incompatible.");
return pi;
}
}
}