fix: OverrideVirtualWithBaseCallsBothVirtualAndBase etc. failing tests because Weaver Cmd/Rpc SubstitueMethods couldn't be accessed by inheriting classes

This commit is contained in:
vis2k 2021-06-26 13:17:18 +08:00
parent 74ae04d222
commit ff218adc17

View File

@ -35,11 +35,14 @@ public static MethodDefinition SubstituteMethod(TypeDefinition td, MethodDefinit
string newName = RpcPrefix + md.Name; string newName = RpcPrefix + md.Name;
MethodDefinition cmd = new MethodDefinition(newName, md.Attributes, md.ReturnType); MethodDefinition cmd = new MethodDefinition(newName, md.Attributes, md.ReturnType);
// force new usercode_cmd to be private. // force the substitute method to be protected.
// otherwise the generated User_Cmd could be assigned to UnityEvents in the Inspector // -> public would show in the Inspector for UnityEvents as
// (User_Cmd() is only called by Invoke_Cmd in this class) // User_CmdUsePotion() etc. but the user shouldn't use those.
// -> private would not allow inheriting classes to call it, see
// OverrideVirtualWithBaseCallsBothVirtualAndBase test.
// -> IL has no concept of 'protected', it's called IsFamily there.
cmd.IsPublic = false; cmd.IsPublic = false;
cmd.IsPrivate = true; cmd.IsFamily = true;
// add parameters // add parameters
foreach (ParameterDefinition pd in md.Parameters) foreach (ParameterDefinition pd in md.Parameters)