Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SignatureHelper.cs
Go to the documentation of this file.
4using System.Text;
5
7
8public sealed class SignatureHelper
9{
10 private byte[] m_signature;
11
12 private int m_currSig;
13
14 private int m_sizeLoc;
15
17
18 private bool m_sigDone;
19
20 private int m_argCount;
21
22 internal int ArgumentCount => m_argCount;
23
24 public static SignatureHelper GetMethodSigHelper(Module? mod, Type? returnType, Type[]? parameterTypes)
25 {
26 return GetMethodSigHelper(mod, CallingConventions.Standard, returnType, null, null, parameterTypes, null, null);
27 }
28
29 public static SignatureHelper GetMethodSigHelper(Module? mod, CallingConventions callingConvention, Type? returnType)
30 {
31 return GetMethodSigHelper(mod, callingConvention, returnType, null, null, null, null, null);
32 }
33
34 internal static SignatureHelper GetMethodSpecSigHelper(Module scope, Type[] inst)
35 {
36 SignatureHelper signatureHelper = new SignatureHelper(scope, MdSigCallingConvention.GenericInst);
37 signatureHelper.AddData(inst.Length);
38 foreach (Type clsArgument in inst)
39 {
40 signatureHelper.AddArgument(clsArgument);
41 }
42 return signatureHelper;
43 }
44
45 internal static SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
46 {
47 return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
48 }
49
50 internal static SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
51 {
52 if (returnType == null)
53 {
54 returnType = typeof(void);
55 }
56 MdSigCallingConvention mdSigCallingConvention = MdSigCallingConvention.Default;
57 if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
58 {
59 mdSigCallingConvention = MdSigCallingConvention.Vararg;
60 }
61 if (cGenericParam > 0)
62 {
63 mdSigCallingConvention |= MdSigCallingConvention.Generic;
64 }
65 if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
66 {
67 mdSigCallingConvention |= MdSigCallingConvention.HasThis;
68 }
69 SignatureHelper signatureHelper = new SignatureHelper(scope, mdSigCallingConvention, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
70 signatureHelper.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
71 return signatureHelper;
72 }
73
74 internal static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType)
75 {
76 if ((object)returnType == null)
77 {
78 returnType = typeof(void);
79 }
80 MdSigCallingConvention callingConvention;
81 switch (unmanagedCallConv)
82 {
83 case CallingConvention.Cdecl:
84 callingConvention = MdSigCallingConvention.C;
85 break;
86 case CallingConvention.Winapi:
87 case CallingConvention.StdCall:
88 callingConvention = MdSigCallingConvention.StdCall;
89 break;
90 case CallingConvention.ThisCall:
91 callingConvention = MdSigCallingConvention.ThisCall;
92 break;
93 case CallingConvention.FastCall:
94 callingConvention = MdSigCallingConvention.FastCall;
95 break;
96 default:
97 throw new ArgumentException(SR.Argument_UnknownUnmanagedCallConv, "unmanagedCallConv");
98 }
99 return new SignatureHelper(mod, callingConvention, returnType, null, null);
100 }
101
103 {
104 return GetLocalVarSigHelper(null);
105 }
106
107 public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type? returnType)
108 {
109 return GetMethodSigHelper(null, callingConvention, returnType);
110 }
111
112 internal static SignatureHelper GetMethodSigHelper(CallingConvention unmanagedCallingConvention, Type returnType)
113 {
114 return GetMethodSigHelper(null, unmanagedCallingConvention, returnType);
115 }
116
118 {
119 return new SignatureHelper(mod, MdSigCallingConvention.LocalSig);
120 }
121
123 {
124 return new SignatureHelper(mod, MdSigCallingConvention.Field);
125 }
126
127 public static SignatureHelper GetPropertySigHelper(Module? mod, Type? returnType, Type[]? parameterTypes)
128 {
129 return GetPropertySigHelper(mod, returnType, null, null, parameterTypes, null, null);
130 }
131
132 public static SignatureHelper GetPropertySigHelper(Module? mod, Type? returnType, Type[]? requiredReturnTypeCustomModifiers, Type[]? optionalReturnTypeCustomModifiers, Type[]? parameterTypes, Type[][]? requiredParameterTypeCustomModifiers, Type[][]? optionalParameterTypeCustomModifiers)
133 {
134 return GetPropertySigHelper(mod, (CallingConventions)0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
135 }
136
137 public static SignatureHelper GetPropertySigHelper(Module? mod, CallingConventions callingConvention, Type? returnType, Type[]? requiredReturnTypeCustomModifiers, Type[]? optionalReturnTypeCustomModifiers, Type[]? parameterTypes, Type[][]? requiredParameterTypeCustomModifiers, Type[][]? optionalParameterTypeCustomModifiers)
138 {
139 if (returnType == null)
140 {
141 returnType = typeof(void);
142 }
143 MdSigCallingConvention mdSigCallingConvention = MdSigCallingConvention.Property;
144 if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
145 {
146 mdSigCallingConvention |= MdSigCallingConvention.HasThis;
147 }
148 SignatureHelper signatureHelper = new SignatureHelper(mod, mdSigCallingConvention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
149 signatureHelper.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
150 return signatureHelper;
151 }
152
154 {
155 if (module == null)
156 {
157 throw new ArgumentNullException("module");
158 }
159 if (type == null)
160 {
161 throw new ArgumentNullException("type");
162 }
163 return new SignatureHelper(module, type);
164 }
165
166 private SignatureHelper(Module mod, MdSigCallingConvention callingConvention)
167 {
168 Init(mod, callingConvention);
169 }
170
171 private SignatureHelper(Module mod, MdSigCallingConvention callingConvention, int cGenericParameters, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
172 {
173 Init(mod, callingConvention, cGenericParameters);
174 if (callingConvention == MdSigCallingConvention.Field)
175 {
177 }
178 AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers);
179 }
180
181 private SignatureHelper(Module mod, MdSigCallingConvention callingConvention, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
182 : this(mod, callingConvention, 0, returnType, requiredCustomModifiers, optionalCustomModifiers)
183 {
184 }
185
187 {
188 Init(mod);
190 }
191
192 [MemberNotNull("m_signature")]
193 private void Init(Module mod)
194 {
195 m_signature = new byte[32];
196 m_currSig = 0;
197 m_module = mod as ModuleBuilder;
198 m_argCount = 0;
199 m_sigDone = false;
200 m_sizeLoc = -1;
201 if (m_module == null && mod != null)
202 {
204 }
205 }
206
207 [MemberNotNull("m_signature")]
208 private void Init(Module mod, MdSigCallingConvention callingConvention)
209 {
210 Init(mod, callingConvention, 0);
211 }
212
213 [MemberNotNull("m_signature")]
214 private void Init(Module mod, MdSigCallingConvention callingConvention, int cGenericParam)
215 {
216 Init(mod);
217 AddData((int)callingConvention);
218 if (callingConvention == MdSigCallingConvention.Field || callingConvention == MdSigCallingConvention.GenericInst)
219 {
220 m_sizeLoc = -1;
221 return;
222 }
223 if (cGenericParam > 0)
224 {
225 AddData(cGenericParam);
226 }
228 }
229
230 private void AddOneArgTypeHelper(Type argument, bool pinned)
231 {
232 if (pinned)
233 {
234 AddElementType(CorElementType.ELEMENT_TYPE_PINNED);
235 }
236 AddOneArgTypeHelper(argument);
237 }
238
239 private void AddOneArgTypeHelper(Type clsArgument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
240 {
241 if (optionalCustomModifiers != null)
242 {
243 foreach (Type type in optionalCustomModifiers)
244 {
245 if (type == null)
246 {
247 throw new ArgumentNullException("optionalCustomModifiers");
248 }
249 if (type.HasElementType)
250 {
251 throw new ArgumentException(SR.Argument_ArraysInvalid, "optionalCustomModifiers");
252 }
253 if (type.ContainsGenericParameters)
254 {
255 throw new ArgumentException(SR.Argument_GenericsInvalid, "optionalCustomModifiers");
256 }
257 AddElementType(CorElementType.ELEMENT_TYPE_CMOD_OPT);
258 int typeToken = m_module.GetTypeToken(type);
259 AddToken(typeToken);
260 }
261 }
262 if (requiredCustomModifiers != null)
263 {
264 foreach (Type type2 in requiredCustomModifiers)
265 {
266 if (type2 == null)
267 {
268 throw new ArgumentNullException("requiredCustomModifiers");
269 }
270 if (type2.HasElementType)
271 {
272 throw new ArgumentException(SR.Argument_ArraysInvalid, "requiredCustomModifiers");
273 }
275 {
276 throw new ArgumentException(SR.Argument_GenericsInvalid, "requiredCustomModifiers");
277 }
278 AddElementType(CorElementType.ELEMENT_TYPE_CMOD_REQD);
279 int typeToken2 = m_module.GetTypeToken(type2);
280 AddToken(typeToken2);
281 }
282 }
283 AddOneArgTypeHelper(clsArgument);
284 }
285
286 private void AddOneArgTypeHelper(Type clsArgument)
287 {
288 AddOneArgTypeHelperWorker(clsArgument, lastWasGenericInst: false);
289 }
290
291 private void AddOneArgTypeHelperWorker(Type clsArgument, bool lastWasGenericInst)
292 {
293 if (clsArgument.IsGenericParameter)
294 {
295 if (clsArgument.DeclaringMethod != null)
296 {
297 AddElementType(CorElementType.ELEMENT_TYPE_MVAR);
298 }
299 else
300 {
301 AddElementType(CorElementType.ELEMENT_TYPE_VAR);
302 }
304 return;
305 }
306 if (clsArgument.IsGenericType && (!clsArgument.IsGenericTypeDefinition || !lastWasGenericInst))
307 {
308 AddElementType(CorElementType.ELEMENT_TYPE_GENERICINST);
309 AddOneArgTypeHelperWorker(clsArgument.GetGenericTypeDefinition(), lastWasGenericInst: true);
310 Type[] genericArguments = clsArgument.GetGenericArguments();
311 AddData(genericArguments.Length);
312 Type[] array = genericArguments;
313 foreach (Type clsArgument2 in array)
314 {
315 AddOneArgTypeHelper(clsArgument2);
316 }
317 return;
318 }
319 if (clsArgument is TypeBuilder)
320 {
321 TypeBuilder typeBuilder = (TypeBuilder)clsArgument;
322 int clsToken = ((!typeBuilder.Module.Equals(m_module)) ? m_module.GetTypeToken(clsArgument) : typeBuilder.TypeToken);
323 if (clsArgument.IsValueType)
324 {
325 InternalAddTypeToken(clsToken, CorElementType.ELEMENT_TYPE_VALUETYPE);
326 }
327 else
328 {
329 InternalAddTypeToken(clsToken, CorElementType.ELEMENT_TYPE_CLASS);
330 }
331 return;
332 }
333 if (clsArgument is EnumBuilder)
334 {
335 TypeBuilder typeBuilder2 = ((EnumBuilder)clsArgument).m_typeBuilder;
336 int clsToken2 = ((!typeBuilder2.Module.Equals(m_module)) ? m_module.GetTypeToken(clsArgument) : typeBuilder2.TypeToken);
337 if (clsArgument.IsValueType)
338 {
339 InternalAddTypeToken(clsToken2, CorElementType.ELEMENT_TYPE_VALUETYPE);
340 }
341 else
342 {
343 InternalAddTypeToken(clsToken2, CorElementType.ELEMENT_TYPE_CLASS);
344 }
345 return;
346 }
347 if (clsArgument.IsByRef)
348 {
349 AddElementType(CorElementType.ELEMENT_TYPE_BYREF);
350 clsArgument = clsArgument.GetElementType();
351 AddOneArgTypeHelper(clsArgument);
352 return;
353 }
354 if (clsArgument.IsPointer)
355 {
356 AddElementType(CorElementType.ELEMENT_TYPE_PTR);
357 AddOneArgTypeHelper(clsArgument.GetElementType());
358 return;
359 }
360 if (clsArgument.IsArray)
361 {
362 if (clsArgument.IsSZArray)
363 {
364 AddElementType(CorElementType.ELEMENT_TYPE_SZARRAY);
365 AddOneArgTypeHelper(clsArgument.GetElementType());
366 return;
367 }
368 AddElementType(CorElementType.ELEMENT_TYPE_ARRAY);
369 AddOneArgTypeHelper(clsArgument.GetElementType());
370 int arrayRank = clsArgument.GetArrayRank();
371 AddData(arrayRank);
372 AddData(0);
373 AddData(arrayRank);
374 for (int j = 0; j < arrayRank; j++)
375 {
376 AddData(0);
377 }
378 return;
379 }
380 CorElementType corElementType = CorElementType.ELEMENT_TYPE_MAX;
381 if (clsArgument is RuntimeType)
382 {
383 corElementType = RuntimeTypeHandle.GetCorElementType((RuntimeType)clsArgument);
384 if (corElementType == CorElementType.ELEMENT_TYPE_CLASS)
385 {
386 if (clsArgument == typeof(object))
387 {
388 corElementType = CorElementType.ELEMENT_TYPE_OBJECT;
389 }
390 else if (clsArgument == typeof(string))
391 {
392 corElementType = CorElementType.ELEMENT_TYPE_STRING;
393 }
394 }
395 }
396 if (IsSimpleType(corElementType))
397 {
398 AddElementType(corElementType);
399 }
400 else if (m_module == null)
401 {
402 InternalAddRuntimeType(clsArgument);
403 }
404 else if (clsArgument.IsValueType)
405 {
406 InternalAddTypeToken(m_module.GetTypeToken(clsArgument), CorElementType.ELEMENT_TYPE_VALUETYPE);
407 }
408 else
409 {
410 InternalAddTypeToken(m_module.GetTypeToken(clsArgument), CorElementType.ELEMENT_TYPE_CLASS);
411 }
412 }
413
414 private void AddData(int data)
415 {
416 if (m_currSig + 4 > m_signature.Length)
417 {
419 }
420 if (data <= 127)
421 {
422 m_signature[m_currSig++] = (byte)data;
423 return;
424 }
425 if (data <= 16383)
426 {
428 m_currSig += 2;
429 return;
430 }
431 if (data <= 536870911)
432 {
433 BinaryPrimitives.WriteInt32BigEndian(m_signature.AsSpan(m_currSig), (int)(data | 0xC0000000u));
434 m_currSig += 4;
435 return;
436 }
438 }
439
441 {
442 if (m_currSig + 1 > m_signature.Length)
443 {
445 }
446 m_signature[m_currSig++] = (byte)cvt;
447 }
448
449 private void AddToken(int token)
450 {
451 int num = token & 0xFFFFFF;
452 MetadataTokenType metadataTokenType = (MetadataTokenType)(token & -16777216);
453 if (num > 67108863)
454 {
456 }
457 num <<= 2;
458 switch (metadataTokenType)
459 {
460 case MetadataTokenType.TypeRef:
461 num |= 1;
462 break;
463 case MetadataTokenType.TypeSpec:
464 num |= 2;
465 break;
466 }
467 AddData(num);
468 }
469
470 private void InternalAddTypeToken(int clsToken, CorElementType CorType)
471 {
472 AddElementType(CorType);
473 AddToken(clsToken);
474 }
475
476 private unsafe void InternalAddRuntimeType(Type type)
477 {
478 AddElementType(CorElementType.ELEMENT_TYPE_INTERNAL);
479 IntPtr value = type.GetTypeHandleInternal().Value;
480 if (m_currSig + sizeof(void*) > m_signature.Length)
481 {
483 }
484 byte* ptr = (byte*)(&value);
485 for (int i = 0; i < sizeof(void*); i++)
486 {
487 m_signature[m_currSig++] = ptr[i];
488 }
489 }
490
491 private static byte[] ExpandArray(byte[] inArray)
492 {
493 return ExpandArray(inArray, inArray.Length * 2);
494 }
495
496 private static byte[] ExpandArray(byte[] inArray, int requiredLength)
497 {
498 if (requiredLength < inArray.Length)
499 {
500 requiredLength = inArray.Length * 2;
501 }
502 byte[] array = new byte[requiredLength];
503 Buffer.BlockCopy(inArray, 0, array, 0, inArray.Length);
504 return array;
505 }
506
507 private void IncrementArgCounts()
508 {
509 if (m_sizeLoc != -1)
510 {
511 m_argCount++;
512 }
513 }
514
515 private void SetNumberOfSignatureElements(bool forceCopy)
516 {
517 int currSig = m_currSig;
518 if (m_sizeLoc != -1)
519 {
520 if (m_argCount < 128 && !forceCopy)
521 {
523 return;
524 }
525 int num = ((m_argCount < 128) ? 1 : ((m_argCount >= 16384) ? 4 : 2));
526 byte[] array = new byte[m_currSig + num - 1];
527 array[0] = m_signature[0];
528 Buffer.BlockCopy(m_signature, m_sizeLoc + 1, array, m_sizeLoc + num, currSig - (m_sizeLoc + 1));
532 m_currSig = currSig + (num - 1);
533 }
534 }
535
536 internal static bool IsSimpleType(CorElementType type)
537 {
538 if ((int)type <= 14)
539 {
540 return true;
541 }
542 if (type == CorElementType.ELEMENT_TYPE_TYPEDBYREF || type == CorElementType.ELEMENT_TYPE_I || type == CorElementType.ELEMENT_TYPE_U || type == CorElementType.ELEMENT_TYPE_OBJECT)
543 {
544 return true;
545 }
546 return false;
547 }
548
549 internal byte[] InternalGetSignature(out int length)
550 {
551 if (!m_sigDone)
552 {
553 m_sigDone = true;
554 SetNumberOfSignatureElements(forceCopy: false);
555 }
557 return m_signature;
558 }
559
561 {
562 int argCount = m_argCount;
563 int currSig = m_currSig;
564 int num = currSig;
565 num = ((argCount < 127) ? (num + 1) : ((argCount >= 16383) ? (num + 4) : (num + 2)));
566 byte[] array = new byte[num];
567 int dstOffset = 0;
568 array[dstOffset++] = m_signature[0];
569 if (argCount <= 127)
570 {
571 array[dstOffset++] = (byte)((uint)argCount & 0xFFu);
572 }
573 else if (argCount <= 16383)
574 {
575 array[dstOffset++] = (byte)((uint)(argCount >> 8) | 0x80u);
576 array[dstOffset++] = (byte)((uint)argCount & 0xFFu);
577 }
578 else
579 {
580 if (argCount > 536870911)
581 {
583 }
584 array[dstOffset++] = (byte)((uint)(argCount >> 24) | 0xC0u);
585 array[dstOffset++] = (byte)((uint)(argCount >> 16) & 0xFFu);
586 array[dstOffset++] = (byte)((uint)(argCount >> 8) & 0xFFu);
587 array[dstOffset++] = (byte)((uint)argCount & 0xFFu);
588 }
589 Buffer.BlockCopy(m_signature, 2, array, dstOffset, currSig - 2);
590 array[num - 1] = 0;
591 return array;
592 }
593
594 public void AddArgument(Type clsArgument)
595 {
596 AddArgument(clsArgument, null, null);
597 }
598
599 public void AddArgument(Type argument, bool pinned)
600 {
601 if (argument == null)
602 {
603 throw new ArgumentNullException("argument");
604 }
606 AddOneArgTypeHelper(argument, pinned);
607 }
608
609 public void AddArguments(Type[]? arguments, Type[][]? requiredCustomModifiers, Type[][]? optionalCustomModifiers)
610 {
611 if (requiredCustomModifiers != null && (arguments == null || requiredCustomModifiers.Length != arguments.Length))
612 {
613 throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, "requiredCustomModifiers", "arguments"));
614 }
615 if (optionalCustomModifiers != null && (arguments == null || optionalCustomModifiers.Length != arguments.Length))
616 {
617 throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, "optionalCustomModifiers", "arguments"));
618 }
619 if (arguments != null)
620 {
621 for (int i = 0; i < arguments.Length; i++)
622 {
623 AddArgument(arguments[i], (requiredCustomModifiers != null) ? requiredCustomModifiers[i] : null, (optionalCustomModifiers != null) ? optionalCustomModifiers[i] : null);
624 }
625 }
626 }
627
628 public void AddArgument(Type argument, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers)
629 {
630 if (m_sigDone)
631 {
633 }
634 if (argument == null)
635 {
636 throw new ArgumentNullException("argument");
637 }
639 AddOneArgTypeHelper(argument, requiredCustomModifiers, optionalCustomModifiers);
640 }
641
642 public void AddSentinel()
643 {
644 AddElementType(CorElementType.ELEMENT_TYPE_SENTINEL);
645 }
646
647 public override bool Equals(object? obj)
648 {
649 if (!(obj is SignatureHelper))
650 {
651 return false;
652 }
653 SignatureHelper signatureHelper = (SignatureHelper)obj;
654 if (!signatureHelper.m_module.Equals(m_module) || signatureHelper.m_currSig != m_currSig || signatureHelper.m_sizeLoc != m_sizeLoc || signatureHelper.m_sigDone != m_sigDone)
655 {
656 return false;
657 }
658 for (int i = 0; i < m_currSig; i++)
659 {
660 if (m_signature[i] != signatureHelper.m_signature[i])
661 {
662 return false;
663 }
664 }
665 return true;
666 }
667
668 public override int GetHashCode()
669 {
670 int num = m_module.GetHashCode() + m_currSig + m_sizeLoc;
671 if (m_sigDone)
672 {
673 num++;
674 }
675 for (int i = 0; i < m_currSig; i++)
676 {
677 num += m_signature[i].GetHashCode();
678 }
679 return num;
680 }
681
682 public byte[] GetSignature()
683 {
684 return GetSignature(appendEndOfSig: false);
685 }
686
687 internal byte[] GetSignature(bool appendEndOfSig)
688 {
689 if (!m_sigDone)
690 {
691 if (appendEndOfSig)
692 {
693 AddElementType(CorElementType.ELEMENT_TYPE_END);
694 }
695 SetNumberOfSignatureElements(forceCopy: true);
696 m_sigDone = true;
697 }
698 if (m_signature.Length > m_currSig)
699 {
700 byte[] array = new byte[m_currSig];
703 }
704 return m_signature;
705 }
706
707 public override string ToString()
708 {
709 StringBuilder stringBuilder = new StringBuilder();
710 stringBuilder.Append("Length: ").Append(m_currSig).AppendLine();
711 if (m_sizeLoc != -1)
712 {
713 stringBuilder.Append("Arguments: ").Append(m_signature[m_sizeLoc]).AppendLine();
714 }
715 else
716 {
717 stringBuilder.AppendLine("Field Signature");
718 }
719 stringBuilder.AppendLine("Signature: ");
720 for (int i = 0; i <= m_currSig; i++)
721 {
722 stringBuilder.Append(m_signature[i]).Append(" ");
723 }
724 stringBuilder.AppendLine();
725 return stringBuilder.ToString();
726 }
727}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
static void WriteInt16BigEndian(Span< byte > destination, short value)
static void WriteInt32BigEndian(Span< byte > destination, int value)
override bool Equals(object? obj)
unsafe void InternalAddRuntimeType(Type type)
static byte[] ExpandArray(byte[] inArray)
static SignatureHelper GetLocalVarSigHelper(Module? mod)
void Init(Module mod, MdSigCallingConvention callingConvention, int cGenericParam)
static SignatureHelper GetTypeSigToken(Module module, Type type)
static byte[] ExpandArray(byte[] inArray, int requiredLength)
byte[] InternalGetSignature(out int length)
static bool IsSimpleType(CorElementType type)
void InternalAddTypeToken(int clsToken, CorElementType CorType)
static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type? returnType)
static SignatureHelper GetFieldSigHelper(Module? mod)
static SignatureHelper GetPropertySigHelper(Module? mod, Type? returnType, Type[]? requiredReturnTypeCustomModifiers, Type[]? optionalReturnTypeCustomModifiers, Type[]? parameterTypes, Type[][]? requiredParameterTypeCustomModifiers, Type[][]? optionalParameterTypeCustomModifiers)
static SignatureHelper GetLocalVarSigHelper()
void AddArgument(Type argument, bool pinned)
void SetNumberOfSignatureElements(bool forceCopy)
void AddOneArgTypeHelperWorker(Type clsArgument, bool lastWasGenericInst)
static SignatureHelper GetMethodSigHelper(Module? mod, CallingConventions callingConvention, Type? returnType)
static SignatureHelper GetMethodSigHelper(CallingConvention unmanagedCallingConvention, Type returnType)
void AddOneArgTypeHelper(Type argument, bool pinned)
void AddOneArgTypeHelper(Type clsArgument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
void AddArguments(Type[]? arguments, Type[][]? requiredCustomModifiers, Type[][]? optionalCustomModifiers)
static SignatureHelper GetMethodSigHelper(Module? mod, Type? returnType, Type[]? parameterTypes)
static SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
static SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
static SignatureHelper GetMethodSpecSigHelper(Module scope, Type[] inst)
void AddElementType(CorElementType cvt)
static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType)
byte[] GetSignature(bool appendEndOfSig)
SignatureHelper(Module mod, MdSigCallingConvention callingConvention, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
void AddArgument(Type argument, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers)
SignatureHelper(Module mod, MdSigCallingConvention callingConvention)
SignatureHelper(Module mod, MdSigCallingConvention callingConvention, int cGenericParameters, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
void Init(Module mod, MdSigCallingConvention callingConvention)
static SignatureHelper GetPropertySigHelper(Module? mod, CallingConventions callingConvention, Type? returnType, Type[]? requiredReturnTypeCustomModifiers, Type[]? optionalReturnTypeCustomModifiers, Type[]? parameterTypes, Type[][]? requiredParameterTypeCustomModifiers, Type[][]? optionalParameterTypeCustomModifiers)
static SignatureHelper GetPropertySigHelper(Module? mod, Type? returnType, Type[]? parameterTypes)
override bool Equals(object? o)
Definition Module.cs:311
static string Argument_ArraysInvalid
Definition SR.cs:472
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Argument_LargeInteger
Definition SR.cs:756
static string Argument_SigIsFinalized
Definition SR.cs:874
static string Argument_BadFieldSig
Definition SR.cs:484
static string NotSupported_MustBeModuleBuilder
Definition SR.cs:1686
static string Argument_MismatchedArrays
Definition SR.cs:768
static string Argument_GenericsInvalid
Definition SR.cs:610
static string Argument_UnknownUnmanagedCallConv
Definition SR.cs:904
Definition SR.cs:7
override string ToString()
StringBuilder Append(char value, int repeatCount)
Type? GetElementType()
bool IsValueType
Definition Type.cs:234
virtual ? MethodBase DeclaringMethod
Definition Type.cs:57
bool IsPointer
Definition Type.cs:75
virtual Type[] GetGenericArguments()
Definition Type.cs:500
virtual bool IsGenericParameter
Definition Type.cs:85
bool IsArray
Definition Type.cs:71
virtual int GenericParameterPosition
Definition Type.cs:158
virtual int GetArrayRank()
Definition Type.cs:490
virtual bool IsGenericType
Definition Type.cs:111
virtual bool IsSZArray
Definition Type.cs:116
bool HasElementType
Definition Type.cs:143
virtual bool IsGenericTypeDefinition
Definition Type.cs:113
virtual bool ContainsGenericParameters
Definition Type.cs:336
bool IsByRef
Definition Type.cs:73
virtual Type GetGenericTypeDefinition()
Definition Type.cs:495
static CorElementType GetCorElementType(RuntimeType type)