Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomAttribute.cs
Go to the documentation of this file.
4
5namespace System.Reflection;
6
7internal static class CustomAttribute
8{
9 private static readonly RuntimeType Type_RuntimeType = (RuntimeType)typeof(RuntimeType);
10
11 private static readonly RuntimeType Type_Type = (RuntimeType)typeof(Type);
12
13 internal static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
14 {
15 if ((object)type.GetElementType() != null)
16 {
17 return false;
18 }
20 {
21 return true;
22 }
23 if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType))
24 {
25 return true;
26 }
27 if (!inherit)
28 {
29 return false;
30 }
31 type = type.BaseType as RuntimeType;
32 while ((object)type != null)
33 {
34 if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType, 0, inherit))
35 {
36 return true;
37 }
38 type = type.BaseType as RuntimeType;
39 }
40 return false;
41 }
42
43 internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
44 {
45 if (PseudoCustomAttribute.IsDefined(method, caType))
46 {
47 return true;
48 }
49 if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType))
50 {
51 return true;
52 }
53 if (!inherit)
54 {
55 return false;
56 }
57 method = method.GetParentDefinition();
58 while ((object)method != null)
59 {
60 if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, 0, inherit))
61 {
62 return true;
63 }
64 method = method.GetParentDefinition();
65 }
66 return false;
67 }
68
69 internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
70 {
71 return IsCustomAttributeDefined(ctor.GetRuntimeModule(), ctor.MetadataToken, caType);
72 }
73
74 internal static bool IsDefined(RuntimePropertyInfo property, RuntimeType caType)
75 {
76 return IsCustomAttributeDefined(property.GetRuntimeModule(), property.MetadataToken, caType);
77 }
78
79 internal static bool IsDefined(RuntimeEventInfo e, RuntimeType caType)
80 {
82 }
83
84 internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
85 {
86 if (PseudoCustomAttribute.IsDefined(field, caType))
87 {
88 return true;
89 }
90 return IsCustomAttributeDefined(field.GetRuntimeModule(), field.MetadataToken, caType);
91 }
92
93 internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType)
94 {
95 if (PseudoCustomAttribute.IsDefined(parameter, caType))
96 {
97 return true;
98 }
99 return IsCustomAttributeDefined(parameter.GetRuntimeModule(), parameter.MetadataToken, caType);
100 }
101
102 internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
103 {
105 }
106
107 internal static bool IsDefined(RuntimeModule module, RuntimeType caType)
108 {
109 return IsCustomAttributeDefined(module, module.MetadataToken, caType);
110 }
111
112 internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
113 {
114 if ((object)type.GetElementType() != null)
115 {
116 if (!caType.IsValueType)
117 {
118 return CreateAttributeArrayHelper(caType, 0);
119 }
120 return Array.Empty<object>();
121 }
122 if (type.IsGenericType && !type.IsGenericTypeDefinition)
123 {
124 type = type.GetGenericTypeDefinition() as RuntimeType;
125 }
128 if (!inherit || (caType.IsSealed && !GetAttributeUsage(caType).Inherited))
129 {
130 object[] customAttributes = GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, pcas.Count, caType);
131 if (pcas.Count > 0)
132 {
133 pcas.CopyTo(customAttributes, customAttributes.Length - pcas.Count);
134 }
135 return customAttributes;
136 }
137 RuntimeType.ListBuilder<object> attributes = default(RuntimeType.ListBuilder<object>);
138 bool mustBeInheritable = false;
139 RuntimeType elementType = ((caType.IsValueType || caType.ContainsGenericParameters) ? ((RuntimeType)typeof(object)) : caType);
140 for (int i = 0; i < pcas.Count; i++)
141 {
142 attributes.Add(pcas[i]);
143 }
144 while (type != (RuntimeType)typeof(object) && type != null)
145 {
146 AddCustomAttributes(ref attributes, type.GetRuntimeModule(), type.MetadataToken, caType, mustBeInheritable, attributes);
147 mustBeInheritable = true;
148 type = type.BaseType as RuntimeType;
149 }
150 object[] array = CreateAttributeArrayHelper(elementType, attributes.Count);
151 for (int j = 0; j < attributes.Count; j++)
152 {
153 array[j] = attributes[j];
154 }
155 return array;
156 }
157
158 internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
159 {
160 if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
161 {
163 }
165 PseudoCustomAttribute.GetCustomAttributes(method, caType, ref pcas);
166 if (!inherit || (caType.IsSealed && !GetAttributeUsage(caType).Inherited))
167 {
168 object[] customAttributes = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, pcas.Count, caType);
169 if (pcas.Count > 0)
170 {
171 pcas.CopyTo(customAttributes, customAttributes.Length - pcas.Count);
172 }
173 return customAttributes;
174 }
175 RuntimeType.ListBuilder<object> attributes = default(RuntimeType.ListBuilder<object>);
176 bool mustBeInheritable = false;
177 RuntimeType elementType = ((caType.IsValueType || caType.ContainsGenericParameters) ? ((RuntimeType)typeof(object)) : caType);
178 for (int i = 0; i < pcas.Count; i++)
179 {
180 attributes.Add(pcas[i]);
181 }
182 while (method != null)
183 {
184 AddCustomAttributes(ref attributes, method.GetRuntimeModule(), method.MetadataToken, caType, mustBeInheritable, attributes);
185 mustBeInheritable = true;
186 method = method.GetParentDefinition();
187 }
188 object[] array = CreateAttributeArrayHelper(elementType, attributes.Count);
189 for (int j = 0; j < attributes.Count; j++)
190 {
191 array[j] = attributes[j];
192 }
193 return array;
194 }
195
196 internal static object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
197 {
198 return GetCustomAttributes(ctor.GetRuntimeModule(), ctor.MetadataToken, 0, caType);
199 }
200
201 internal static object[] GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)
202 {
203 return GetCustomAttributes(property.GetRuntimeModule(), property.MetadataToken, 0, caType);
204 }
205
206 internal static object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caType)
207 {
208 return GetCustomAttributes(e.GetRuntimeModule(), e.MetadataToken, 0, caType);
209 }
210
211 internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
212 {
214 PseudoCustomAttribute.GetCustomAttributes(field, caType, ref pcas);
215 object[] customAttributes = GetCustomAttributes(field.GetRuntimeModule(), field.MetadataToken, pcas.Count, caType);
216 if (pcas.Count > 0)
217 {
218 pcas.CopyTo(customAttributes, customAttributes.Length - pcas.Count);
219 }
220 return customAttributes;
221 }
222
223 internal static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
224 {
226 PseudoCustomAttribute.GetCustomAttributes(parameter, caType, ref pcas);
227 object[] customAttributes = GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, pcas.Count, caType);
228 if (pcas.Count > 0)
229 {
230 pcas.CopyTo(customAttributes, customAttributes.Length - pcas.Count);
231 }
232 return customAttributes;
233 }
234
235 internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
236 {
237 int token = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
238 return GetCustomAttributes(assembly.ManifestModule as RuntimeModule, token, 0, caType);
239 }
240
241 internal static object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType)
242 {
243 return GetCustomAttributes(module, module.MetadataToken, 0, caType);
244 }
245
246 private static bool IsCustomAttributeDefined(RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType)
247 {
248 return IsCustomAttributeDefined(decoratedModule, decoratedMetadataToken, attributeFilterType, 0, mustBeInheritable: false);
249 }
250
251 private static bool IsCustomAttributeDefined(RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, int attributeCtorToken, bool mustBeInheritable)
252 {
253 MetadataImport scope = decoratedModule.MetadataImport;
254 scope.EnumCustomAttributes(decoratedMetadataToken, out var result);
255 if (result.Length == 0)
256 {
257 return false;
258 }
259 CustomAttributeRecord customAttributeRecord = default(CustomAttributeRecord);
260 if ((object)attributeFilterType != null)
261 {
262 RuntimeType.ListBuilder<object> derivedAttributes = default(RuntimeType.ListBuilder<object>);
263 for (int i = 0; i < result.Length; i++)
264 {
265 scope.GetCustomAttributeProps(result[i], out customAttributeRecord.tkCtor.Value, out customAttributeRecord.blob);
266 if (FilterCustomAttributeRecord(customAttributeRecord.tkCtor, in scope, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, ref derivedAttributes, out var _, out var _, out var _))
267 {
268 return true;
269 }
270 }
271 }
272 else
273 {
274 for (int j = 0; j < result.Length; j++)
275 {
276 scope.GetCustomAttributeProps(result[j], out customAttributeRecord.tkCtor.Value, out customAttributeRecord.blob);
277 if ((int)customAttributeRecord.tkCtor == attributeCtorToken)
278 {
279 return true;
280 }
281 }
282 }
283 return false;
284 }
285
286 private static object[] GetCustomAttributes(RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType)
287 {
288 RuntimeType.ListBuilder<object> attributes = default(RuntimeType.ListBuilder<object>);
289 AddCustomAttributes(ref attributes, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable: false, default(RuntimeType.ListBuilder<object>));
290 RuntimeType elementType = (((object)attributeFilterType == null || attributeFilterType.IsValueType || attributeFilterType.ContainsGenericParameters) ? ((RuntimeType)typeof(object)) : attributeFilterType);
291 object[] array = CreateAttributeArrayHelper(elementType, attributes.Count + pcaCount);
292 for (int i = 0; i < attributes.Count; i++)
293 {
294 array[i] = attributes[i];
295 }
296 return array;
297 }
298
299 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2065:UnrecognizedReflectionPattern", Justification = "Linker guarantees presence of all the constructor parameters, property setters and fields which are accessed by any attribute instantiation which is present in the code linker has analyzed.As such the reflection usage in this method will never fail as those methods/fields will be present.")]
300 private unsafe static void AddCustomAttributes(ref RuntimeType.ListBuilder<object> attributes, RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, bool mustBeInheritable, RuntimeType.ListBuilder<object> derivedAttributes)
301 {
302 CustomAttributeRecord[] customAttributeRecords = RuntimeCustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);
303 if ((object)attributeFilterType == null && customAttributeRecords.Length == 0)
304 {
305 return;
306 }
307 MetadataImport scope = decoratedModule.MetadataImport;
308 for (int i = 0; i < customAttributeRecords.Length; i++)
309 {
310 ref CustomAttributeRecord reference = ref customAttributeRecords[i];
311 IntPtr blob = reference.blob.Signature;
312 IntPtr intPtr = (IntPtr)((byte*)(void*)blob + reference.blob.Length);
313 if (!FilterCustomAttributeRecord(reference.tkCtor, in scope, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, ref derivedAttributes, out var attributeType, out var ctorWithParameters, out var isVarArg))
314 {
315 continue;
316 }
317 RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, isVarArg);
318 object obj;
319 int namedArgs;
320 if (ctorWithParameters != null)
321 {
322 obj = CreateCaObject(decoratedModule, attributeType, ctorWithParameters, ref blob, intPtr, out namedArgs);
323 }
324 else
325 {
326 obj = attributeType.CreateInstanceDefaultCtor(publicOnly: false, wrapExceptions: false);
327 if ((int)((byte*)(void*)intPtr - (byte*)(void*)blob) == 0)
328 {
329 namedArgs = 0;
330 }
331 else
332 {
333 int num = Unsafe.ReadUnaligned<int>((void*)blob);
334 if ((num & 0xFFFF) != 1)
335 {
337 }
338 namedArgs = num >> 16;
339 blob = (IntPtr)((byte*)(void*)blob + 4);
340 }
341 }
342 for (int j = 0; j < namedArgs; j++)
343 {
344 GetPropertyOrFieldData(decoratedModule, ref blob, intPtr, out var name, out var isProperty, out var type, out var value);
345 try
346 {
347 if (isProperty)
348 {
349 if ((object)type == null && value != null)
350 {
351 type = (RuntimeType)value.GetType();
352 if (type == Type_RuntimeType)
353 {
354 type = Type_Type;
355 }
356 }
357 PropertyInfo propertyInfo = (((object)type == null) ? attributeType.GetProperty(name) : attributeType.GetProperty(name, type, Type.EmptyTypes));
358 if ((object)propertyInfo == null)
359 {
361 }
362 MethodInfo setMethod = propertyInfo.GetSetMethod(nonPublic: true);
363 if (setMethod.IsPublic)
364 {
365 setMethod.Invoke(obj, BindingFlags.Default, null, new object[1] { value }, null);
366 }
367 }
368 else
369 {
370 FieldInfo field = attributeType.GetField(name);
371 field.SetValue(obj, value, BindingFlags.Default, Type.DefaultBinder, null);
372 }
373 }
374 catch (Exception inner)
375 {
377 }
378 }
379 if (blob != intPtr)
380 {
382 }
383 attributes.Add(obj);
384 }
385 }
386
387 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Module.ResolveMethod and Module.ResolveType are marked as RequiresUnreferencedCode because they rely on tokenswhich are not guaranteed to be stable across trimming. So if somebody hardcodes a token it could break.The usage here is not like that as all these tokens come from existing metadata loaded from some ILand so trimming has no effect (the tokens are read AFTER trimming occured).")]
388 private static bool FilterCustomAttributeRecord(MetadataToken caCtorToken, in MetadataImport scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, ref RuntimeType.ListBuilder<object> derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctorWithParameters, out bool isVarArg)
389 {
390 ctorWithParameters = null;
391 isVarArg = false;
392 attributeType = decoratedModule.ResolveType(scope.GetParentToken(caCtorToken), null, null) as RuntimeType;
393 if (!attributeFilterType.IsAssignableFrom(attributeType))
394 {
395 return false;
396 }
397 if (!AttributeUsageCheck(attributeType, mustBeInheritable, ref derivedAttributes))
398 {
399 return false;
400 }
401 if ((attributeType.Attributes & TypeAttributes.WindowsRuntime) == TypeAttributes.WindowsRuntime)
402 {
403 return false;
404 }
405 ConstArray methodSignature = scope.GetMethodSignature(caCtorToken);
406 isVarArg = (methodSignature[0] & 5) != 0;
407 if (methodSignature[1] != 0)
408 {
409 if (attributeType.IsGenericType)
410 {
411 ctorWithParameters = decoratedModule.ResolveMethod(caCtorToken, attributeType.GenericTypeArguments, null).MethodHandle.GetMethodInfo();
412 }
413 else
414 {
415 ctorWithParameters = new ModuleHandle(decoratedModule).ResolveMethodHandle(caCtorToken).GetMethodInfo();
416 }
417 }
418 MetadataToken metadataToken = default(MetadataToken);
419 if (decoratedToken.IsParamDef)
420 {
421 metadataToken = new MetadataToken(scope.GetParentToken(decoratedToken));
422 metadataToken = new MetadataToken(scope.GetParentToken(metadataToken));
423 }
424 else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef)
425 {
426 metadataToken = new MetadataToken(scope.GetParentToken(decoratedToken));
427 }
428 else if (decoratedToken.IsTypeDef)
429 {
430 metadataToken = decoratedToken;
431 }
432 else if (decoratedToken.IsGenericPar)
433 {
434 metadataToken = new MetadataToken(scope.GetParentToken(decoratedToken));
435 if (metadataToken.IsMethodDef)
436 {
437 metadataToken = new MetadataToken(scope.GetParentToken(metadataToken));
438 }
439 }
440 RuntimeTypeHandle rth = (metadataToken.IsTypeDef ? decoratedModule.ModuleHandle.ResolveTypeHandle(metadataToken) : default(RuntimeTypeHandle));
441 RuntimeTypeHandle rth2 = attributeType.TypeHandle;
442 bool result = RuntimeMethodHandle.IsCAVisibleFromDecoratedType(new QCallTypeHandle(ref rth2), (ctorWithParameters != null) ? ctorWithParameters.Value : RuntimeMethodHandleInternal.EmptyHandle, new QCallTypeHandle(ref rth), new QCallModule(ref decoratedModule)) != Interop.BOOL.FALSE;
443 GC.KeepAlive(ctorWithParameters);
444 return result;
445 }
446
447 private static bool AttributeUsageCheck(RuntimeType attributeType, bool mustBeInheritable, ref RuntimeType.ListBuilder<object> derivedAttributes)
448 {
449 AttributeUsageAttribute attributeUsageAttribute = null;
450 if (mustBeInheritable)
451 {
452 attributeUsageAttribute = GetAttributeUsage(attributeType);
453 if (!attributeUsageAttribute.Inherited)
454 {
455 return false;
456 }
457 }
458 if (derivedAttributes.Count == 0)
459 {
460 return true;
461 }
462 for (int i = 0; i < derivedAttributes.Count; i++)
463 {
464 if (derivedAttributes[i].GetType() == attributeType)
465 {
466 if (attributeUsageAttribute == null)
467 {
468 attributeUsageAttribute = GetAttributeUsage(attributeType);
469 }
470 return attributeUsageAttribute.AllowMultiple;
471 }
472 }
473 return true;
474 }
475
476 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Module.ResolveType is marked as RequiresUnreferencedCode because it relies on tokenswhich are not guaranteed to be stable across trimming. So if somebody hardcodes a token it could break.The usage here is not like that as all these tokens come from existing metadata loaded from some ILand so trimming has no effect (the tokens are read AFTER trimming occured).")]
477 internal static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)
478 {
479 RuntimeModule runtimeModule = decoratedAttribute.GetRuntimeModule();
480 MetadataImport metadataImport = runtimeModule.MetadataImport;
481 CustomAttributeRecord[] customAttributeRecords = RuntimeCustomAttributeData.GetCustomAttributeRecords(runtimeModule, decoratedAttribute.MetadataToken);
482 AttributeUsageAttribute attributeUsageAttribute = null;
483 for (int i = 0; i < customAttributeRecords.Length; i++)
484 {
485 ref CustomAttributeRecord reference = ref customAttributeRecords[i];
486 RuntimeType runtimeType = runtimeModule.ResolveType(metadataImport.GetParentToken(reference.tkCtor), null, null) as RuntimeType;
487 if (!(runtimeType != (RuntimeType)typeof(AttributeUsageAttribute)))
488 {
489 if (attributeUsageAttribute != null)
490 {
491 throw new FormatException(SR.Format(SR.Format_AttributeUsage, runtimeType));
492 }
493 ParseAttributeUsageAttribute(reference.blob, out var targets, out var inherited, out var allowMultiple);
494 attributeUsageAttribute = new AttributeUsageAttribute(targets, allowMultiple, inherited);
495 }
496 }
497 return attributeUsageAttribute ?? AttributeUsageAttribute.Default;
498 }
499
500 [MethodImpl(MethodImplOptions.InternalCall)]
501 private static extern void _ParseAttributeUsageAttribute(IntPtr pCa, int cCa, out int targets, out bool inherited, out bool allowMultiple);
502
503 private static void ParseAttributeUsageAttribute(ConstArray ca, out AttributeTargets targets, out bool inherited, out bool allowMultiple)
504 {
505 _ParseAttributeUsageAttribute(ca.Signature, ca.Length, out var targets2, out inherited, out allowMultiple);
506 targets = (AttributeTargets)targets2;
507 }
508
509 [MethodImpl(MethodImplOptions.InternalCall)]
510 private unsafe static extern object _CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, byte** ppBlob, byte* pEndBlob, int* pcNamedArgs);
511
512 private unsafe static object CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs)
513 {
514 byte* ptr = (byte*)(void*)blob;
515 byte* pEndBlob = (byte*)(void*)blobEnd;
516 System.Runtime.CompilerServices.Unsafe.SkipInit(out int num);
517 object result = _CreateCaObject(module, type, ctor, &ptr, pEndBlob, &num);
518 blob = (IntPtr)ptr;
519 namedArgs = num;
520 return result;
521 }
522
523 [MethodImpl(MethodImplOptions.InternalCall)]
524 private unsafe static extern void _GetPropertyOrFieldData(RuntimeModule pModule, byte** ppBlobStart, byte* pBlobEnd, out string name, out bool bIsProperty, out RuntimeType type, out object value);
525
526 private unsafe static void GetPropertyOrFieldData(RuntimeModule module, ref IntPtr blobStart, IntPtr blobEnd, out string name, out bool isProperty, out RuntimeType type, out object value)
527 {
528 byte* ptr = (byte*)(void*)blobStart;
529 _GetPropertyOrFieldData(module, &ptr, (byte*)(void*)blobEnd, out name, out isProperty, out type, out value);
530 blobStart = (IntPtr)ptr;
531 }
532
533 private static object[] CreateAttributeArrayHelper(RuntimeType elementType, int elementCount)
534 {
535 if (elementCount == 0)
536 {
537 return elementType.GetEmptyArray();
538 }
539 return (object[])Array.CreateInstance(elementType, elementCount);
540 }
541}
static unsafe Array CreateInstance(Type elementType, int length)
Definition Array.cs:473
static readonly AttributeUsageAttribute Default
static void KeepAlive(object? obj)
Definition GC.cs:180
Definition GC.cs:8
static object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType)
static unsafe object CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs)
static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
static object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
static bool IsDefined(RuntimeEventInfo e, RuntimeType caType)
static unsafe object _CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, byte **ppBlob, byte *pEndBlob, int *pcNamedArgs)
static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType)
static bool IsCustomAttributeDefined(RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType)
static void ParseAttributeUsageAttribute(ConstArray ca, out AttributeTargets targets, out bool inherited, out bool allowMultiple)
static bool IsDefined(RuntimePropertyInfo property, RuntimeType caType)
static bool AttributeUsageCheck(RuntimeType attributeType, bool mustBeInheritable, ref RuntimeType.ListBuilder< object > derivedAttributes)
static bool IsDefined(RuntimeModule module, RuntimeType caType)
static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
static unsafe void _GetPropertyOrFieldData(RuntimeModule pModule, byte **ppBlobStart, byte *pBlobEnd, out string name, out bool bIsProperty, out RuntimeType type, out object value)
static object[] GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)
static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static object[] GetCustomAttributes(RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType)
static object[] CreateAttributeArrayHelper(RuntimeType elementType, int elementCount)
static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
static bool IsCustomAttributeDefined(RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, int attributeCtorToken, bool mustBeInheritable)
static object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caType)
static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
static void _ParseAttributeUsageAttribute(IntPtr pCa, int cCa, out int targets, out bool inherited, out bool allowMultiple)
static unsafe void AddCustomAttributes(ref RuntimeType.ListBuilder< object > attributes, RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, bool mustBeInheritable, RuntimeType.ListBuilder< object > derivedAttributes)
static bool FilterCustomAttributeRecord(MetadataToken caCtorToken, in MetadataImport scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, ref RuntimeType.ListBuilder< object > derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctorWithParameters, out bool isVarArg)
static readonly RuntimeType Type_RuntimeType
static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)
static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
static unsafe void GetPropertyOrFieldData(RuntimeModule module, ref IntPtr blobStart, IntPtr blobEnd, out string name, out bool isProperty, out RuntimeType type, out object value)
static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
static readonly RuntimeType Type_Type
void SetValue(object? obj, object? value)
Definition FieldInfo.cs:108
object? Invoke(object? obj, object?[]? parameters)
RuntimeMethodHandle MethodHandle
Definition MethodBase.cs:84
ModuleHandle ModuleHandle
Definition Module.cs:64
static bool IsDefined(RuntimeType type, RuntimeType caType)
static void GetCustomAttributes(RuntimeType type, RuntimeType caType, ref RuntimeType.ListBuilder< Attribute > pcas)
static int GetToken(RuntimeAssembly assembly)
static void CheckCanCreateInstance(Type declaringType, bool isVarArg)
static CustomAttributeRecord[] GetCustomAttributeRecords(RuntimeModule module, int targetToken)
override MethodInfo GetGenericMethodDefinition()
unsafe override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo typeInfo)
override int MetadataToken
override bool ContainsGenericParameters
RuntimeModule GetRuntimeModule()
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Format_AttributeUsage
Definition SR.cs:1316
static string RFLCT_InvalidPropFail
Definition SR.cs:1844
static string RFLCT_InvalidFieldFail
Definition SR.cs:1842
Definition SR.cs:7
bool IsValueType
Definition Type.cs:234
static Binder DefaultBinder
Definition Type.cs:298
static readonly Type[] EmptyTypes
Definition Type.cs:19
bool IsSealed
Definition Type.cs:179
RuntimeTypeHandle ResolveTypeHandle(int typeToken)
RuntimeMethodHandle ResolveMethodHandle(int methodToken)
void GetCustomAttributeProps(int customAttributeToken, out int constructorToken, out ConstArray signature)
void EnumCustomAttributes(int mdToken, out MetadataEnumResult result)
static RuntimeMethodHandleInternal EmptyHandle
static Interop.BOOL IsCAVisibleFromDecoratedType(QCallTypeHandle attrTypeHandle, RuntimeMethodHandleInternal attrCtor, QCallTypeHandle sourceTypeHandle, QCallModule sourceModule)
IRuntimeMethodInfo GetMethodInfo()