Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TypeHelper.cs
Go to the documentation of this file.
2
3namespace System.Linq;
4
5internal static class TypeHelper
6{
7 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:RequiresUnreferencedCode", Justification = "GetInterfaces is only called if 'definition' is interface type. In that case though the interface must be present (otherwise the Type of it could not exist) which also means that the trimmer kept the interface and thus kept it on all types which implement it. It doesn't matter if the GetInterfaces call below returns fewer typesas long as it returns the 'definition' as well.")]
8 internal static Type FindGenericType(Type definition, Type type)
9 {
10 bool? flag = null;
11 while (type != null && type != typeof(object))
12 {
13 if (type.IsGenericType && type.GetGenericTypeDefinition() == definition)
14 {
15 return type;
16 }
17 if (!flag.HasValue)
18 {
19 flag = definition.IsInterface;
20 }
21 if (flag.GetValueOrDefault())
22 {
23 Type[] interfaces = type.GetInterfaces();
24 foreach (Type type2 in interfaces)
25 {
26 Type type3 = FindGenericType(definition, type2);
27 if (type3 != null)
28 {
29 return type3;
30 }
31 }
32 }
34 }
35 return null;
36 }
37}
static Type FindGenericType(Type definition, Type type)
Definition TypeHelper.cs:8
bool IsInterface
Definition Type.cs:30
Type? BaseType
Definition Type.cs:295
Type[] GetInterfaces()