diff --git a/Il2CppInspector/Reflection/Il2CppModel.cs b/Il2CppInspector/Reflection/Il2CppModel.cs index 5ecbe64..64f6ec2 100644 --- a/Il2CppInspector/Reflection/Il2CppModel.cs +++ b/Il2CppInspector/Reflection/Il2CppModel.cs @@ -44,6 +44,16 @@ namespace Il2CppInspector.Reflection // Get an assembly by its image name public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.ShortName == name); + // Get a type by its fully qualified name including generic type arguments, array brackets etc. + // In other words, rather than only being able to fetch a type definition such as in Assembly.GetType(), + // this method can also find reference types, types created from TypeRefs and constructed types from MethodSpecs + public TypeInfo GetType(string fullName) => Types.FirstOrDefault(t => fullName == t.Namespace + "." + t.Name); + + // Get a concrete instantiation of a generic method from its fully qualified name and type arguments + public MethodBase GetGenericMethod(string fullName, params TypeInfo[] typeArguments) => + GenericMethods.Values.First(m => fullName == m.DeclaringType.Namespace + "." + m.DeclaringType.BaseName + "." + m.Name + && m.GetGenericArguments().SequenceEqual(typeArguments)); + // Create type model public Il2CppModel(Il2CppInspector package) { Package = package;