From 29fab4be97d5f95f1d6f7390940f510d1b7bed8b Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Wed, 25 Oct 2017 05:10:54 +0200 Subject: [PATCH] Add Reflection stub classes and Il2CppReflector --- Il2CppInspector/Il2CppReflector.cs | 26 +++ .../Reflection/ReflectionClasses.cs | 152 ++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 Il2CppInspector/Il2CppReflector.cs create mode 100644 Il2CppInspector/Reflection/ReflectionClasses.cs diff --git a/Il2CppInspector/Il2CppReflector.cs b/Il2CppInspector/Il2CppReflector.cs new file mode 100644 index 0000000..601b6d4 --- /dev/null +++ b/Il2CppInspector/Il2CppReflector.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +namespace Il2CppInspector.Reflection +{ + public class Il2CppReflector + { + public List Assemblies { get; } = new List(); + + // Factory instantiation via Il2CppReflector.Parse only + private Il2CppReflector() { } + + public static Il2CppReflector Parse(Il2CppInspector package) { + var r = new Il2CppReflector(); + + // TODO: Populate reflection classes + + return r; + } + + // Get the assembly in which a type is defined + public Assembly GetAssembly(Type type) { + throw new NotImplementedException(); + } + } +} diff --git a/Il2CppInspector/Reflection/ReflectionClasses.cs b/Il2CppInspector/Reflection/ReflectionClasses.cs new file mode 100644 index 0000000..0361c82 --- /dev/null +++ b/Il2CppInspector/Reflection/ReflectionClasses.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace Il2CppInspector.Reflection +{ + public class Assembly + { + // TODO: CustomAttributes + + // Name of the assembly + public string FullName { get; set; } + + // Entry point method for the assembly + public MethodInfo EntryPoint { get; set; } + + // List of types defined in the assembly + public List DefinedTypes { get; } = new List(); + + // Get a type from its string name + public Type GetType(string typeName) { + throw new NotImplementedException(); + } + } + + public abstract class MemberInfo + { + // Assembly that this member is defined in + public Assembly Assembly { get; set; } + + // Custom attributes for this member + public IEnumerable CustomAttributes { get; set; } + + // Type that this type is declared in for nested types + public Type DeclaringType { get; set; } + + // What sort of member this is, eg. method, field etc. + public MemberTypes MemberType { get; set; } + + // Name of the member + public string Name { get; set; } + + // TODO: GetCustomAttributes etc. + } + + public class Type : MemberInfo + { + // (not code attributes) + // Undefined if the Type represents a generic type parameter + public TypeAttributes Attributes { get; set; } + + // Type that this type inherits from + public Type BaseType { get; set; } + + // TODO: ContainsGenericParameters + + // Method that the type is declared in if this is a type parameter of a generic method + public MethodBase DeclaringMethod { get; set; } + + // Gets the type of the object encompassed or referred to by the current array, pointer or reference type + public Type ElementType { get; set; } + + // Type name including namespace + public string FullName { get; set; } + + // TODO: Generic stuff + + public bool HasElementType { get; set; } + public bool IsAbstract { get; set; } + public bool IsArray { get; set; } + public bool IsByRef { get; set; } + public bool IsClass { get; set; } + public bool IsEnum { get; set; } + public bool IsGenericParameter { get; set; } + public bool IsGenericType { get; set; } + public bool IsGenericTypeDefinition { get; set; } + public bool IsInterface { get; set; } + public bool IsNested { get; set; } + public bool IsNestedPrivate { get; set; } + public bool IsNestedPublic { get; set; } + public bool IsPointer { get; set; } + public bool IsPrimitive { get; set; } + public bool IsPublic { get; set; } + public bool IsSealed { get; set; } + public bool IsSerializable { get; set; } + public bool IsValueType { get; set; } + + public string Namespace { get; set; } + + // Number of dimensions of an array + public int GetArrayRank() => throw new NotImplementedException(); + + public List Constructors { get; set; } + + public List Inerfaces { get; set; } + + public List Members { get; set; } + + public List Methods { get; set; } + + public List Fields { get; set; } + + public List NestedTypes { get; set; } + + public List Properties { get; set; } + + // TODO: Custom attribute stuff + + public string[] GetEnumNames() => throw new NotImplementedException(); + + public Type GetEnumUnderlyingType() => throw new NotImplementedException(); + + public Array GetEnumValues() => throw new NotImplementedException(); + + // TODO: Event stuff + + // TODO: Generic stuff + } + + public abstract class MethodBase : MemberInfo + { + // (not code attributes) + public MethodAttributes Attributes { get; set; } + + // TODO: ContainsGenericParameters + } + + public class ConstructorInfo : MethodBase + { + // TODO + } + + public class MethodInfo : MethodBase + { + // TODO + } + + public class FieldInfo : MemberInfo + { + // TODO + } + + public class PropertyInfo : MemberInfo + { + // TODO + } + + public class CustomAttributeData + { + // TODO + } +}