diff --git a/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs b/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs
index 3a7d13085..4834c0ed5 100644
--- a/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs
+++ b/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using Confuser.Core;
+using Confuser.Renamer.References;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
@@ -41,6 +42,10 @@ public void Analyze(ConfuserContext context, INameService service, IDnlibDef def
} else if ((instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) &&
((IMethod)instr.Operand).Name == "ToString") {
HandleEnum(context, service, method, i);
+ } else if (instr.OpCode.Code == Code.Ldstr) {
+ TypeDef typeDef = method.Module.FindReflection((string)instr.Operand);
+ if (typeDef != null)
+ service.AddReference(typeDef, new StringTypeReference(instr, typeDef));
}
}
}
diff --git a/Confuser.Renamer/Confuser.Renamer.csproj b/Confuser.Renamer/Confuser.Renamer.csproj
index 2a7c9f157..bb377d7b8 100644
--- a/Confuser.Renamer/Confuser.Renamer.csproj
+++ b/Confuser.Renamer/Confuser.Renamer.csproj
@@ -76,6 +76,7 @@
+
diff --git a/Confuser.Renamer/References/StringTypeReference.cs b/Confuser.Renamer/References/StringTypeReference.cs
new file mode 100644
index 000000000..4058f5dca
--- /dev/null
+++ b/Confuser.Renamer/References/StringTypeReference.cs
@@ -0,0 +1,25 @@
+using System;
+using Confuser.Core;
+using dnlib.DotNet;
+using dnlib.DotNet.Emit;
+
+namespace Confuser.Renamer.References {
+ public class StringTypeReference : INameReference {
+ private readonly Instruction reference;
+ private readonly TypeDef typeDef;
+
+ public StringTypeReference(Instruction reference, TypeDef typeDef) {
+ this.reference = reference;
+ this.typeDef = typeDef;
+ }
+
+ public bool UpdateNameReference(ConfuserContext context, INameService service) {
+ reference.Operand = typeDef.ReflectionFullName;
+ return true;
+ }
+
+ public bool ShouldCancelRename() {
+ return false;
+ }
+ }
+}
\ No newline at end of file