Fix Hook.Patch confusing .ctor with .cctor
This commit is contained in:
@@ -39,7 +39,7 @@ namespace TestProject.LuaCs
|
||||
if (patchId != null) args.Add(Stringify(patchId));
|
||||
args.Add(Stringify(className));
|
||||
args.Add(Stringify(methodName));
|
||||
if (parameters != null && parameters.Length > 0)
|
||||
if (parameters != null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("{ ");
|
||||
@@ -101,7 +101,7 @@ namespace TestProject.LuaCs
|
||||
end
|
||||
", LuaCsHook.HookMethodType.Before);
|
||||
Assert.Equal(DataType.String, returnValue.Type);
|
||||
return new(returnValue.String, () => luaCs.RemovePrefix<T>(returnValue.String, methodName));
|
||||
return new(returnValue.String, () => luaCs.RemovePrefix<T>(returnValue.String, methodName, parameters));
|
||||
}
|
||||
|
||||
public static PatchHandle AddPostfix<T>(this LuaCsSetup luaCs, string body, string methodName, string[]? parameters = null, string? patchId = null)
|
||||
@@ -113,7 +113,7 @@ namespace TestProject.LuaCs
|
||||
end
|
||||
", LuaCsHook.HookMethodType.After);
|
||||
Assert.Equal(DataType.String, returnValue.Type);
|
||||
return new(returnValue.String, () => luaCs.RemovePostfix<T>(returnValue.String, methodName));
|
||||
return new(returnValue.String, () => luaCs.RemovePostfix<T>(returnValue.String, methodName, parameters));
|
||||
}
|
||||
|
||||
public static bool RemovePrefix<T>(this LuaCsSetup luaCs, string patchId, string methodName, string[]? parameters = null)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Barotrauma;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MoonSharp.Interpreter;
|
||||
using System;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@@ -345,10 +346,10 @@ namespace TestProject.LuaCs
|
||||
{
|
||||
using var postfixHandle = luaCs.AddPostfix<PatchTargetConstructor>(@$"
|
||||
instance.Ctor = {(int)PatchTargetConstructor.CtorType.Patched}
|
||||
", ".ctor");
|
||||
", ".ctor", Array.Empty<string>());
|
||||
using var prefixHandle = luaCs.AddPrefix<PatchTargetConstructor>(@$"
|
||||
instance.PrefixRan = true
|
||||
", ".ctor");
|
||||
", ".ctor", Array.Empty<string>());
|
||||
var target = new PatchTargetConstructor();
|
||||
Assert.Equal(PatchTargetConstructor.CtorType.Patched, target.Ctor);
|
||||
Assert.True(target.PrefixRan);
|
||||
|
||||
Reference in New Issue
Block a user