From 78cb337e0ce3997c40636bead8337d74e6bc2674 Mon Sep 17 00:00:00 2001 From: yck1509 Date: Tue, 13 Oct 2015 16:09:28 +0800 Subject: [PATCH] Fix IsVisibleOutside testing --- Confuser.Core/Project/ConfuserProject.cs | 23 +++++++++++++++++++++++ Confuser.Renamer/AnalyzePhase.cs | 8 ++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Confuser.Core/Project/ConfuserProject.cs b/Confuser.Core/Project/ConfuserProject.cs index 0969b6f0a..ed9441ff2 100644 --- a/Confuser.Core/Project/ConfuserProject.cs +++ b/Confuser.Core/Project/ConfuserProject.cs @@ -169,6 +169,17 @@ public enum SettingItemAction { /// /// or public class SettingItem : Dictionary { + /// + /// Initialize this setting item instance + /// + /// The protection id + /// The action to take + /// Inherits protection + public SettingItem(string id = null, SettingItemAction action = SettingItemAction.Add) { + Id = id; + Action = action; + } + /// /// The identifier of component /// @@ -239,6 +250,18 @@ internal void Load(XmlElement elem) { /// A rule that control how s are applied to module /// public class Rule : List> { + /// + /// Initialize this rule instance + /// + /// The pattern + /// The preset + /// Inherits protection + public Rule(string pattern = "true", ProtectionPreset preset = ProtectionPreset.None, bool inherit = false) { + Pattern = pattern; + Preset = preset; + Inherit = inherit; + } + /// /// Gets or sets the pattern that determine the target components of the rule. /// diff --git a/Confuser.Renamer/AnalyzePhase.cs b/Confuser.Renamer/AnalyzePhase.cs index 0ed257372..4083b59ca 100644 --- a/Confuser.Renamer/AnalyzePhase.cs +++ b/Confuser.Renamer/AnalyzePhase.cs @@ -157,7 +157,7 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, MethodDef method) { if (method.DeclaringType.IsVisibleOutside() && (method.IsFamily || method.IsFamilyOrAssembly || method.IsPublic) && - !IsVisibleOutside(context, parameters, method)) + IsVisibleOutside(context, parameters, method)) service.SetCanRename(method, false); else if (method.IsRuntimeSpecialName) @@ -176,7 +176,7 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field) { if (field.DeclaringType.IsVisibleOutside() && (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) && - !IsVisibleOutside(context, parameters, field)) + IsVisibleOutside(context, parameters, field)) service.SetCanRename(field, false); else if (field.IsRuntimeSpecialName) @@ -194,7 +194,7 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property) { if (property.DeclaringType.IsVisibleOutside() && - !IsVisibleOutside(context, parameters, property)) + IsVisibleOutside(context, parameters, property)) service.SetCanRename(property, false); else if (property.IsRuntimeSpecialName) @@ -212,7 +212,7 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) { if (evt.DeclaringType.IsVisibleOutside() && - !IsVisibleOutside(context, parameters, evt)) + IsVisibleOutside(context, parameters, evt)) service.SetCanRename(evt, false); else if (evt.IsRuntimeSpecialName)