Skip to content

Commit

Permalink
feat: ClientRpc no longer need Rpc prefix (#2086)
Browse files Browse the repository at this point in the history
Instead of doing
```cs
[ClientRpc]
public void RpcPepe() {}
```

You can now do
```cs
[ClientRpc]
public void Pepe() {}
```

We actually tried to remove them a while ago. The way the weaver worked
back then caused an infinite recursion.

Since the Command rewrite that allows virtuals, this is no longer
a problem.  So we can drop this requirement.

Co-authored-by: Paul Pacheco <paul.pacheco@aa.com>
  • Loading branch information
paulpach and paulpach committed Jul 12, 2020
1 parent d89ac9f commit eb93c34
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
6 changes: 0 additions & 6 deletions Assets/Mirror/Editor/Weaver/Processors/RpcProcessor.cs
Expand Up @@ -112,12 +112,6 @@ public static MethodDefinition ProcessRpcCall(TypeDefinition td, MethodDefinitio

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

if (md.IsStatic)
{
Weaver.Error($"{md.Name} must not be static", md);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirror/Tests/Editor/ClientRpcTest.cs
Expand Up @@ -8,7 +8,7 @@ class ClientRpcBehaviour : NetworkBehaviour
public event Action<int> onSendInt;

[ClientRpc]
public void RpcSendInt(int someInt)
public void SendInt(int someInt)
{
onSendInt?.Invoke(someInt);
}
Expand Down Expand Up @@ -40,7 +40,7 @@ public void RpcIsCalled()
callCount++;
Assert.That(incomingInt, Is.EqualTo(someInt));
};
hostBehaviour.RpcSendInt(someInt);
hostBehaviour.SendInt(someInt);
ProcessMessages();
Assert.That(callCount, Is.EqualTo(1));
}
Expand Down
6 changes: 0 additions & 6 deletions Assets/Mirror/Tests/Editor/Weaver/WeaverClientRpcTests.cs
Expand Up @@ -10,12 +10,6 @@ public void ClientRpcValid()
Assert.That(weaverErrors, Is.Empty);
}

[Test]
public void ClientRpcStartsWithRpc()
{
Assert.That(weaverErrors, Contains.Item("DoesntStartWithRpc must start with Rpc. Consider renaming it to RpcDoesntStartWithRpc (at System.Void WeaverClientRpcTests.ClientRpcStartsWithRpc.ClientRpcStartsWithRpc::DoesntStartWithRpc())"));
}

[Test]
public void ClientRpcCantBeStatic()
{
Expand Down

This file was deleted.

0 comments on commit eb93c34

Please sign in to comment.