From 1402a8a145838cf017aa15ca606119af53f2f442 Mon Sep 17 00:00:00 2001 From: Martin Karing Date: Sun, 13 Sep 2020 11:46:25 +0200 Subject: [PATCH] Fixing signature import for renamed references --- Confuser.Renamer/Analyzers/VTableAnalyzer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Confuser.Renamer/Analyzers/VTableAnalyzer.cs b/Confuser.Renamer/Analyzers/VTableAnalyzer.cs index 26c80e3..6a50066 100644 --- a/Confuser.Renamer/Analyzers/VTableAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/VTableAnalyzer.cs @@ -239,18 +239,18 @@ namespace Confuser.Renamer.Analyzers { service.AddReference(def, new TypeRefReference(typeRef, def)); } - private static GenericInstSig SetupSignatureReferences(INameService service, ICollection modules, ModuleDef module, GenericInstSig typeSig) { - var genericType = SetupSignatureReferences(service, modules, module, typeSig.GenericType); - var genericArguments = typeSig.GenericArguments.Select(a => SetupSignatureReferences(service, modules, module, a)).ToList(); - return new GenericInstSig(genericType, genericArguments); + private static void SetupSignatureReferences(INameService service, ICollection modules, + ModuleDef module, GenericInstSig typeSig) { + SetupSignatureReferences(service, modules, module, typeSig.GenericType); + foreach (var genericArgument in typeSig.GenericArguments) + SetupSignatureReferences(service, modules, module, genericArgument); } - private static T SetupSignatureReferences(INameService service, ICollection modules, ModuleDef module, T typeSig) where T : TypeSig { + private static void SetupSignatureReferences(INameService service, ICollection modules, ModuleDef module, TypeSig typeSig) { var asTypeRef = typeSig.TryGetTypeRef(); if (asTypeRef != null) { SetupTypeReference(service, modules, module, asTypeRef); } - return typeSig; } private static void SetupOverwriteReferences(INameService service, ICollection modules, VTableSlot slot, ModuleDef module) { @@ -266,10 +266,10 @@ namespace Confuser.Renamer.Analyzers { IMethodDefOrRef target; if (baseSlot.MethodDefDeclType is GenericInstSig declType) { - var signature = SetupSignatureReferences(service, modules, module, declType); - MemberRef targetRef = new MemberRefUser(module, baseMethodDef.Name, baseMethodDef.MethodSig, signature.ToTypeDefOrRef()); + MemberRef targetRef = new MemberRefUser(module, baseMethodDef.Name, baseMethodDef.MethodSig, declType.ToTypeDefOrRef()); targetRef = importer.Import(targetRef); service.AddReference(baseMethodDef, new MemberRefReference(targetRef, baseMethodDef)); + SetupSignatureReferences(service, modules, module, targetRef.DeclaringType.ToTypeSig() as GenericInstSig); target = targetRef; }