Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Associates.cs
Go to the documentation of this file.
3
4namespace System.Reflection;
5
6internal static class Associates
7{
8 [Flags]
16
17 internal static bool IncludeAccessor(MethodInfo associate, bool nonPublic)
18 {
19 if ((object)associate == null)
20 {
21 return false;
22 }
23 if (nonPublic)
24 {
25 return true;
26 }
27 if (associate.IsPublic)
28 {
29 return true;
30 }
31 return false;
32 }
33
34 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Module.ResolveMethod 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).")]
36 {
38 {
39 return null;
40 }
41 bool flag = declaredType != reflectedType;
42 IntPtr[] array = null;
43 int typeInstCount = 0;
44 RuntimeType[] instantiationInternal = declaredType.GetTypeHandleInternal().GetInstantiationInternal();
45 if (instantiationInternal != null)
46 {
49 for (int i = 0; i < instantiationInternal.Length; i++)
50 {
51 array[i] = instantiationInternal[i].GetTypeHandleInternal().Value;
52 }
53 }
55 if (flag)
56 {
58 if ((attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private)
59 {
60 return null;
61 }
62 if ((attributes & MethodAttributes.Virtual) != 0 && (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == 0)
63 {
66 }
67 }
69 return runtimeMethodInfo ?? (reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo);
70 }
71
73 {
74 addOn = (removeOn = (fireOn = (getter = (setter = null))));
75 Attributes attributes = Attributes.ComposedOfAllVirtualMethods | Attributes.ComposedOfAllPrivateMethods | Attributes.ComposedOfNoPublicMembers | Attributes.ComposedOfNoStaticMembers;
77 {
79 }
82 scope.Enum(MetadataTokenType.MethodDef, mdPropEvent, out var result);
83 int num = result.Length / 2;
84 for (int i = 0; i < num; i++)
85 {
86 int tkMethod = result[i * 2];
89 if (runtimeMethodInfo == null)
90 {
91 continue;
92 }
94 bool flag = (attributes2 & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
95 bool flag2 = (attributes2 & MethodAttributes.Virtual) != 0;
98 bool flag4 = (attributes2 & MethodAttributes.Static) != 0;
99 if (flag3)
100 {
101 attributes &= ~Attributes.ComposedOfNoPublicMembers;
102 attributes &= ~Attributes.ComposedOfAllPrivateMethods;
103 }
104 else if (!flag)
105 {
106 attributes &= ~Attributes.ComposedOfAllPrivateMethods;
107 }
108 if (flag4)
109 {
110 attributes &= ~Attributes.ComposedOfNoStaticMembers;
111 }
112 if (!flag2)
113 {
114 attributes &= ~Attributes.ComposedOfAllVirtualMethods;
115 }
117 {
118 case MethodSemanticsAttributes.Setter:
120 continue;
121 case MethodSemanticsAttributes.Getter:
122 getter = runtimeMethodInfo;
123 continue;
126 continue;
127 case MethodSemanticsAttributes.AddOn:
129 continue;
130 case MethodSemanticsAttributes.RemoveOn:
132 continue;
133 }
134 if (list == null)
135 {
136 list = new List<MethodInfo>(num);
137 }
139 }
140 bool isPublic = (attributes & Attributes.ComposedOfNoPublicMembers) == 0;
141 bool isStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0;
143 composedOfAllPrivateMethods = (attributes & Attributes.ComposedOfAllPrivateMethods) != 0;
144 other = list?.ToArray();
145 }
146}
static void AssignAssociates(MetadataImport scope, int mdPropEvent, RuntimeType declaringType, RuntimeType reflectedType, out RuntimeMethodInfo addOn, out RuntimeMethodInfo removeOn, out RuntimeMethodInfo fireOn, out RuntimeMethodInfo getter, out RuntimeMethodInfo setter, out MethodInfo[] other, out bool composedOfAllPrivateMethods, out BindingFlags bindingFlags)
Definition Associates.cs:72
static RuntimeMethodInfo AssignAssociates(int tkMethod, RuntimeType declaredType, RuntimeType reflectedType)
Definition Associates.cs:35
static bool IncludeAccessor(MethodInfo associate, bool nonPublic)
Definition Associates.cs:17
static BindingFlags FilterPreCalculate(bool isPublic, bool isInherited, bool isStatic)
static MethodBase GetMethodBase(RuntimeModule scope, int typeMetadataToken)
static unsafe RuntimeMethodHandleInternal ResolveMethodHandleInternal(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount)
void Enum(MetadataTokenType type, int parent, out MetadataEnumResult result)
static bool IsNullToken(int token)
static int GetSlot(RuntimeMethodHandleInternal method)
static MethodAttributes GetAttributes(RuntimeMethodHandleInternal method)
static TypeAttributes GetAttributes(RuntimeType type)
static RuntimeModule GetModule(RuntimeType type)
static bool IsGenericVariable(RuntimeType type)
static RuntimeMethodHandleInternal GetMethodAt(RuntimeType type, int slot)