fix: 修复ScriptObject中事件函数名默认未被禁用混淆的bug

pull/30/head
walon 2025-10-08 22:25:01 +08:00
parent 747ee88fd3
commit b40a063582
1 changed files with 3 additions and 3 deletions

View File

@ -124,14 +124,14 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
private readonly CachedDictionary<TypeDef, bool> _computeDeclaringTypeDisableAllMemberRenamingCache; private readonly CachedDictionary<TypeDef, bool> _computeDeclaringTypeDisableAllMemberRenamingCache;
private readonly CachedDictionary<TypeDef, bool> _isSerializableCache; private readonly CachedDictionary<TypeDef, bool> _isSerializableCache;
private readonly CachedDictionary<TypeDef, bool> _isInheritFromMonoBehaviourCache; private readonly CachedDictionary<TypeDef, bool> _isInheritFromMonoBehaviourOrScriptableObjectCache;
private readonly CachedDictionary<TypeDef, bool> _isScriptOrSerializableTypeCache; private readonly CachedDictionary<TypeDef, bool> _isScriptOrSerializableTypeCache;
public UnityRenamePolicy() public UnityRenamePolicy()
{ {
_computeDeclaringTypeDisableAllMemberRenamingCache = new CachedDictionary<TypeDef, bool>(ComputeDeclaringTypeDisableAllMemberRenaming); _computeDeclaringTypeDisableAllMemberRenamingCache = new CachedDictionary<TypeDef, bool>(ComputeDeclaringTypeDisableAllMemberRenaming);
_isSerializableCache = new CachedDictionary<TypeDef, bool>(MetaUtil.IsSerializableType); _isSerializableCache = new CachedDictionary<TypeDef, bool>(MetaUtil.IsSerializableType);
_isInheritFromMonoBehaviourCache = new CachedDictionary<TypeDef, bool>(MetaUtil.IsInheritFromMonoBehaviour); _isInheritFromMonoBehaviourOrScriptableObjectCache = new CachedDictionary<TypeDef, bool>(MetaUtil.IsScriptType);
_isScriptOrSerializableTypeCache = new CachedDictionary<TypeDef, bool>(MetaUtil.IsScriptOrSerializableType); _isScriptOrSerializableTypeCache = new CachedDictionary<TypeDef, bool>(MetaUtil.IsScriptOrSerializableType);
} }
@ -201,7 +201,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
public override bool NeedRename(MethodDef methodDef) public override bool NeedRename(MethodDef methodDef)
{ {
TypeDef typeDef = methodDef.DeclaringType; TypeDef typeDef = methodDef.DeclaringType;
if (s_monoBehaviourEvents.Contains(methodDef.Name) && _isInheritFromMonoBehaviourCache.GetValue(typeDef)) if (s_monoBehaviourEvents.Contains(methodDef.Name) && _isInheritFromMonoBehaviourOrScriptableObjectCache.GetValue(typeDef))
{ {
return false; return false;
} }