Skip to content

Commit

Permalink
fix: OverrideVirtualWithBaseCallsBothVirtualAndBase etc. failing test…
Browse files Browse the repository at this point in the history
…s because Weaver Cmd/Rpc SubstitueMethods couldn't be accessed by inheriting classes
  • Loading branch information
miwarnec committed Jun 26, 2021
1 parent 74ae04d commit ff218ad
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ public static MethodDefinition SubstituteMethod(TypeDefinition td, MethodDefinit
string newName = RpcPrefix + md.Name;
MethodDefinition cmd = new MethodDefinition(newName, md.Attributes, md.ReturnType);

// force new usercode_cmd to be private.
// otherwise the generated User_Cmd could be assigned to UnityEvents in the Inspector
// (User_Cmd() is only called by Invoke_Cmd in this class)
// force the substitute method to be protected.
// -> public would show in the Inspector for UnityEvents as
// 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.IsPrivate = true;
cmd.IsFamily = true;

// add parameters
foreach (ParameterDefinition pd in md.Parameters)
Expand Down

0 comments on commit ff218ad

Please sign in to comment.