From a833cf26e1d4a6f4dc35bbb91bc71640d102fc85 Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 28 Jun 2025 10:49:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMonoBehavoiur=E5=92=8CScripta?= =?UTF-8?q?bleObject=E7=9A=84=E5=B1=9E=E6=80=A7=E6=B2=A1=E6=9C=89=E6=B7=B7?= =?UTF-8?q?=E6=B7=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs | 6 +++--- Editor/Utils/MetaUtil.cs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs b/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs index 7ecefbe..6b0fb9e 100644 --- a/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs +++ b/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs @@ -123,14 +123,14 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies }; private readonly CachedDictionary _computeDeclaringTypeDisableAllMemberRenamingCache; - private readonly CachedDictionary _isInheritScriptCache; + private readonly CachedDictionary _isSerializableCache; private readonly CachedDictionary _isInheritFromMonoBehaviourCache; private readonly CachedDictionary _isScriptOrSerializableTypeCache; public UnityRenamePolicy() { _computeDeclaringTypeDisableAllMemberRenamingCache = new CachedDictionary(ComputeDeclaringTypeDisableAllMemberRenaming); - _isInheritScriptCache = new CachedDictionary(MetaUtil.IsScriptType); + _isSerializableCache = new CachedDictionary(MetaUtil.IsSerializableType); _isInheritFromMonoBehaviourCache = new CachedDictionary(MetaUtil.IsInheritFromMonoBehaviour); _isScriptOrSerializableTypeCache = new CachedDictionary(MetaUtil.IsScriptOrSerializableType); } @@ -252,7 +252,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies public override bool NeedRename(PropertyDef propertyDef) { TypeDef typeDef = propertyDef.DeclaringType; - if (_isScriptOrSerializableTypeCache.GetValue(typeDef)) + if (_isSerializableCache.GetValue(typeDef)) { bool isGetterPublic = propertyDef.GetMethod != null && propertyDef.GetMethod.IsPublic && !propertyDef.GetMethod.IsStatic; bool isSetterPublic = propertyDef.SetMethod != null && propertyDef.SetMethod.IsPublic && !propertyDef.SetMethod.IsStatic; diff --git a/Editor/Utils/MetaUtil.cs b/Editor/Utils/MetaUtil.cs index 1212da4..0f20e11 100644 --- a/Editor/Utils/MetaUtil.cs +++ b/Editor/Utils/MetaUtil.cs @@ -177,6 +177,11 @@ namespace Obfuz.Utils return false; } + public static bool IsSerializableType(TypeDef type) + { + return type.IsSerializable; + } + public static bool IsScriptOrSerializableType(TypeDef type) { return type.IsSerializable || IsScriptType(type);