diff --git a/Il2CppTests/TestExpectedResults/ArraysAndPointers.cs b/Il2CppTests/TestExpectedResults/ArraysAndPointers.cs index bccc3c8..064c735 100644 --- a/Il2CppTests/TestExpectedResults/ArraysAndPointers.cs +++ b/Il2CppTests/TestExpectedResults/ArraysAndPointers.cs @@ -1,8 +1,9 @@ // Image 0: mscorlib.dll - 0 // Image 1: ArraysAndPointers.dll - 1810 + // Namespace: Il2CppTests.TestSources -internal class Test // TypeDefIndex: 1811 +internal class Test // TypeDefIndex: 1813 { // Fields private int[] foo; // 0x08 @@ -10,25 +11,46 @@ internal class Test // TypeDefIndex: 1811 private float[][] arrayOfArrays; // 0x10 private float[,] twoDimensionalArray; // 0x14 private float[,,] threeDimensionalArray; // 0x18 - private int*[] arrayOfPointer; // 0x1C - private int** pointerToPointer; // 0x20 - private float*[][,,][] confusedElephant; // 0x24 + private unsafe int*[] arrayOfPointer; // 0x1C + private unsafe int** pointerToPointer; // 0x20 + private unsafe float*[][,,][] confusedElephant; // 0x24 + + // Properties + public unsafe int* PointerProperty { get; set; } // 0x00562EEC 0x00562EF4 + public unsafe int* this[int i] { get; } // 0x00562F10 + public unsafe int this[int* p] { get; } // 0x00562F18 + public unsafe float* this[float* fp] { get; } // 0x00562F20 // Nested types - private struct fixedSizeArrayStruct // TypeDefIndex: 1812 + private struct fixedSizeArrayStruct // TypeDefIndex: 1814 { // Fields - private fixed /* 0x000A6CAC */ int fixedSizeArray[0]; // 0x08 + private unsafe fixed /* 0x000A6C98 */ int fixedSizeArray[0]; // 0x08 // Nested types } + public unsafe delegate void OnUnsafe(int* ud); // TypeDefIndex: 1816; 0x00562F3C + + public class NestedUnsafe // TypeDefIndex: 1817 + { + // Constructors + public NestedUnsafe(); + + // Methods + private unsafe T* UnsafeGenericReturn(); + private unsafe void UnsafeGenericMethod(T* pt); + } + // Constructors - public Test(); // 0x00562BA0 + public unsafe Test(int* u); // 0x00562E78 // Methods - public int[] FooMethod(int[][] bar); // 0x00562AC8 - public int[,] BarMethod(int[,,] baz); // 0x00562B28 + public int[] FooMethod(int[][] bar); // 0x00562DA0 + public int[,] BarMethod(int[,,] baz); // 0x00562E00 + public unsafe void UnsafeMethod(int* unsafePointerArgument); // 0x00562EFC + public unsafe int* UnsafeReturnMethod(); // 0x00562F00 + public unsafe int* UnsafeMethod2(int* i); // 0x00562F08 } diff --git a/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x64.cs b/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x64.cs index 8e61a70..d8c4c0f 100644 --- a/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x64.cs +++ b/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x64.cs @@ -1,34 +1,56 @@ // Image 0: mscorlib.dll - 0 // Image 1: ArraysAndPointers.dll - 1810 + // Namespace: Il2CppTests.TestSources -internal class Test // TypeDefIndex: 1811 +internal class Test // TypeDefIndex: 1813 { // Fields private int[] foo; // 0x10 private int[] bar; // 0x20 private float[][] arrayOfArrays; // 0x30 private float[,] twoDimensionalArray; // 0x40 - private float[,,] threeDimensionalArray; // 0x10 - private int*[] arrayOfPointer; // 0x29 - private int** pointerToPointer; // 0x8047EC30 - private float*[][,,][] confusedElephant; // 0x00 + private float[,,] threeDimensionalArray; // 0x50 + private unsafe int*[] arrayOfPointer; // 0x10 + private unsafe int** pointerToPointer; // 0x19 + private unsafe float*[][,,][] confusedElephant; // 0x8047EDC0 + + // Properties + public unsafe int* PointerProperty { get; set; } // 0x00000001801513A0 0x00000001801140B0 + public unsafe int* this[int i] { get; } // 0x00000001800EA8C0 + public unsafe int this[int* p] { get; } // 0x00000001800EA8C0 + public unsafe float* this[float* fp] { get; } // 0x00000001800EA8C0 // Nested types - private struct fixedSizeArrayStruct // TypeDefIndex: 1812 + private struct fixedSizeArrayStruct // TypeDefIndex: 1814 { // Fields - private fixed /* 0x000000018000CC70 */ int fixedSizeArray[0]; // 0x10 + private unsafe fixed /* 0x000000018000C310 */ int fixedSizeArray[0]; // 0x10 // Nested types } + public unsafe delegate void OnUnsafe(int* ud); // TypeDefIndex: 1816; 0x00000001803E0E50 + + public class NestedUnsafe // TypeDefIndex: 1817 + { + // Constructors + public NestedUnsafe(); + + // Methods + private unsafe T* UnsafeGenericReturn(); + private unsafe void UnsafeGenericMethod(T* pt); + } + // Constructors - public Test(); // 0x00000001803E0EE0 + public unsafe Test(int* u); // 0x00000001803E1130 // Methods - public int[] FooMethod(int[][] bar); // 0x00000001803E0EA0 - public int[,] BarMethod(int[,,] baz); // 0x00000001803E0E50 + public int[] FooMethod(int[][] bar); // 0x00000001803E10F0 + public int[,] BarMethod(int[,,] baz); // 0x00000001803E10A0 + public unsafe void UnsafeMethod(int* unsafePointerArgument); // 0x00000001800EA7B0 + public unsafe int* UnsafeReturnMethod(); // 0x00000001800EA8C0 + public unsafe int* UnsafeMethod2(int* i); // 0x000000018012FC60 } diff --git a/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x86.cs b/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x86.cs index b83bf86..9ffd72c 100644 --- a/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x86.cs +++ b/Il2CppTests/TestExpectedResults/GameAssembly-ArraysAndPointers-x86.cs @@ -1,8 +1,9 @@ // Image 0: mscorlib.dll - 0 // Image 1: ArraysAndPointers.dll - 1810 + // Namespace: Il2CppTests.TestSources -internal class Test // TypeDefIndex: 1811 +internal class Test // TypeDefIndex: 1813 { // Fields private int[] foo; // 0x08 @@ -10,25 +11,46 @@ internal class Test // TypeDefIndex: 1811 private float[][] arrayOfArrays; // 0x10 private float[,] twoDimensionalArray; // 0x14 private float[,,] threeDimensionalArray; // 0x18 - private int*[] arrayOfPointer; // 0x1C - private int** pointerToPointer; // 0x20 - private float*[][,,][] confusedElephant; // 0x24 + private unsafe int*[] arrayOfPointer; // 0x1C + private unsafe int** pointerToPointer; // 0x20 + private unsafe float*[][,,][] confusedElephant; // 0x24 + + // Properties + public unsafe int* PointerProperty { get; set; } // 0x100EB040 0x100EB250 + public unsafe int* this[int i] { get; } // 0x100C5600 + public unsafe int this[int* p] { get; } // 0x100C5600 + public unsafe float* this[float* fp] { get; } // 0x100C5600 // Nested types - private struct fixedSizeArrayStruct // TypeDefIndex: 1812 + private struct fixedSizeArrayStruct // TypeDefIndex: 1814 { // Fields - private fixed /* 0x1000DE40 */ int fixedSizeArray[0]; // 0x08 + private unsafe fixed /* 0x1000D370 */ int fixedSizeArray[0]; // 0x08 // Nested types } + public unsafe delegate void OnUnsafe(int* ud); // TypeDefIndex: 1816; 0x1034DA60 + + public class NestedUnsafe // TypeDefIndex: 1817 + { + // Constructors + public NestedUnsafe(); + + // Methods + private unsafe T* UnsafeGenericReturn(); + private unsafe void UnsafeGenericMethod(T* pt); + } + // Constructors - public Test(); // 0x1034DAE0 + public unsafe Test(int* u); // 0x1034DD10 // Methods - public int[] FooMethod(int[][] bar); // 0x1034DAB0 - public int[,] BarMethod(int[,,] baz); // 0x1034DA60 + public int[] FooMethod(int[][] bar); // 0x1034DCE0 + public int[,] BarMethod(int[,,] baz); // 0x1034DC90 + public unsafe void UnsafeMethod(int* unsafePointerArgument); // 0x100C5530 + public unsafe int* UnsafeReturnMethod(); // 0x100C5600 + public unsafe int* UnsafeMethod2(int* i); // 0x10102390 } diff --git a/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x64.cs b/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x64.cs index 5b84b7d..d7627c9 100644 --- a/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x64.cs +++ b/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x64.cs @@ -14,7 +14,7 @@ internal class Test // TypeDefIndex: 1811 public string this[int i] { get; } // 0x00000001803E0E80 public string this[double d] { get; } // 0x00000001803E0E50 public string this[long l] { set; } // 0x00000001800EA7B0 - public string this[] { get; set; } // 0x00000001803E0EB0 0x00000001800EA7B0 + public string this[float f] { get; set; } // 0x00000001803E0EB0 0x00000001800EA7B0 public bool this[int i, int j] { get; } // 0x000000018010E420 // Constructors diff --git a/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x86.cs b/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x86.cs index 1cef894..583ae1f 100644 --- a/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x86.cs +++ b/Il2CppTests/TestExpectedResults/GameAssembly-Properties-x86.cs @@ -14,7 +14,7 @@ internal class Test // TypeDefIndex: 1811 public string this[int i] { get; } // 0x1034DA90 public string this[double d] { get; } // 0x1034DA60 public string this[long l] { set; } // 0x100C5530 - public string this[] { get; set; } // 0x1034DAC0 0x100C5530 + public string this[float f] { get; set; } // 0x1034DAC0 0x100C5530 public bool this[int i, int j] { get; } // 0x100E5880 // Constructors diff --git a/Il2CppTests/TestSources/ArraysAndPointers.cs b/Il2CppTests/TestSources/ArraysAndPointers.cs index a421fe5..63d484b 100644 --- a/Il2CppTests/TestSources/ArraysAndPointers.cs +++ b/Il2CppTests/TestSources/ArraysAndPointers.cs @@ -7,14 +7,14 @@ namespace Il2CppTests.TestSources { #pragma warning disable CS0169 - internal unsafe class Test + internal class Test { private int[] foo; private int[] bar = new int[10]; private struct fixedSizeArrayStruct { - private fixed int fixedSizeArray[25]; + private unsafe fixed int fixedSizeArray[25]; } private float[][] arrayOfArrays; @@ -25,10 +25,40 @@ namespace Il2CppTests.TestSources public int[,] BarMethod(int[,,] baz) => new int[5, 6]; - private int*[] arrayOfPointer; - private int** pointerToPointer; + // Unsafe fields + private unsafe int*[] arrayOfPointer; + private unsafe int** pointerToPointer; + private unsafe float*[][,,][] confusedElephant; - private float*[][,,][] confusedElephant; + // Unsafe constructor + public unsafe Test(int* u) {} + + // Unsafe delegate + public unsafe delegate void OnUnsafe(int*ud); + + // Unsafe property + public unsafe int* PointerProperty { get; set; } + + // Unsafe method (method with unsafe parameter) + public unsafe void UnsafeMethod(int* unsafePointerArgument) {} + + // Unsafe method (method with unsafe return type) + public unsafe int* UnsafeReturnMethod() => (int*) 0; + + // Unsafe method with both + public unsafe int* UnsafeMethod2(int* i) => i; + + // Unsafe indexers + public unsafe int* this[int i] => (int*) 0; + public unsafe int this[int* p] => 0; + public unsafe float* this[float* fp] => (float*) 0; + + // Unsafe generic type (unmanaged constraint introduced in C# 7.3) + public class NestedUnsafe where T : unmanaged + { + unsafe T* UnsafeGenericReturn() => null; + unsafe void UnsafeGenericMethod(T* pt) {} + } } #pragma warning restore CS0169 } \ No newline at end of file