diff --git a/Editor/ObfusPasses/SymbolObfus/ReflectionCompatibilityDetector.cs b/Editor/ObfusPasses/SymbolObfus/ReflectionCompatibilityDetector.cs index b78b0c6..08aae89 100644 --- a/Editor/ObfusPasses/SymbolObfus/ReflectionCompatibilityDetector.cs +++ b/Editor/ObfusPasses/SymbolObfus/ReflectionCompatibilityDetector.cs @@ -190,17 +190,25 @@ namespace Obfuz.ObfusPasses.SymbolObfus private void AnalyzeEnum(IMethod method, TypeDef typeDef) { const int extraSearchInstructionCount = 3; - TypeDef parseType = GetMethodGenericParameter(method)?.ToTypeDefOrRef()?.ResolveTypeDef(); + TypeSig parseTypeSig = GetMethodGenericParameter(method); + TypeDef parseType = parseTypeSig?.ToTypeDefOrRef().ResolveTypeDef(); switch (method.Name) { case "Parse": { - if (parseType != null) + if (parseTypeSig != null) { // Enum.Parse(string name) or Enum.Parse(string name, bool caseInsensitive) - if (IsAnyEnumItemRenamed(parseType)) + if (parseType != null) { - Debug.LogError($"[ReflectionCompatibilityDetector] Reflection compatibility issue in {_curCallingMethod}: Enum.Parse field of T:{parseType.FullName} is renamed."); + if (IsAnyEnumItemRenamed(parseType)) + { + Debug.LogError($"[ReflectionCompatibilityDetector] Reflection compatibility issue in {_curCallingMethod}: Enum.Parse field of T:{parseType.FullName} is renamed."); + } + } + else + { + Debug.LogWarning($"[ReflectionCompatibilityDetector] Reflection compatibility issue in {_curCallingMethod}: Enum.Parse field of T should not be renamed."); } } else @@ -220,12 +228,19 @@ namespace Obfuz.ObfusPasses.SymbolObfus } case "TryParse": { - if (parseType != null) + if (parseTypeSig != null) { // Enum.TryParse(string name, out T result) or Enum.TryParse(string name, bool ignoreCase, out T result) - if (IsAnyEnumItemRenamed(parseType)) + if (parseType != null) { - Debug.LogError($"[ReflectionCompatibilityDetector] Reflection compatibility issue in {_curCallingMethod}: Enum.TryParse field of T:{parseType.FullName} is renamed."); + if (IsAnyEnumItemRenamed(parseType)) + { + Debug.LogError($"[ReflectionCompatibilityDetector] Reflection compatibility issue in {_curCallingMethod}: Enum.TryParse field of T:{parseType.FullName} is renamed."); + } + } + else + { + Debug.LogWarning($"[ReflectionCompatibilityDetector] Reflection compatibility issue in {_curCallingMethod}: Enum.TryParse field of T should not be renamed."); } } else