Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeParameterInfo.cs
Go to the documentation of this file.
3
4namespace System.Reflection;
5
6internal sealed class RuntimeParameterInfo : ParameterInfo
7{
9
11
12 private int m_tkParamDef;
13
15
17
18 private volatile bool m_nameIsCached;
19
20 private readonly bool m_noMetadata;
21
22 private bool m_noDefaultValue;
23
25
26 public override Type ParameterType
27 {
28 get
29 {
30 if (ClassImpl == null)
31 {
34 }
35 return ClassImpl;
36 }
37 }
38
39 public override string Name
40 {
41 get
42 {
43 if (!m_nameIsCached)
44 {
46 {
49 }
50 m_nameIsCached = true;
51 }
52 return NameImpl;
53 }
54 }
55
56 public override bool HasDefaultValue
57 {
58 get
59 {
61 {
62 return false;
63 }
66 }
67 }
68
69 public override object DefaultValue => GetDefaultValue(raw: false);
70
71 public override object RawDefaultValue => GetDefaultValue(raw: true);
72
73 public override int MetadataToken => m_tkParamDef;
74
80
86
88 {
89 returnParameter = null;
90 int num = sig.Arguments.Length;
91 ParameterInfo[] array = (fetchReturnParameter ? null : ((num == 0) ? Array.Empty<ParameterInfo>() : new ParameterInfo[num]));
93 int num2 = 0;
95 {
97 metadataImport.EnumParams(methodDef, out var result);
98 num2 = result.Length;
99 if (num2 > num + 1)
100 {
102 }
103 for (int i = 0; i < num2; i++)
104 {
105 int num3 = result[i];
106 metadataImport.GetParamDefProps(num3, out var sequence, out var attributes);
107 sequence--;
108 if (fetchReturnParameter && sequence == -1)
109 {
110 if (returnParameter != null)
111 {
113 }
115 }
116 else if (!fetchReturnParameter && sequence >= 0)
117 {
118 if (sequence >= num)
119 {
121 }
122 array[sequence] = new RuntimeParameterInfo(sig, metadataImport, num3, sequence, attributes, member);
123 }
124 }
125 }
127 {
128 if (returnParameter == null)
129 {
131 }
132 }
133 else if (num2 < array.Length + 1)
134 {
135 for (int j = 0; j < array.Length; j++)
136 {
137 if (array[j] == null)
138 {
140 }
141 }
142 }
143 return array;
144 }
145
146 internal void SetName(string name)
147 {
148 NameImpl = name;
149 }
150
151 internal void SetAttributes(ParameterAttributes attributes)
152 {
153 AttrsImpl = attributes;
154 }
155
161
163 {
164 MemberImpl = member;
165 m_originalMember = accessor.MemberImpl as MethodBase;
166 NameImpl = accessor.Name;
167 m_nameIsCached = true;
168 ClassImpl = accessor.ParameterType;
169 PositionImpl = accessor.Position;
170 AttrsImpl = accessor.Attributes;
171 m_tkParamDef = (System.Reflection.MetadataToken.IsNullToken(accessor.MetadataToken) ? 134217728 : accessor.MetadataToken);
172 m_scope = accessor.m_scope;
173 }
174
176 {
177 PositionImpl = position;
178 MemberImpl = member;
181 m_scope = scope;
182 AttrsImpl = attributes;
183 ClassImpl = null;
184 NameImpl = null;
185 }
186
187 internal RuntimeParameterInfo(MethodInfo owner, string name, Type parameterType, int position)
188 {
189 MemberImpl = owner;
190 NameImpl = name;
191 m_nameIsCached = true;
192 m_noMetadata = true;
194 PositionImpl = position;
196 m_tkParamDef = 134217728;
198 }
199
200 private object GetDefaultValue(bool raw)
201 {
202 if (m_noMetadata)
203 {
204 return null;
205 }
207 if (obj == DBNull.Value && base.IsOptional)
208 {
209 obj = Type.Missing;
210 }
211 return obj;
212 }
213
214 private object GetDefaultValueInternal(bool raw)
215 {
217 {
218 return DBNull.Value;
219 }
220 object obj = null;
222 {
223 if (raw)
224 {
226 if (customAttributeTypedArgument.ArgumentType != null)
227 {
228 return new DateTime((long)customAttributeTypedArgument.Value);
229 }
230 }
231 else
232 {
234 if (customAttributes != null && customAttributes.Length != 0)
235 {
237 }
238 }
239 }
241 {
242 obj = MdConstant.GetValue(m_scope, m_tkParamDef, ParameterType.GetTypeHandleInternal(), raw);
243 }
244 if (obj == DBNull.Value)
245 {
246 if (raw)
247 {
249 {
250 Type declaringType = customAttribute.Constructor.DeclaringType;
252 {
254 }
256 {
258 }
259 else if (declaringType.IsSubclassOf(s_CustomConstantAttributeType))
260 {
262 }
263 }
264 }
265 else
266 {
268 if (customAttributes2.Length != 0)
269 {
271 }
272 else
273 {
275 if (customAttributes2.Length != 0)
276 {
278 }
279 }
280 }
281 }
282 if (obj == DBNull.Value)
283 {
284 m_noDefaultValue = true;
285 }
286 return obj;
287 }
288
290 {
291 foreach (CustomAttributeNamedArgument namedArgument in attr.NamedArguments)
292 {
293 if (namedArgument.MemberInfo.Name.Equals("Value"))
294 {
295 return (decimal)namedArgument.TypedValue.Value;
296 }
297 }
298 ParameterInfo[] parameters = attr.Constructor.GetParameters();
300 if (parameters[2].ParameterType == typeof(uint))
301 {
302 int lo = (int)(uint)constructorArguments[4].Value;
303 int mid = (int)(uint)constructorArguments[3].Value;
304 int hi = (int)(uint)constructorArguments[2].Value;
305 byte b = (byte)constructorArguments[1].Value;
306 byte scale = (byte)constructorArguments[0].Value;
307 return new decimal(lo, mid, hi, b != 0, scale);
308 }
309 int lo2 = (int)constructorArguments[4].Value;
310 int mid2 = (int)constructorArguments[3].Value;
311 int hi2 = (int)constructorArguments[2].Value;
312 byte b2 = (byte)constructorArguments[1].Value;
313 byte scale2 = (byte)constructorArguments[0].Value;
314 return new decimal(lo2, mid2, hi2, b2 != 0, scale2);
315 }
316
318 {
319 foreach (CustomAttributeNamedArgument namedArgument in attr.NamedArguments)
320 {
321 if (namedArgument.MemberInfo.Name.Equals("Value"))
322 {
323 return new DateTime((long)namedArgument.TypedValue.Value);
324 }
325 }
326 return new DateTime((long)attr.ConstructorArguments[0].Value);
327 }
328
330 {
331 foreach (CustomAttributeNamedArgument namedArgument in attr.NamedArguments)
332 {
333 if (namedArgument.MemberInfo.Name.Equals("Value"))
334 {
335 return namedArgument.TypedValue.Value;
336 }
337 }
338 return DBNull.Value;
339 }
340
342 {
346 if (runtimeMethodInfo != null)
347 {
348 return runtimeMethodInfo.GetRuntimeModule();
349 }
350 if (runtimeConstructorInfo != null)
351 {
352 return runtimeConstructorInfo.GetRuntimeModule();
353 }
354 if (runtimePropertyInfo != null)
355 {
356 return runtimePropertyInfo.GetRuntimeModule();
357 }
358 return null;
359 }
360
362 {
363 if (m_signature != null)
364 {
366 }
367 return Type.EmptyTypes;
368 }
369
371 {
372 if (m_signature != null)
373 {
375 }
376 return Type.EmptyTypes;
377 }
378
379 public override object[] GetCustomAttributes(bool inherit)
380 {
382 {
383 return Array.Empty<object>();
384 }
386 }
387
388 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
389 {
390 if (attributeType == null)
391 {
392 throw new ArgumentNullException("attributeType");
393 }
395 {
396 return Array.Empty<object>();
397 }
398 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
399 if (runtimeType == null)
400 {
401 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
402 }
404 }
405
406 public override bool IsDefined(Type attributeType, bool inherit)
407 {
408 if (attributeType == null)
409 {
410 throw new ArgumentNullException("attributeType");
411 }
413 {
414 return false;
415 }
416 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
417 if (runtimeType == null)
418 {
419 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
420 }
422 }
423
428}
static readonly DBNull Value
Definition DBNull.cs:8
static IList< CustomAttributeData > GetCustomAttributes(MemberInfo target)
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
static unsafe object GetValue(MetadataImport scope, int token, RuntimeTypeHandle fieldTypeHandle, bool raw)
Definition MdConstant.cs:5
ParameterAttributes AttrsImpl
static IList< CustomAttributeData > GetCustomAttributesInternal(RuntimeType target)
static CustomAttributeTypedArgument Filter(IList< CustomAttributeData > attrs, Type caType, int parameter)
RuntimeParameterInfo(RuntimeParameterInfo accessor, MemberInfo member)
override IList< CustomAttributeData > GetCustomAttributesData()
static ParameterInfo GetReturnParameter(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
override bool IsDefined(Type attributeType, bool inherit)
static DateTime GetRawDateTimeConstant(CustomAttributeData attr)
static object GetRawConstant(CustomAttributeData attr)
RuntimeParameterInfo(Signature signature, MetadataImport scope, int tkParamDef, int position, ParameterAttributes attributes, MemberInfo member)
override object[] GetCustomAttributes(Type attributeType, bool inherit)
RuntimeParameterInfo(RuntimeParameterInfo accessor, RuntimePropertyInfo property)
static ParameterInfo[] GetParameters(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
RuntimeParameterInfo(MethodInfo owner, string name, Type parameterType, int position)
void SetAttributes(ParameterAttributes attributes)
override object[] GetCustomAttributes(bool inherit)
static ParameterInfo[] GetParameters(IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo returnParameter, bool fetchReturnParameter)
static decimal GetRawDecimalConstant(CustomAttributeData attr)
static string Arg_MustBeType
Definition SR.cs:302
static string BadImageFormat_ParameterSignatureMismatch
Definition SR.cs:1154
Definition SR.cs:7
unsafe Signature(IRuntimeMethodInfo method, RuntimeType[] arguments, RuntimeType returnType, CallingConventions callingConvention)
Definition Signature.cs:40
RuntimeType ReturnType
Definition Signature.cs:31
RuntimeType[] Arguments
Definition Signature.cs:29
Type[] GetCustomModifiers(int position, bool required)
static readonly object Missing
Definition Type.cs:21
static readonly Type[] EmptyTypes
Definition Type.cs:19
unsafe override string ToString()
static readonly MetadataImport EmptyImport
unsafe MdUtf8String GetName(int mdToken)
static bool IsNullToken(int token)
static int GetMethodDef(IRuntimeMethodInfo method)
static RuntimeType GetDeclaringType(RuntimeMethodHandleInternal method)
static MetadataImport GetMetadataImport(RuntimeType type)