From f134b88c13a4a0ac5a75043bd8394c4f13952561 Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 27 May 2025 10:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20ObfuzIgnoreAttribute.Apply?= =?UTF-8?q?ToMembers=E5=B1=9E=E6=80=A7=EF=BC=8C=E5=9B=A0=E4=B8=BA=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=BF=85=E8=A6=81=EF=BC=8C=E6=AD=A3=E5=B8=B8=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=9D=A5=E8=AF=B4=E5=BA=94=E8=AF=A5=E6=98=AFApplyToMe?= =?UTF-8?q?mbers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/Utils/MetaUtil.cs | 26 ++----------------- .../Runtime/ObfuzIgnoreAttribute.cs | 2 -- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs b/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs index 8d2525c..470c943 100644 --- a/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs +++ b/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs @@ -811,25 +811,6 @@ namespace Obfuz.Utils return scope; } - //public static ObfuzScope? GetSelfOrInheritObfuzIgnoreScope(TypeDef typeDef) - //{ - // TypeDef cur = typeDef; - // while (cur != null) - // { - // var ca = cur.CustomAttributes?.FirstOrDefault(c => c.AttributeType.FullName == "Obfuz.ObfuzIgnoreAttribute"); - // if (ca != null) - // { - // var scope = (ObfuzScope)ca.ConstructorArguments[0].Value; - // CANamedArgument inheritByNestedTypesArg = ca.GetNamedArgument("ApplyToMembers", false); - // bool inheritByNestedTypes = inheritByNestedTypesArg == null || (bool)inheritByNestedTypesArg.Value; - // return inheritByNestedTypes ? (ObfuzScope?) scope : null; - // } - // cur = cur.DeclaringType; - // } - // return null; - //} - - public static bool HasObfuzIgnoreScope(IHasCustomAttribute obj, ObfuzScope targetScope) { ObfuzScope? objScope = GetObfuzIgnoreScope(obj); @@ -869,16 +850,13 @@ namespace Obfuz.Utils var scope = (ObfuzScope)ca.ConstructorArguments[0].Value; if (cur != typeDef) { - CANamedArgument applyToNestedTypesArg = ca.GetNamedArgument(cur == typeDef ? "ApplyToMembers" : "ApplyToNestedTypes", false); + CANamedArgument applyToNestedTypesArg = ca.GetNamedArgument("ApplyToNestedTypes", false); if (applyToNestedTypesArg != null && !(bool)applyToNestedTypesArg.Value) { return false; } } - - CANamedArgument inheritByNestedTypesArg = ca.GetNamedArgument("ApplyToMembers", false); - bool inheritByNestedTypes = inheritByNestedTypesArg == null || (bool)inheritByNestedTypesArg.Value; - return inheritByNestedTypes && (scope & targetScope) != 0; + return (scope & targetScope) != 0; } cur = cur.DeclaringType; } diff --git a/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs b/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs index 99fea04..3464091 100644 --- a/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs +++ b/com.code-philosophy.obfuz/Runtime/ObfuzIgnoreAttribute.cs @@ -12,8 +12,6 @@ namespace Obfuz { public ObfuzScope Scope { get; set; } - public bool ApplyToMembers { get; set; } = true; - public bool ApplyToNestedTypes { get; set; } = true; public ObfuzIgnoreAttribute(ObfuzScope scope = ObfuzScope.All)