Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IEnumerableConverterFactoryHelpers.cs
Go to the documentation of this file.
4
6
8{
9 [RequiresUnreferencedCode("System.Collections.Immutable converters use Reflection to find and create Immutable Collection types, which requires unreferenced code.")]
11 {
14 {
17 foreach (MethodInfo methodInfo in array)
18 {
19 if (methodInfo.Name == "CreateRange" && methodInfo.GetParameters().Length == 1 && methodInfo.IsGenericMethod && methodInfo.GetGenericArguments().Length == 1)
20 {
22 }
23 }
24 }
26 return null;
27 }
28
29 [RequiresUnreferencedCode("System.Collections.Immutable converters use Reflection to find and create Immutable Collection types, which requires unreferenced code.")]
31 {
34 {
37 foreach (MethodInfo methodInfo in array)
38 {
39 if (methodInfo.Name == "CreateRange" && methodInfo.GetParameters().Length == 1 && methodInfo.IsGenericMethod && methodInfo.GetGenericArguments().Length == 2)
40 {
42 }
43 }
44 }
46 return null;
47 }
48
49 [RequiresUnreferencedCode("System.Collections.Immutable converters use Reflection to find and create Immutable Collection types, which requires unreferenced code.")]
51 {
52 string immutableEnumerableConstructingTypeName = type.GetImmutableEnumerableConstructingTypeName();
54 {
55 return type.Assembly.GetType(immutableEnumerableConstructingTypeName);
56 }
57 return null;
58 }
59
60 [RequiresUnreferencedCode("System.Collections.Immutable converters use Reflection to find and create Immutable Collection types, which requires unreferenced code.")]
62 {
63 string immutableDictionaryConstructingTypeName = type.GetImmutableDictionaryConstructingTypeName();
65 {
66 return type.Assembly.GetType(immutableDictionaryConstructingTypeName);
67 }
68 return null;
69 }
70
71 public static bool IsNonGenericStackOrQueue(this Type type)
72 {
73 Type typeIfExists = GetTypeIfExists("System.Collections.Stack, System.Collections.NonGeneric");
74 if ((object)typeIfExists != null && typeIfExists.IsAssignableFrom(type))
75 {
76 return true;
77 }
78 Type typeIfExists2 = GetTypeIfExists("System.Collections.Queue, System.Collections.NonGeneric");
79 if ((object)typeIfExists2 != null && typeIfExists2.IsAssignableFrom(type))
80 {
81 return true;
82 }
83 return false;
84 }
85
86 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2057:TypeGetType", Justification = "This method exists to allow for 'weak references' to the Stack and Queue types. If those types are used in the app, they will be preserved by the app and Type.GetType will return them. If those types are not used in the app, we don't want to preserve them here.")]
87 private static Type GetTypeIfExists(string name)
88 {
89 return Type.GetType(name, throwOnError: false);
90 }
91}
virtual MethodInfo MakeGenericMethod(params Type[] typeArguments)
Definition MethodInfo.cs:41
static MethodInfo GetImmutableEnumerableCreateRangeMethod(this Type type, Type elementType)
static MethodInfo GetImmutableDictionaryCreateRangeMethod(this Type type, Type keyType, Type valueType)
static void ThrowNotSupportedException_SerializationNotSupported(Type propertyType)
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408