From 209f52f0ce432f92b0c441fda26fb16352c44e50 Mon Sep 17 00:00:00 2001 From: yck1509 Date: Thu, 26 Feb 2015 20:26:15 +0800 Subject: [PATCH] Exclude Settings class from renaming Fix #178 --- Confuser.Core/DnlibUtils.cs | 19 +++++++++++++++++++ Confuser.Renamer/AnalyzePhase.cs | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/Confuser.Core/DnlibUtils.cs b/Confuser.Core/DnlibUtils.cs index 25aa117..cfd3d06 100644 --- a/Confuser.Core/DnlibUtils.cs +++ b/Confuser.Core/DnlibUtils.cs @@ -133,6 +133,25 @@ namespace Confuser.Core { return false; } + /// + /// Determines whether the specified type is inherited from a base type. + /// + /// The type. + /// The full name of base type. + /// true if the specified type is inherited from a base type; otherwise, false. + public static bool InheritsFrom(this TypeDef type, string baseType) { + if (type.BaseType == null) + return false; + + TypeDef bas = type; + do { + bas = bas.BaseType.ResolveTypeDefThrow(); + if (bas.ReflectionFullName == baseType) + return true; + } while (bas.BaseType != null); + return false; + } + /// /// Determines whether the specified type implements the specified interface. /// diff --git a/Confuser.Renamer/AnalyzePhase.cs b/Confuser.Renamer/AnalyzePhase.cs index 5869a8f..4dfab70 100644 --- a/Confuser.Renamer/AnalyzePhase.cs +++ b/Confuser.Renamer/AnalyzePhase.cs @@ -122,6 +122,10 @@ namespace Confuser.Renamer { if (type.InheritsFromCorlib("System.Attribute")) { service.ReduceRenameMode(type, RenameMode.ASCII); } + + if (type.InheritsFrom("System.Configuration.SettingsBase")) { + service.SetCanRename(type, false); + } } void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, MethodDef method) {