Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeConstructorInfo.cs
Go to the documentation of this file.
6using System.Text;
8
9namespace System.Reflection;
10
12{
13 private volatile RuntimeType m_declaringType;
14
16
17 private string m_toString;
18
20
21 private object _empty1;
22
23 private object _empty2;
24
25 private object _empty3;
26
28
30
32
34
36
38 {
39 [MethodImpl(MethodImplOptions.AggressiveInlining)]
40 get
41 {
43 if ((iNVOCATION_FLAGS & INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED) == 0)
44 {
46 }
47 return iNVOCATION_FLAGS;
48 [MethodImpl(MethodImplOptions.NoInlining)]
50 {
51 INVOCATION_FLAGS iNVOCATION_FLAGS2 = INVOCATION_FLAGS.INVOCATION_FLAGS_IS_CTOR;
53 if (declaringType == typeof(void) || (declaringType != null && declaringType.ContainsGenericParameters) || (CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
54 {
55 iNVOCATION_FLAGS2 |= INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE;
56 }
57 else if (base.IsStatic)
58 {
59 iNVOCATION_FLAGS2 |= INVOCATION_FLAGS.INVOCATION_FLAGS_RUN_CLASS_CONSTRUCTOR | INVOCATION_FLAGS.INVOCATION_FLAGS_NO_CTOR_INVOKE;
60 }
61 else if (declaringType != null && declaringType.IsAbstract)
62 {
63 iNVOCATION_FLAGS2 |= INVOCATION_FLAGS.INVOCATION_FLAGS_NO_CTOR_INVOKE;
64 }
65 else
66 {
67 if (declaringType != null && declaringType.IsByRefLike)
68 {
69 iNVOCATION_FLAGS2 |= INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS;
70 }
71 if (typeof(Delegate).IsAssignableFrom(DeclaringType))
72 {
73 iNVOCATION_FLAGS2 |= INVOCATION_FLAGS.INVOCATION_FLAGS_IS_DELEGATE_CTOR;
74 }
75 }
76 return m_invocationFlags = iNVOCATION_FLAGS2 | INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED;
77 }
78 }
79 }
80
82
84 {
85 [MethodImpl(MethodImplOptions.AggressiveInlining)]
86 get
87 {
89 [MethodImpl(MethodImplOptions.NoInlining)]
91 {
94 return signature;
95 }
96 }
97 }
98
100
102
103 public override string Name => RuntimeMethodHandle.GetName(this);
104
105 public override MemberTypes MemberType => MemberTypes.Constructor;
106
107 public override Type DeclaringType
108 {
109 get
110 {
111 if (!m_reflectedTypeCache.IsGlobal)
112 {
113 return m_declaringType;
114 }
115 return null;
116 }
117 }
118
119 public override Type ReflectedType
120 {
121 get
122 {
123 if (!m_reflectedTypeCache.IsGlobal)
124 {
126 }
127 return null;
128 }
129 }
130
131 public override int MetadataToken => RuntimeMethodHandle.GetMethodDef(this);
132
133 public override Module Module => GetRuntimeModule();
134
136
138
139 public override CallingConventions CallingConvention => Signature.CallingConvention;
140
141 public override bool IsSecurityCritical => true;
142
143 public override bool IsSecuritySafeCritical => false;
144
145 public override bool IsSecurityTransparent => false;
146
147 public override bool ContainsGenericParameters
148 {
149 get
150 {
151 if (DeclaringType != null)
152 {
153 return DeclaringType.ContainsGenericParameters;
154 }
155 return false;
156 }
157 }
158
167
168 internal override bool CacheEquals(object o)
169 {
171 {
172 return runtimeConstructorInfo.m_handle == m_handle;
173 }
174 return false;
175 }
176
177 private void CheckConsistency(object target)
178 {
179 if ((target != null || !base.IsStatic) && !m_declaringType.IsInstanceOfType(target))
180 {
181 if (target == null)
182 {
184 }
186 }
187 }
188
189 public override string ToString()
190 {
191 if (m_toString == null)
192 {
194 sbParamList.Append("Void ");
195 sbParamList.Append(Name);
196 sbParamList.Append('(');
198 sbParamList.Append(')');
199 m_toString = sbParamList.ToString();
200 }
201 return m_toString;
202 }
203
204 public override object[] GetCustomAttributes(bool inherit)
205 {
207 }
208
209 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
210 {
211 if (attributeType == null)
212 {
213 throw new ArgumentNullException("attributeType");
214 }
215 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
216 if (runtimeType == null)
217 {
218 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
219 }
221 }
222
223 public override bool IsDefined(Type attributeType, bool inherit)
224 {
225 if (attributeType == null)
226 {
227 throw new ArgumentNullException("attributeType");
228 }
229 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
230 if (runtimeType == null)
231 {
232 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
233 }
235 }
236
241
246
248 {
249 return m_declaringType;
250 }
251
256
257 internal override Type GetReturnType()
258 {
259 return Signature.ReturnType;
260 }
261
262 internal override ParameterInfo[] GetParametersNoCopy()
263 {
265 }
266
267 public override ParameterInfo[] GetParameters()
268 {
270 if (parametersNoCopy.Length == 0)
271 {
272 return parametersNoCopy;
273 }
276 return array;
277 }
278
283
285 {
286 if (declaringType == null)
287 {
288 throw new ArgumentNullException("declaringType");
289 }
290 if (declaringType.IsInterface)
291 {
293 }
294 if (declaringType.IsAbstract)
295 {
297 }
298 if (declaringType.GetRootElementType() == typeof(ArgIterator))
299 {
300 throw new NotSupportedException();
301 }
302 if (isVarArg)
303 {
304 throw new NotSupportedException();
305 }
306 if (declaringType.ContainsGenericParameters)
307 {
309 }
310 if (declaringType == typeof(void))
311 {
313 }
314 }
315
318 {
319 CheckCanCreateInstance(DeclaringType, (CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs);
320 if ((Attributes & MethodAttributes.Static) == MethodAttributes.Static)
321 {
323 }
324 throw new TargetException();
325 }
326
328 [DebuggerHidden]
329 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2059:RunClassConstructor", Justification = "This ConstructorInfo instance represents the static constructor itself, so if this object was created, the static constructor exists.")]
330 public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
331 {
333 if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
334 {
336 }
338 if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_RUN_CLASS_CONSTRUCTOR) != 0)
339 {
341 if (declaringType != null)
342 {
344 }
345 else
346 {
348 }
349 return null;
350 }
352 int num = signature.Arguments.Length;
353 int num2 = ((parameters != null) ? parameters.Length : 0);
354 if (num != num2)
355 {
357 }
358 bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
361 if (num2 != 0)
362 {
364 }
366 for (int i = 0; i < arguments.Length; i++)
367 {
368 parameters[i] = arguments[i];
369 }
370 return result;
371 }
372
373 [RequiresUnreferencedCode("Trimming may change method bodies. For example it can change some instructions, remove branches or local variables.")]
374 public override MethodBody GetMethodBody()
375 {
377 if (methodBody != null)
378 {
379 methodBody._methodBase = this;
380 }
381 return methodBody;
382 }
383
385 [DebuggerHidden]
386 public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
387 {
389 if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE | INVOCATION_FLAGS.INVOCATION_FLAGS_NO_CTOR_INVOKE | INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS)) != 0)
390 {
392 }
394 int num = signature.Arguments.Length;
395 int num2 = ((parameters != null) ? parameters.Length : 0);
396 if (num != num2)
397 {
399 }
400 bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
403 if (num2 != 0)
404 {
406 }
408 for (int i = 0; i < arguments.Length; i++)
409 {
410 parameters[i] = arguments[i];
411 }
412 return result;
413 }
414}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
virtual Type[] GetParameterTypes()
static void AppendParameters(ref ValueStringBuilder sbParamList, Type[] parameterTypes, CallingConventions callingConvention)
Span< object > CheckArguments(ref StackAllocedArguments stackArgs, ReadOnlySpan< object > parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
ModuleHandle ModuleHandle
Definition Module.cs:64
override MethodImplAttributes GetMethodImplementationFlags()
override bool IsDefined(Type attributeType, bool inherit)
override object[] GetCustomAttributes(Type attributeType, bool inherit)
override bool HasSameMetadataDefinitionAs(MemberInfo other)
RuntimeConstructorInfo(RuntimeMethodHandleInternal handle, RuntimeType declaringType, RuntimeType.RuntimeTypeCache reflectedTypeCache, MethodAttributes methodAttributes, BindingFlags bindingFlags)
override IList< CustomAttributeData > GetCustomAttributesData()
RuntimeType.RuntimeTypeCache m_reflectedTypeCache
override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
static void CheckCanCreateInstance(Type declaringType, bool isVarArg)
override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
override object[] GetCustomAttributes(bool inherit)
static IList< CustomAttributeData > GetCustomAttributesInternal(RuntimeType target)
static ParameterInfo[] GetParameters(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
static void RunClassConstructor(QCallTypeHandle type)
static void RunModuleConstructor(QCallModule module)
static string Access_Void
Definition SR.cs:40
static string Arg_MustBeType
Definition SR.cs:302
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Acc_NotClassInit
Definition SR.cs:36
static string RFLCT_Targ_ITargMismatch
Definition SR.cs:1846
static string Acc_CreateInterfaceEx
Definition SR.cs:32
static string Acc_CreateAbstEx
Definition SR.cs:26
static string Arg_ParmCnt
Definition SR.cs:368
static string Acc_CreateGenericEx
Definition SR.cs:30
static string RFLCT_Targ_StatMethReqTarg
Definition SR.cs:1850
Definition SR.cs:7
RuntimeType ReturnType
Definition Signature.cs:31
CallingConventions CallingConvention
Definition Signature.cs:27
static void Write(ref bool location, bool value)
Definition Volatile.cs:74
static int GetMethodDef(IRuntimeMethodInfo method)
static string GetName(RuntimeMethodHandleInternal method)
static MethodImplAttributes GetImplAttributes(IRuntimeMethodInfo method)
static RuntimeMethodBody GetMethodBody(IRuntimeMethodInfo method, RuntimeType declaringType)
static object InvokeMethod(object target, in Span< object > arguments, Signature sig, bool constructor, bool wrapExceptions)
static RuntimeModule GetModule(RuntimeType type)