From f04604edc7f98f500079402c61769a3ce203e369 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Thu, 30 Jan 2020 08:00:58 +0100 Subject: [PATCH] Tests: Include array of derived closed generic type in GenericTypes --- .../GameAssembly-GenericTypes-x64.cs | 60 +++++++++---------- .../GameAssembly-GenericTypes-x86.cs | 60 +++++++++---------- Il2CppTests/TestGenericTypes.cs | 10 ++-- Il2CppTests/TestSources/GenericTypes.cs | 2 - 4 files changed, 65 insertions(+), 67 deletions(-) diff --git a/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x64.cs b/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x64.cs index 928f630..c326941 100644 --- a/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x64.cs +++ b/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x64.cs @@ -11,32 +11,32 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Image 0: mscorlib.dll - Assembly: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Types 0-1809 -// [assembly: AssemblyCompany] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyCopyright] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyDefaultAlias] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyDelaySign] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyDescription] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyFileVersion] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyInformationalVersion] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyKeyFile] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyProduct] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: AssemblyTitle] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: CLSCompliant] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: CompilationRelaxations] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: ComVisible] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: Debuggable] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: DefaultDependency] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: Guid] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: NeutralResourcesLanguage] // 0x000000018000E050-0x000000018000E2C0 -[assembly: RuntimeCompatibility] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: SatelliteContractVersion] // 0x000000018000E050-0x000000018000E2C0 -[assembly: StringFreezing] // 0x000000018000E050-0x000000018000E2C0 -// [assembly: TypeLibVersion] // 0x000000018000E050-0x000000018000E2C0 +// [assembly: AssemblyCompany] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyCopyright] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyDefaultAlias] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyDelaySign] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyDescription] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyFileVersion] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyInformationalVersion] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyKeyFile] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyProduct] // 0x000000018000E500-0x000000018000E770 +// [assembly: AssemblyTitle] // 0x000000018000E500-0x000000018000E770 +// [assembly: CLSCompliant] // 0x000000018000E500-0x000000018000E770 +// [assembly: CompilationRelaxations] // 0x000000018000E500-0x000000018000E770 +// [assembly: ComVisible] // 0x000000018000E500-0x000000018000E770 +// [assembly: Debuggable] // 0x000000018000E500-0x000000018000E770 +// [assembly: DefaultDependency] // 0x000000018000E500-0x000000018000E770 +// [assembly: Guid] // 0x000000018000E500-0x000000018000E770 +// [assembly: NeutralResourcesLanguage] // 0x000000018000E500-0x000000018000E770 +[assembly: RuntimeCompatibility] // 0x000000018000E500-0x000000018000E770 +// [assembly: SatelliteContractVersion] // 0x000000018000E500-0x000000018000E770 +[assembly: StringFreezing] // 0x000000018000E500-0x000000018000E770 +// [assembly: TypeLibVersion] // 0x000000018000E500-0x000000018000E770 // Image 1: GenericTypes.dll - Assembly: GenericTypes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - Types 1810-1832 -// [assembly: CompilationRelaxations] // 0x000000018000C150-0x000000018000C1B0 -// [assembly: Debuggable] // 0x000000018000C150-0x000000018000C1B0 -[assembly: RuntimeCompatibility] // 0x000000018000C150-0x000000018000C1B0 +// [assembly: CompilationRelaxations] // 0x000000018000C600-0x000000018000C660 +// [assembly: Debuggable] // 0x000000018000C600-0x000000018000C660 +[assembly: RuntimeCompatibility] // 0x000000018000C600-0x000000018000C660 internal static class Consts // TypeDefIndex: 100 { @@ -75,11 +75,11 @@ internal static class Consts // TypeDefIndex: 100 internal sealed class Locale // TypeDefIndex: 101 { // Constructors - private Locale() {} // 0x00000001800E3000-0x00000001800E3010 + private Locale() {} // 0x00000001800E5000-0x00000001800E5010 // Methods - public static string GetText(string msg) => default; // 0x0000000180124590-0x00000001801245A0 - public static string GetText(string fmt, params /* 0x00000001800090D0-0x00000001800090E0 */ object[] args) => default; // 0x00000001802C5BB0-0x00000001802C5C20 + public static string GetText(string msg) => default; // 0x00000001801273C0-0x00000001801273D0 + public static string GetText(string fmt, params /* 0x0000000180009200-0x0000000180009210 */ object[] args) => default; // 0x00000001802D5F20-0x00000001802D5F90 } namespace Il2CppTests.TestSources @@ -115,10 +115,10 @@ namespace Il2CppTests.TestSources internal class Test // TypeDefIndex: 1819 { // Constructors - public Test() {} // 0x00000001800E3000-0x00000001800E3010 + public Test() {} // 0x00000001800E5000-0x00000001800E5010 // Methods - public void GenericTypesTest() {} // 0x00000001803EDC60-0x00000001803EDC60 + public void GenericTypesTest() {} // 0x0000000180408870-0x0000000180408870 } internal class ConstrainedValueType // TypeDefIndex: 1820 @@ -169,7 +169,7 @@ namespace Il2CppTests.TestSources public ConstrainedRefType() {} // Methods - // [NullableContext] // 0x0000000180009190-0x00000001800091B0 + // [NullableContext] // 0x0000000180008EC0-0x0000000180008EE0 public void ConstrainedMethodNotNull(N notnullArgument, R bar) {} public void ConstrainedUnmanaged(U unmanagedArgument) where U : struct {} diff --git a/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x86.cs b/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x86.cs index eebd981..14e2190 100644 --- a/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x86.cs +++ b/Il2CppTests/TestExpectedResults/GameAssembly-GenericTypes-x86.cs @@ -11,32 +11,32 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Image 0: mscorlib.dll - Assembly: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Types 0-1809 -// [assembly: AssemblyCompany] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyCopyright] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyDefaultAlias] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyDelaySign] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyDescription] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyFileVersion] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyInformationalVersion] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyKeyFile] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyProduct] // 0x1000ED70-0x1000EF80 -// [assembly: AssemblyTitle] // 0x1000ED70-0x1000EF80 -// [assembly: CLSCompliant] // 0x1000ED70-0x1000EF80 -// [assembly: CompilationRelaxations] // 0x1000ED70-0x1000EF80 -// [assembly: ComVisible] // 0x1000ED70-0x1000EF80 -// [assembly: Debuggable] // 0x1000ED70-0x1000EF80 -// [assembly: DefaultDependency] // 0x1000ED70-0x1000EF80 -// [assembly: Guid] // 0x1000ED70-0x1000EF80 -// [assembly: NeutralResourcesLanguage] // 0x1000ED70-0x1000EF80 -[assembly: RuntimeCompatibility] // 0x1000ED70-0x1000EF80 -// [assembly: SatelliteContractVersion] // 0x1000ED70-0x1000EF80 -[assembly: StringFreezing] // 0x1000ED70-0x1000EF80 -// [assembly: TypeLibVersion] // 0x1000ED70-0x1000EF80 +// [assembly: AssemblyCompany] // 0x1000F350-0x1000F560 +// [assembly: AssemblyCopyright] // 0x1000F350-0x1000F560 +// [assembly: AssemblyDefaultAlias] // 0x1000F350-0x1000F560 +// [assembly: AssemblyDelaySign] // 0x1000F350-0x1000F560 +// [assembly: AssemblyDescription] // 0x1000F350-0x1000F560 +// [assembly: AssemblyFileVersion] // 0x1000F350-0x1000F560 +// [assembly: AssemblyInformationalVersion] // 0x1000F350-0x1000F560 +// [assembly: AssemblyKeyFile] // 0x1000F350-0x1000F560 +// [assembly: AssemblyProduct] // 0x1000F350-0x1000F560 +// [assembly: AssemblyTitle] // 0x1000F350-0x1000F560 +// [assembly: CLSCompliant] // 0x1000F350-0x1000F560 +// [assembly: CompilationRelaxations] // 0x1000F350-0x1000F560 +// [assembly: ComVisible] // 0x1000F350-0x1000F560 +// [assembly: Debuggable] // 0x1000F350-0x1000F560 +// [assembly: DefaultDependency] // 0x1000F350-0x1000F560 +// [assembly: Guid] // 0x1000F350-0x1000F560 +// [assembly: NeutralResourcesLanguage] // 0x1000F350-0x1000F560 +[assembly: RuntimeCompatibility] // 0x1000F350-0x1000F560 +// [assembly: SatelliteContractVersion] // 0x1000F350-0x1000F560 +[assembly: StringFreezing] // 0x1000F350-0x1000F560 +// [assembly: TypeLibVersion] // 0x1000F350-0x1000F560 // Image 1: GenericTypes.dll - Assembly: GenericTypes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - Types 1810-1832 -// [assembly: CompilationRelaxations] // 0x1000D210-0x1000D260 -// [assembly: Debuggable] // 0x1000D210-0x1000D260 -[assembly: RuntimeCompatibility] // 0x1000D210-0x1000D260 +// [assembly: CompilationRelaxations] // 0x1000D800-0x1000D850 +// [assembly: Debuggable] // 0x1000D800-0x1000D850 +[assembly: RuntimeCompatibility] // 0x1000D800-0x1000D850 internal static class Consts // TypeDefIndex: 100 { @@ -75,11 +75,11 @@ internal static class Consts // TypeDefIndex: 100 internal sealed class Locale // TypeDefIndex: 101 { // Constructors - private Locale() {} // 0x100C0000-0x100C0010 + private Locale() {} // 0x100C3000-0x100C3010 // Methods - public static string GetText(string msg) => default; // 0x100F8810-0x100F8820 - public static string GetText(string fmt, params /* 0x10009B80-0x10009BA0 */ object[] args) => default; // 0x10261620-0x10261670 + public static string GetText(string msg) => default; // 0x100FD9C0-0x100FD9D0 + public static string GetText(string fmt, params /* 0x10009C70-0x10009C90 */ object[] args) => default; // 0x10270000-0x10270050 } namespace Il2CppTests.TestSources @@ -115,10 +115,10 @@ namespace Il2CppTests.TestSources internal class Test // TypeDefIndex: 1819 { // Constructors - public Test() {} // 0x100C0000-0x100C0010 + public Test() {} // 0x100C3000-0x100C3010 // Methods - public void GenericTypesTest() {} // 0x103584B0-0x103584B0 + public void GenericTypesTest() {} // 0x1036D450-0x1036D450 } internal class ConstrainedValueType // TypeDefIndex: 1820 @@ -169,7 +169,7 @@ namespace Il2CppTests.TestSources public ConstrainedRefType() {} // Methods - // [NullableContext] // 0x10009B00-0x10009B20 + // [NullableContext] // 0x10009C10-0x10009C30 public void ConstrainedMethodNotNull(N notnullArgument, R bar) {} public void ConstrainedUnmanaged(U unmanagedArgument) where U : struct {} diff --git a/Il2CppTests/TestGenericTypes.cs b/Il2CppTests/TestGenericTypes.cs index 252a1d9..2c16978 100644 --- a/Il2CppTests/TestGenericTypes.cs +++ b/Il2CppTests/TestGenericTypes.cs @@ -6,6 +6,7 @@ using System; using System.IO; +using System.Linq; using Il2CppInspector.Reflection; using NUnit.Framework; @@ -32,9 +33,8 @@ namespace Il2CppInspector TypeInfo tBase = asm.GetType("Il2CppTests.TestSources.Base`2"); TypeInfo tDerived = asm.GetType("Il2CppTests.TestSources.Derived`1"); TypeInfo tDerivedBase = tDerived.BaseType; - - // TODO: array of Derived - // TypeInfo tDerivedArray + // TODO: Use a model GetType() once implemented + TypeInfo tDerivedArray = model.Types.First(t => t.Namespace == "Il2CppTests.TestSources" && t.Name == "Derived`1[System.Int32][]"); TypeInfo tT = tBase.GenericTypeParameters[0]; TypeInfo tU = tBase.GenericTypeParameters[1]; @@ -44,7 +44,7 @@ namespace Il2CppInspector DisplayGenericType(tBase, "Generic type definition Base"); DisplayGenericType(tDerived, "Derived"); DisplayGenericType(tDerivedBase, "Base type of Derived"); - //DisplayGenericType(tDerivedArray, "Array of Derived"); + DisplayGenericType(tDerivedArray, "Array of Derived"); DisplayGenericType(tT, "Type parameter T from Base"); DisplayGenericType(tU, "Type parameter U from Base"); DisplayGenericType(tF, "Field type, G>"); @@ -55,7 +55,7 @@ namespace Il2CppInspector (tBase, "Base`2[T,U]", true, true, true, false, -1), (tDerived, "Derived`1[V]", true, true, true, false, -1), (tDerivedBase, "Base`2[System.String,V]", true, false, true, false, -1), - //(tDerivedArray, "Derived`1[System.Int32][]", false, false, false, false, -1), + (tDerivedArray, "Derived`1[System.Int32][]", false, false, false, false, -1), (tT, "T", false, false, true, true, 0), (tU, "U", false, false, true, true, 1), (tF, "G`1[Derived`1[V]]", true, false, true, false, -1), diff --git a/Il2CppTests/TestSources/GenericTypes.cs b/Il2CppTests/TestSources/GenericTypes.cs index 4432aa9..d4f6f87 100644 --- a/Il2CppTests/TestSources/GenericTypes.cs +++ b/Il2CppTests/TestSources/GenericTypes.cs @@ -45,8 +45,6 @@ namespace Il2CppTests.TestSources Type tF = tDerived.GetField("F").FieldType; Type tNested = typeof(Derived<>.Nested); } - - private void forceTypeReferenceToDerivedIntArray(Derived typeRef) {} } // Constraints on type definitions