对于标记`[BurstCompile]`的类型,除了类型名和函数名以外的仍然混淆

main
walon 2025-07-11 19:08:25 +08:00
parent 2887231df7
commit 083ddd3035
3 changed files with 17 additions and 15 deletions

View File

@ -23,5 +23,11 @@ namespace Obfuz.Editor
public const string ZluaLuaMarshalAsAttributeFullName = "Zlua.LuaMarshalAsAttribute"; public const string ZluaLuaMarshalAsAttributeFullName = "Zlua.LuaMarshalAsAttribute";
public const string BurstCompileFullName = "Unity.Burst.BurstCompileAttribute"; public const string BurstCompileFullName = "Unity.Burst.BurstCompileAttribute";
public const string DOTSCompilerGeneratedAttributeFullName = "Unity.Jobs.DOTSCompilerGeneratedAttribute";
public const string RuntimeInitializedOnLoadMethodAttributeFullName = "UnityEngine.RuntimeInitializeOnLoadMethodAttribute";
public const string BlackboardEnumAttributeFullName = "Unity.Behavior.BlackboardEnumAttribute";
public const string CompilerGeneratedAttributeFullName = "System.Runtime.CompilerServices.CompilerGeneratedAttribute";
} }
} }

View File

@ -153,10 +153,6 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
{ {
return true; return true;
} }
if (MetaUtil.HasBurstCompileAttribute(typeDef))
{
return true;
}
if (typeDef.DeclaringType != null) if (typeDef.DeclaringType != null)
{ {
return IsUnitySourceGeneratedAssemblyType(typeDef.DeclaringType); return IsUnitySourceGeneratedAssemblyType(typeDef.DeclaringType);
@ -191,6 +187,10 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
{ {
return false; return false;
} }
if (MetaUtil.HasBurstCompileAttribute(typeDef))
{
return false;
}
if (typeDef.Methods.Any(m => MetaUtil.HasRuntimeInitializeOnLoadMethodAttribute(m))) if (typeDef.Methods.Any(m => MetaUtil.HasRuntimeInitializeOnLoadMethodAttribute(m)))
{ {
return false; return false;
@ -213,7 +213,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
{ {
return false; return false;
} }
if (MetaUtil.HasBurstCompileAttribute(methodDef) || MetaUtil.HasDOTSCompilerGeneratedAttribute(methodDef)) if (MetaUtil.HasBurstCompileAttribute(methodDef) || MetaUtil.HasBurstCompileAttribute(methodDef.DeclaringType) || MetaUtil.HasDOTSCompilerGeneratedAttribute(methodDef))
{ {
return false; return false;
} }
@ -242,10 +242,6 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
{ {
return false; return false;
} }
if (MetaUtil.HasBurstCompileAttribute(fieldDef))
{
return false;
}
return true; return true;
} }

View File

@ -886,7 +886,7 @@ namespace Obfuz.Utils
public static bool HasCompilerGeneratedAttribute(IHasCustomAttribute obj) public static bool HasCompilerGeneratedAttribute(IHasCustomAttribute obj)
{ {
return obj.CustomAttributes.Find("System.Runtime.CompilerServices.CompilerGeneratedAttribute") != null; return obj.CustomAttributes.Find(ConstValues.CompilerGeneratedAttributeFullName) != null;
} }
public static bool HasEncryptFieldAttribute(IHasCustomAttribute obj) public static bool HasEncryptFieldAttribute(IHasCustomAttribute obj)
@ -896,27 +896,27 @@ namespace Obfuz.Utils
public static bool HasRuntimeInitializeOnLoadMethodAttribute(MethodDef method) public static bool HasRuntimeInitializeOnLoadMethodAttribute(MethodDef method)
{ {
return method.CustomAttributes.Find("UnityEngine.RuntimeInitializeOnLoadMethodAttribute") != null; return method.CustomAttributes.Find(ConstValues.RuntimeInitializedOnLoadMethodAttributeFullName) != null;
} }
public static bool HasBlackboardEnumAttribute(TypeDef typeDef) public static bool HasBlackboardEnumAttribute(TypeDef typeDef)
{ {
return typeDef.CustomAttributes.Find("Unity.Behavior.BlackboardEnumAttribute") != null; return typeDef.CustomAttributes.Find(ConstValues.BlackboardEnumAttributeFullName) != null;
} }
public static bool HasBurstCompileAttribute(IHasCustomAttribute obj) public static bool HasBurstCompileAttribute(IHasCustomAttribute obj)
{ {
return obj.CustomAttributes.Find("Unity.Burst.BurstCompileAttribute") != null; return obj.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null;
} }
public static bool HasDOTSCompilerGeneratedAttribute(IHasCustomAttribute obj) public static bool HasDOTSCompilerGeneratedAttribute(IHasCustomAttribute obj)
{ {
return obj.CustomAttributes.Find("Unity.Jobs.DOTSCompilerGeneratedAttribute") != null; return obj.CustomAttributes.Find(ConstValues.DOTSCompilerGeneratedAttributeFullName) != null;
} }
public static bool HasMicrosoftCodeAnalysisEmbeddedAttribute(IHasCustomAttribute obj) public static bool HasMicrosoftCodeAnalysisEmbeddedAttribute(IHasCustomAttribute obj)
{ {
return obj.CustomAttributes.Find("Microsoft.CodeAnalysis.EmbeddedAttribute") != null; return obj.CustomAttributes.Find(ConstValues.EmbeddedAttributeFullName) != null;
} }
} }
} }