Skip to content

Commit

Permalink
feat: Commands no longer need to start with Cmd (#263)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Pacheco <paul.pacheco@aa.com>
  • Loading branch information
paulpach and paulpach committed Jul 12, 2020
1 parent 50e7fa6 commit 9578e19
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 26 deletions.
6 changes: 0 additions & 6 deletions Assets/Mirror/Editor/Weaver/Processors/CommandProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ static void AddSenderConnection(MethodDefinition method, ILProcessor worker)

public static bool ProcessMethodsValidateCommand(MethodDefinition md)
{
if (!md.Name.StartsWith("Cmd"))
{
Weaver.Error($"{md.Name} must start with Cmd. Consider renaming it to Cmd{md.Name}", md);
return false;
}

if (md.IsStatic)
{
Weaver.Error($"{md.Name} cannot be static", md);
Expand Down
6 changes: 0 additions & 6 deletions Assets/Mirror/Tests/Editor/Weaver/WeaverCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ public void CommandValid()
Assert.That(weaverErrors, Is.Empty);
}

[Test]
public void CommandStartsWithCmd()
{
Assert.That(weaverErrors, Contains.Item("DoesntStartWithCmd must start with Cmd. Consider renaming it to CmdDoesntStartWithCmd (at System.Void WeaverCommandTests.CommandStartsWithCmd.CommandStartsWithCmd::DoesntStartWithCmd())"));
}

[Test]
public void CommandCantBeStatic()
{
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Mirror/Tests/Runtime/ClientServerComponentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void CheckNotHost()
[UnityTest]
public IEnumerator Command() => RunAsync(async () =>
{
clientComponent.CmdTest(1, "hello");
clientComponent.Test(1, "hello");
await WaitFor(() => serverComponent.cmdArg1 != 0);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirror/Tests/Runtime/HostComponentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public void CommandWithoutAuthority()
// only authorized clients can call command
Assert.Throws<UnauthorizedAccessException>(() =>
{
rpcComponent2.CmdTest(1, "hello");
rpcComponent2.Test(1, "hello");
});

}

[UnityTest]
public IEnumerator Command() => RunAsync(async () =>
{
component.CmdTest(1, "hello");
component.Test(1, "hello");
await WaitFor(() => component.cmdArg1 != 0);
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Tests/Runtime/MockComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class MockComponent : NetworkBehaviour
public string cmdArg2;

[Command]
public void CmdTest(int arg1, string arg2)
public void Test(int arg1, string arg2)
{
this.cmdArg1 = arg1;
this.cmdArg2 = arg2;
Expand Down

0 comments on commit 9578e19

Please sign in to comment.