diff --git a/Stripper.cs b/Stripper.cs index 3e81518..96b9272 100644 --- a/Stripper.cs +++ b/Stripper.cs @@ -11,6 +11,11 @@ public static void Strip(ModuleDefinition module) { StripType(type); } + + RemoveUncommonTypes(module, new[]{ + "FezGame.Components.MockAchievement", + "FezGame.Services.MockUser", + }); } private static void StripType(TypeDefinition type) @@ -33,5 +38,31 @@ private static void RemoveMethodBodiesFromType(TypeDefinition type) } } } + + private static void RemoveUncommonTypes(ModuleDefinition module, string[] namesOfTypesToRemove) + { + foreach(var type in module.Types) + { + // clean content of types that should be removed, + // so they're not used to generate hooks + if (namesOfTypesToRemove.Contains(type.FullName)) + { + type.Methods.Clear(); + } + + // Some methods will still reference them. + // Make sure they're removed as well. + var methodsToRemove = type.Methods.Where( + method => method.Parameters.Any( + parameter => namesOfTypesToRemove.Contains(parameter.ParameterType.FullName) + ) + ).ToList(); + + foreach(var method in methodsToRemove) + { + type.Methods.Remove(method); + } + } + } } }