Skip to content

Commit

Permalink
Account for type name when renaming properties and methods from the d…
Browse files Browse the repository at this point in the history
…eobf map (#113)
  • Loading branch information
thegu5 authored Feb 25, 2024
1 parent a342054 commit 8ea82dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,18 @@ private string UnmangleMethodNameWithSignature()
{
var unmangleMethodNameWithSignature = ProduceMethodSignatureBase() + "_" + DeclaringType.Methods
.Where(ParameterSignatureMatchesThis).TakeWhile(it => it != this).Count();

if (DeclaringType.AssemblyContext.GlobalContext.Options.RenameMap.TryGetValue(
DeclaringType.NewType.GetNamespacePrefix() + "." + DeclaringType.NewType.Name + "::" + unmangleMethodNameWithSignature, out var newNameByType))
{
unmangleMethodNameWithSignature = newNameByType;
}
else if (DeclaringType.AssemblyContext.GlobalContext.Options.RenameMap.TryGetValue(
DeclaringType.NewType.GetNamespacePrefix() + "::" + unmangleMethodNameWithSignature, out var newName))
{
unmangleMethodNameWithSignature = newName;
}

return unmangleMethodNameWithSignature;
}

Expand Down
10 changes: 9 additions & 1 deletion Il2CppInterop.Generator/Passes/Pass70GenerateProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ private static string UnmanglePropertyName(AssemblyRewriteContext assemblyContex
var unmanglePropertyName = baseName + "_" + index;

if (assemblyContext.GlobalContext.Options.RenameMap.TryGetValue(
declaringType.GetNamespacePrefix() + "::" + unmanglePropertyName, out var newName))
declaringType.GetNamespacePrefix() + "." + declaringType.Name + "::" + unmanglePropertyName, out var newNameByType))
{
unmanglePropertyName = newNameByType;
}
else if (assemblyContext.GlobalContext.Options.RenameMap.TryGetValue(
declaringType.GetNamespacePrefix() + "::" + unmanglePropertyName, out var newName))
{
unmanglePropertyName = newName;
}


return unmanglePropertyName;
}
Expand Down

0 comments on commit 8ea82dd

Please sign in to comment.