Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 450bb77

Browse files
committed
Use Harmony's FullDescription for hook parameter types
1 parent 0479102 commit 450bb77

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Hooks/HookInstance.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ public class HookInstance
1717
private static readonly StringBuilder evalOutput = new StringBuilder();
1818
private static readonly ScriptEvaluator scriptEvaluator = new ScriptEvaluator(new StringWriter(evalOutput));
1919

20+
static HookInstance()
21+
{
22+
scriptEvaluator.Run("using System;");
23+
scriptEvaluator.Run("using System.Reflection;");
24+
scriptEvaluator.Run("using System.Collections;");
25+
scriptEvaluator.Run("using System.Collections.Generic;");
26+
}
27+
2028
// Instance
2129

2230
public bool Enabled;
@@ -117,13 +125,12 @@ private string GenerateDefaultPatchSourceCode(MethodInfo targetMethod)
117125
if (targetMethod.ReturnType != typeof(void))
118126
codeBuilder.Append($", {targetMethod.ReturnType.FullName} __result");
119127

120-
int paramIdx = 0;
121128
var parameters = targetMethod.GetParameters();
129+
130+
int paramIdx = 0;
122131
foreach (var param in parameters)
123132
{
124-
Type pType = param.ParameterType;
125-
if (pType.IsByRef) pType = pType.GetElementType();
126-
codeBuilder.Append($", {pType.FullName} __{paramIdx}");
133+
codeBuilder.Append($", {param.ParameterType.FullDescription().Replace("&", "")} __{paramIdx}");
127134
paramIdx++;
128135
}
129136

@@ -177,6 +184,8 @@ private string GenerateDefaultPatchSourceCode(MethodInfo targetMethod)
177184

178185
codeBuilder.AppendLine("}");
179186

187+
//ExplorerCore.Log(codeBuilder.ToString());
188+
180189
return PatchSourceCode = codeBuilder.ToString();
181190
}
182191

0 commit comments

Comments
 (0)