9 [__DynamicallyInvokable]
15 [__DynamicallyInvokable]
19 [__DynamicallyInvokable]
23 [__DynamicallyInvokable]
27 [__DynamicallyInvokable]
31 [__DynamicallyInvokable]
35 [__DynamicallyInvokable]
40 [__DynamicallyInvokable]
45 [__DynamicallyInvokable]
49 [__DynamicallyInvokable]
54 [__DynamicallyInvokable]
57 [__DynamicallyInvokable]
65 internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
67 return GetCustomAttribute(parameter.MetadataToken, parameter.GetRuntimeModule());
71 internal static bool IsDefined(RuntimeParameterInfo parameter)
73 return GetCustomAttribute(parameter) !=
null;
77 internal static Attribute GetCustomAttribute(RuntimeFieldInfo field)
79 return GetCustomAttribute(field.MetadataToken, field.GetRuntimeModule());
83 internal static bool IsDefined(RuntimeFieldInfo field)
85 return GetCustomAttribute(field) !=
null;
89 internal static Attribute GetCustomAttribute(
int token, RuntimeModule scope)
91 int sizeParamIndex = 0;
93 string marshalType =
null;
94 string marshalCookie =
null;
95 string safeArrayUserDefinedSubType =
null;
96 int iidParamIndex = 0;
97 ConstArray fieldMarshal = ModuleHandle.GetMetadataImport(scope.GetNativeHandle()).GetFieldMarshal(token);
98 if (fieldMarshal.Length == 0)
102 MetadataImport.GetMarshalAs(fieldMarshal, out
UnmanagedType unmanagedType, out
VarEnum safeArraySubType, out safeArrayUserDefinedSubType, out
UnmanagedType arraySubType, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie, out iidParamIndex);
103 RuntimeType safeArrayUserDefinedSubType2 = (safeArrayUserDefinedSubType ==
null || safeArrayUserDefinedSubType.Length == 0) ?
null : RuntimeTypeHandle.GetTypeByNameUsingCARules(safeArrayUserDefinedSubType, scope);
104 RuntimeType marshalTypeRef =
null;
107 marshalTypeRef = ((marshalType ==
null) ?
null : RuntimeTypeHandle.GetTypeByNameUsingCARules(marshalType, scope));
109 catch (TypeLoadException)
112 return new MarshalAsAttribute(unmanagedType, safeArraySubType, safeArrayUserDefinedSubType2, arraySubType, (
short)sizeParamIndex, sizeConst, marshalType, marshalTypeRef, marshalCookie, iidParamIndex);
115 internal MarshalAsAttribute(
UnmanagedType val,
VarEnum safeArraySubType, RuntimeType safeArrayUserDefinedSubType,
UnmanagedType arraySubType,
short sizeParamIndex,
int sizeConst,
string marshalType, RuntimeType marshalTypeRef,
string marshalCookie,
int iidParamIndex)
131 [__DynamicallyInvokable]
134 _val = unmanagedType;
139 [__DynamicallyInvokable]
string MarshalCookie
Provides additional information to a custom marshaler.
short SizeParamIndex
Indicates the zero-based parameter that contains the count of array elements, similar to size_is in C...
VarEnum SafeArraySubType
Indicates the element type of the F:System.Runtime.InteropServices.UnmanagedType.SafeArray.
Represents the base class for custom attributes.
Type MarshalTypeRef
Implements F:System.Runtime.InteropServices.MarshalAsAttribute.MarshalType as a type.
MarshalAsAttribute(UnmanagedType unmanagedType)
Initializes a new instance of the T:System.Runtime.InteropServices.MarshalAsAttribute class with the ...
MarshalAsAttribute(short unmanagedType)
Initializes a new instance of the T:System.Runtime.InteropServices.MarshalAsAttribute class with the ...
Indicates how to marshal the data between managed and unmanaged code.
UnmanagedType
Identifies how to marshal parameters or fields to unmanaged code.
int SizeConst
Indicates the number of elements in the fixed-length array or the number of characters (not bytes) in...
Represents type declarations: class types, interface types, array types, value types,...
Type SafeArrayUserDefinedSubType
Indicates the user-defined element type of the F:System.Runtime.InteropServices.UnmanagedType....
AttributeTargets
Specifies the application elements on which it is valid to apply an attribute.
UnmanagedType Value
Gets the T:System.Runtime.InteropServices.UnmanagedType value the data is to be marshaled as.
VarEnum
Indicates how to marshal the array elements when an array is marshaled from managed to unmanaged code...
UnmanagedType ArraySubType
Specifies the element type of the unmanaged F:System.Runtime.InteropServices.UnmanagedType....
Attribute()
Initializes a new instance of the T:System.Attribute class.
int IidParameterIndex
Specifies the parameter index of the unmanaged iid_is attribute used by COM.
string MarshalType
Specifies the fully qualified name of a custom marshaler.