1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Collections.Generic; 6 using System.Reflection; 7 using System.Runtime.CompilerServices; 8 9 namespace System.Linq.Expressions 10 { 11 internal static partial class CachedReflectionInfo 12 { 13 private static ConstructorInfo s_Nullable_Boolean_Ctor; 14 15 public static ConstructorInfo Nullable_Boolean_Ctor 16 => s_Nullable_Boolean_Ctor ?? (s_Nullable_Boolean_Ctor = typeof(bool?).GetConstructor(new[] { typeof(bool) })); 17 18 private static ConstructorInfo s_Decimal_Ctor_Int32; 19 public static ConstructorInfo Decimal_Ctor_Int32 => 20 s_Decimal_Ctor_Int32 ?? 21 (s_Decimal_Ctor_Int32 = typeof(decimal).GetConstructor(new[] { typeof(int) })); 22 23 private static ConstructorInfo s_Decimal_Ctor_UInt32; 24 public static ConstructorInfo Decimal_Ctor_UInt32 => 25 s_Decimal_Ctor_UInt32 ?? 26 (s_Decimal_Ctor_UInt32 = typeof(decimal).GetConstructor(new[] { typeof(uint) })); 27 28 private static ConstructorInfo s_Decimal_Ctor_Int64; 29 public static ConstructorInfo Decimal_Ctor_Int64 => 30 s_Decimal_Ctor_Int64 ?? 31 (s_Decimal_Ctor_Int64 = typeof(decimal).GetConstructor(new[] { typeof(long) })); 32 33 private static ConstructorInfo s_Decimal_Ctor_UInt64; 34 public static ConstructorInfo Decimal_Ctor_UInt64 => 35 s_Decimal_Ctor_UInt64 ?? 36 (s_Decimal_Ctor_UInt64 = typeof(decimal).GetConstructor(new[] { typeof(ulong) })); 37 38 private static ConstructorInfo s_Decimal_Ctor_Int32_Int32_Int32_Bool_Byte; 39 public static ConstructorInfo Decimal_Ctor_Int32_Int32_Int32_Bool_Byte => 40 s_Decimal_Ctor_Int32_Int32_Int32_Bool_Byte ?? 41 (s_Decimal_Ctor_Int32_Int32_Int32_Bool_Byte = typeof(decimal).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(bool), typeof(byte) })); 42 43 private static FieldInfo s_Decimal_One; 44 public static FieldInfo Decimal_One 45 => s_Decimal_One ?? (s_Decimal_One = typeof(decimal).GetField(nameof(decimal.One))); 46 47 private static FieldInfo s_Decimal_MinusOne; 48 public static FieldInfo Decimal_MinusOne 49 => s_Decimal_MinusOne ?? (s_Decimal_MinusOne = typeof(decimal).GetField(nameof(decimal.MinusOne))); 50 51 private static FieldInfo s_Decimal_MinValue; 52 public static FieldInfo Decimal_MinValue 53 => s_Decimal_MinValue ?? (s_Decimal_MinValue = typeof(decimal).GetField(nameof(decimal.MinValue))); 54 55 private static FieldInfo s_Decimal_MaxValue; 56 public static FieldInfo Decimal_MaxValue 57 => s_Decimal_MaxValue ?? (s_Decimal_MaxValue = typeof(decimal).GetField(nameof(decimal.MaxValue))); 58 59 private static FieldInfo s_Decimal_Zero; 60 public static FieldInfo Decimal_Zero 61 => s_Decimal_Zero ?? (s_Decimal_Zero = typeof(decimal).GetField(nameof(decimal.Zero))); 62 63 private static FieldInfo s_DateTime_MinValue; 64 public static FieldInfo DateTime_MinValue 65 => s_DateTime_MinValue ?? (s_DateTime_MinValue = typeof(DateTime).GetField(nameof(DateTime.MinValue))); 66 67 private static MethodInfo s_MethodBase_GetMethodFromHandle_RuntimeMethodHandle; 68 public static MethodInfo MethodBase_GetMethodFromHandle_RuntimeMethodHandle => 69 s_MethodBase_GetMethodFromHandle_RuntimeMethodHandle ?? 70 (s_MethodBase_GetMethodFromHandle_RuntimeMethodHandle = typeof(MethodBase).GetMethod(nameof(MethodBase.GetMethodFromHandle), new[] { typeof(RuntimeMethodHandle) })); 71 72 private static MethodInfo s_MethodBase_GetMethodFromHandle_RuntimeMethodHandle_RuntimeTypeHandle; 73 public static MethodInfo MethodBase_GetMethodFromHandle_RuntimeMethodHandle_RuntimeTypeHandle => 74 s_MethodBase_GetMethodFromHandle_RuntimeMethodHandle_RuntimeTypeHandle ?? 75 (s_MethodBase_GetMethodFromHandle_RuntimeMethodHandle_RuntimeTypeHandle = typeof(MethodBase).GetMethod(nameof(MethodBase.GetMethodFromHandle), new[] { typeof(RuntimeMethodHandle), typeof(RuntimeTypeHandle) })); 76 77 private static MethodInfo s_MethodInfo_CreateDelegate_Type_Object; 78 public static MethodInfo MethodInfo_CreateDelegate_Type_Object => 79 s_MethodInfo_CreateDelegate_Type_Object ?? 80 (s_MethodInfo_CreateDelegate_Type_Object = typeof(MethodInfo).GetMethod(nameof(MethodInfo.CreateDelegate), new[] { typeof(Type), typeof(object) })); 81 82 private static MethodInfo s_String_op_Equality_String_String; 83 public static MethodInfo String_op_Equality_String_String => 84 s_String_op_Equality_String_String ?? 85 (s_String_op_Equality_String_String = typeof(string).GetMethod("op_Equality", new[] { typeof(string), typeof(string) })); 86 87 private static MethodInfo s_String_Equals_String_String; 88 public static MethodInfo String_Equals_String_String => 89 s_String_Equals_String_String ?? 90 (s_String_Equals_String_String = typeof(string).GetMethod("Equals", new[] { typeof(string), typeof(string) })); 91 92 private static MethodInfo s_DictionaryOfStringInt32_Add_String_Int32; 93 public static MethodInfo DictionaryOfStringInt32_Add_String_Int32 => 94 s_DictionaryOfStringInt32_Add_String_Int32 ?? 95 (s_DictionaryOfStringInt32_Add_String_Int32 = typeof(Dictionary<string, int>).GetMethod(nameof(Dictionary<string, int>.Add), new[] { typeof(string), typeof(int) })); 96 97 private static ConstructorInfo s_DictionaryOfStringInt32_Ctor_Int32; 98 public static ConstructorInfo DictionaryOfStringInt32_Ctor_Int32 => 99 s_DictionaryOfStringInt32_Ctor_Int32 ?? 100 (s_DictionaryOfStringInt32_Ctor_Int32 = typeof(Dictionary<string, int>).GetConstructor(new[] { typeof(int) })); 101 102 private static MethodInfo s_Type_GetTypeFromHandle; 103 public static MethodInfo Type_GetTypeFromHandle => 104 s_Type_GetTypeFromHandle ?? 105 (s_Type_GetTypeFromHandle = typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle))); 106 107 private static MethodInfo s_Object_GetType; 108 public static MethodInfo Object_GetType => 109 s_Object_GetType ?? 110 (s_Object_GetType = typeof(object).GetMethod(nameof(object.GetType))); 111 112 private static MethodInfo s_Decimal_op_Implicit_Byte; 113 public static MethodInfo Decimal_op_Implicit_Byte => 114 s_Decimal_op_Implicit_Byte ?? 115 (s_Decimal_op_Implicit_Byte = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(byte) })); 116 117 private static MethodInfo s_Decimal_op_Implicit_SByte; 118 public static MethodInfo Decimal_op_Implicit_SByte => 119 s_Decimal_op_Implicit_SByte ?? 120 (s_Decimal_op_Implicit_SByte = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(sbyte) })); 121 122 private static MethodInfo s_Decimal_op_Implicit_Int16; 123 public static MethodInfo Decimal_op_Implicit_Int16 => 124 s_Decimal_op_Implicit_Int16 ?? 125 (s_Decimal_op_Implicit_Int16 = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(short) })); 126 127 private static MethodInfo s_Decimal_op_Implicit_UInt16; 128 public static MethodInfo Decimal_op_Implicit_UInt16 => 129 s_Decimal_op_Implicit_UInt16 ?? 130 (s_Decimal_op_Implicit_UInt16 = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(ushort) })); 131 132 private static MethodInfo s_Decimal_op_Implicit_Int32; 133 public static MethodInfo Decimal_op_Implicit_Int32 => 134 s_Decimal_op_Implicit_Int32 ?? 135 (s_Decimal_op_Implicit_Int32 = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(int) })); 136 137 private static MethodInfo s_Decimal_op_Implicit_UInt32; 138 public static MethodInfo Decimal_op_Implicit_UInt32 => 139 s_Decimal_op_Implicit_UInt32 ?? 140 (s_Decimal_op_Implicit_UInt32 = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(uint) })); 141 142 private static MethodInfo s_Decimal_op_Implicit_Int64; 143 public static MethodInfo Decimal_op_Implicit_Int64 => 144 s_Decimal_op_Implicit_Int64 ?? 145 (s_Decimal_op_Implicit_Int64 = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(long) })); 146 147 private static MethodInfo s_Decimal_op_Implicit_UInt64; 148 public static MethodInfo Decimal_op_Implicit_UInt64 => 149 s_Decimal_op_Implicit_UInt64 ?? 150 (s_Decimal_op_Implicit_UInt64 = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(ulong) })); 151 152 private static MethodInfo s_Decimal_op_Implicit_Char; 153 public static MethodInfo Decimal_op_Implicit_Char => 154 s_Decimal_op_Implicit_Char ?? 155 (s_Decimal_op_Implicit_Char = typeof(decimal).GetMethod("op_Implicit", new[] { typeof(char) })); 156 157 private static MethodInfo s_Math_Pow_Double_Double; 158 public static MethodInfo Math_Pow_Double_Double => 159 s_Math_Pow_Double_Double ?? 160 (s_Math_Pow_Double_Double = typeof(Math).GetMethod(nameof(Math.Pow), new[] { typeof(double), typeof(double) })); 161 162 // Closure and RuntimeOps helpers are used only in the compiler. 163 #if FEATURE_COMPILE 164 private static ConstructorInfo s_Closure_ObjectArray_ObjectArray; 165 public static ConstructorInfo Closure_ObjectArray_ObjectArray => 166 s_Closure_ObjectArray_ObjectArray ?? 167 (s_Closure_ObjectArray_ObjectArray = typeof(Closure).GetConstructor(new[] { typeof(object[]), typeof(object[]) })); 168 169 private static FieldInfo s_Closure_Constants; 170 public static FieldInfo Closure_Constants => 171 s_Closure_Constants ?? 172 (s_Closure_Constants = typeof(Closure).GetField(nameof(Closure.Constants))); 173 174 private static FieldInfo s_Closure_Locals; 175 public static FieldInfo Closure_Locals => 176 s_Closure_Locals ?? 177 (s_Closure_Locals = typeof(Closure).GetField(nameof(Closure.Locals))); 178 179 private static MethodInfo s_RuntimeOps_CreateRuntimeVariables_ObjectArray_Int64Array; 180 public static MethodInfo RuntimeOps_CreateRuntimeVariables_ObjectArray_Int64Array => 181 s_RuntimeOps_CreateRuntimeVariables_ObjectArray_Int64Array ?? 182 (s_RuntimeOps_CreateRuntimeVariables_ObjectArray_Int64Array = typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.CreateRuntimeVariables), new[] { typeof(object[]), typeof(long[]) })); 183 184 private static MethodInfo s_RuntimeOps_CreateRuntimeVariables; 185 public static MethodInfo RuntimeOps_CreateRuntimeVariables => 186 s_RuntimeOps_CreateRuntimeVariables ?? 187 (s_RuntimeOps_CreateRuntimeVariables = typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.CreateRuntimeVariables), Type.EmptyTypes)); 188 189 private static MethodInfo s_RuntimeOps_MergeRuntimeVariables; 190 public static MethodInfo RuntimeOps_MergeRuntimeVariables => 191 s_RuntimeOps_MergeRuntimeVariables ?? 192 (s_RuntimeOps_MergeRuntimeVariables = typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.MergeRuntimeVariables))); 193 194 private static MethodInfo s_RuntimeOps_Quote; 195 public static MethodInfo RuntimeOps_Quote => 196 s_RuntimeOps_Quote ?? 197 (s_RuntimeOps_Quote = typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.Quote))); 198 #endif 199 } 200 } 201