diff --git a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs index e3990b4..2c7b53a 100644 --- a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs +++ b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs @@ -144,6 +144,10 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return true; } + if (MetaUtil.HasBurstCompileAttribute(typeDef)) + { + return true; + } if (typeDef.DeclaringType != null) { return IsUnitySourceGeneratedAssemblyType(typeDef.DeclaringType); @@ -151,13 +155,34 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies return false; } + private bool DoesDeclaringTypeDisableAllMemberRenaming(TypeDef typeDef) + { + if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef)) + { + return true; + } + if (IsUnitySourceGeneratedAssemblyType(typeDef)) + { + return true; + } + if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) + { + return true; + } + if (IsUnitySourceGeneratedAssemblyType(typeDef)) + { + return true; + } + return false; + } + public override bool NeedRename(TypeDef typeDef) { if (MetaUtil.IsScriptType(typeDef)) { return false; } - if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) + if (DoesDeclaringTypeDisableAllMemberRenaming(typeDef)) { return false; } @@ -165,14 +190,6 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return false; } - if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef)) - { - return false; - } - if (IsUnitySourceGeneratedAssemblyType(typeDef)) - { - return false; - } return true; } @@ -183,7 +200,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return false; } - if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) + if (DoesDeclaringTypeDisableAllMemberRenaming(typeDef)) { return false; } @@ -191,9 +208,9 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return false; } - if (IsUnitySourceGeneratedAssemblyType(typeDef)) + if (MetaUtil.HasBurstCompileAttribute(methodDef)) { - return false; + return true; } return true; } @@ -205,15 +222,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return !MetaUtil.IsSerializableField(fieldDef); } - if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) - { - return false; - } - if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef)) - { - return false; - } - if (IsUnitySourceGeneratedAssemblyType(typeDef)) + if (DoesDeclaringTypeDisableAllMemberRenaming(typeDef)) { return false; } diff --git a/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs b/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs index 0da450a..3576821 100644 --- a/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs +++ b/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs @@ -984,5 +984,10 @@ namespace Obfuz.Utils { return typeDef.CustomAttributes.Find("Unity.Behavior.BlackboardEnumAttribute") != null; } + + public static bool HasBurstCompileAttribute(IHasCustomAttribute obj) + { + return obj.CustomAttributes.Find("Unity.Burst.BurstCompileAttribute") != null; + } } }