Skip to content

Commit

Permalink
fix: weaver Cmd/Rpc/Target prefix check is no longer trash (#707)
Browse files Browse the repository at this point in the history
* fix: weaver Cmd prefix check should not allow methods with names shorter than 3 characters.

* fix: weaver Rpc prefix check should not allow methods with names shorter than 3 characters.

* fix: weaver Target prefix check should not allow methods with names shorter than 6 characters.

* Update Assets/Mirror/Editor/Weaver/Processors/CommandProcessor.cs

Co-Authored-By: rodolphito <rodol@rivalrebels.com>

* Update Assets/Mirror/Editor/Weaver/Processors/TargetRpcProcessor.cs

Co-Authored-By: rodolphito <rodol@rivalrebels.com>

* Update Assets/Mirror/Editor/Weaver/Processors/RpcProcessor.cs

Co-Authored-By: rodolphito <rodol@rivalrebels.com>
  • Loading branch information
atlv24 authored and paulpach committed Apr 4, 2019
1 parent 9895647 commit 699a261
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Assets/Mirror/Editor/Weaver/Processors/CommandProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static MethodDefinition ProcessCommandInvoke(TypeDefinition td, MethodDef

public static bool ProcessMethodsValidateCommand(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
{
if (md.Name.Length > 2 && md.Name.Substring(0, 3) != "Cmd")
if (!md.Name.StartsWith("Cmd"))
{
Weaver.Error("Command function [" + td.FullName + ":" + md.Name + "] doesnt have 'Cmd' prefix");
return false;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Editor/Weaver/Processors/RpcProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static MethodDefinition ProcessRpcCall(TypeDefinition td, MethodDefinitio

public static bool ProcessMethodsValidateRpc(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
{
if (md.Name.Length > 2 && md.Name.Substring(0, 3) != "Rpc")
if (!md.Name.StartsWith("Rpc"))
{
Weaver.Error("Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Rpc' prefix");
return false;
Expand Down
5 changes: 1 addition & 4 deletions Assets/Mirror/Editor/Weaver/Processors/TargetRpcProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ public static MethodDefinition ProcessTargetRpcCall(TypeDefinition td, MethodDef

public static bool ProcessMethodsValidateTargetRpc(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
{
const string targetPrefix = "Target";
int prefixLen = targetPrefix.Length;

if (md.Name.Length > prefixLen && md.Name.Substring(0, prefixLen) != targetPrefix)
if (!md.Name.StartsWith("Target"))
{
Weaver.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Target' prefix");
return false;
Expand Down

0 comments on commit 699a261

Please sign in to comment.