Output: Add namespace exclusions

This commit is contained in:
Katy Coe
2019-10-31 01:16:25 +01:00
parent 21d0080862
commit a9b7b8d7af
3 changed files with 27 additions and 2 deletions

View File

@@ -15,6 +15,9 @@ namespace Il2CppInspector
{
private readonly Il2CppReflector model;
// Namespace prefixes whose contents should be skipped
public List<string> ExcludedNamespaces { get; set; }
public Il2CppDumper(Il2CppInspector proc) {
model = new Il2CppReflector(proc);
}
@@ -31,6 +34,10 @@ namespace Il2CppInspector
foreach (var type in model.Assemblies.SelectMany(x => x.DefinedTypes)) {
// Skip namespace and any children if requested
if (ExcludedNamespaces?.Any(x => x == type.Namespace || type.Namespace.StartsWith(x + ".")) ?? false)
continue;
// Type declaration
writer.Write($"\n// Namespace: {type.Namespace}\n");

View File

@@ -2,6 +2,7 @@
// All rights reserved
using System;
using System.Collections.Generic;
using System.IO;
namespace Il2CppInspector
@@ -49,10 +50,18 @@ namespace Il2CppInspector
if (il2cppInspectors == null)
Environment.Exit(1);
// Exclusions
var excludedNamespaces = new List<string> {
"System",
"UnityEngine",
"Mono",
"Microsoft.Win32"
};
// Write output file
int i = 0;
foreach (var il2cpp in il2cppInspectors)
new Il2CppDumper(il2cpp).WriteFile(outFile + (i++ > 0 ? "-" + (i-1) : ""));
new Il2CppDumper(il2cpp) {ExcludedNamespaces = excludedNamespaces}.WriteFile(outFile + (i++ > 0 ? "-" + (i-1) : ""));
}
}
}

View File

@@ -5,6 +5,7 @@
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
@@ -38,10 +39,18 @@ namespace Il2CppInspector
if (inspectors.Count == 0)
throw new Exception("Could not find any images in the IL2CPP binary");
// Exclusions
var excludedNamespaces = new List<string> {
"System",
"UnityEngine",
"Mono",
"Microsoft.Win32",
};
// Dump each image in the binary separately
int i = 0;
foreach (var il2cpp in inspectors)
new Il2CppDumper(il2cpp).WriteFile(testPath + @"\test-result" + (i++ > 0 ? "-" + (i - 1) : "") + ".cs");
new Il2CppDumper(il2cpp) {ExcludedNamespaces = excludedNamespaces}.WriteFile(testPath + @"\test-result" + (i++ > 0 ? "-" + (i - 1) : "") + ".cs");
// Compare test result with expected result
for (i = 0; i < inspectors.Count; i++) {