Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for type name when renaming properties and methods from the deobf map #113

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading