Remove all the recursionCount nonsense.
This was added to prevent infinite recursion with types that reference themselves.
No need to check anymore, the weaver can generate readers and writers for types that reference themselves such as:
```cs
class Tree {
Tree child1;
Tree child2;
}
```
This works by the weaver doing it the way the compiler does: Create a function first, memoize it, then write the body. If the body needs the function, it will get itself and issue a call to itself.
Currently, whenever we want to serialize an enum,
we simply serialize the underlying type (byte, short, int)
This works fine, but in order to get the reader and writer
at runtime I need a function for each type.
With this PR, we generate a reader and writer function for enums too,
the function body simply calls the underlying reader and writer.
* throwing Exception instead of returning null
* re-adding null check until later PR
* removing error from test
* removing extra error
* adding comment
* replacing error with throw for abstact
The plan is to remove WeaverLists at some point so moving the functions
out of weaver to here for now and then move them closer to where they
are actaully used when we start to remove WeaverLists.
# Before
This is hard to read:
```
if (ca.AttributeType.FullName == typeof(Mirror.CommandAttribute).FullName) {
...
}
```
# After
```
if (ca.AttributeType.Is<Mirror.CommandAttribute>()) {
...
}
```
# Before
WeaverTypes declared a static variable like this:
```cs
public static TypeReference int32Type;
```
Weavertypes then loaded the variable in SetupTargetTypes like this:
```cs
int32Type = ImportSystemModuleType(currentAssembly, systemModule, "System.Int32");
```
Note we lookup the type with a string, any typo there won't be detected until the code is executed. It will also not be found by the IDE when you click "find references", or when you refactor.
Then we use it like this:
```cs
var intType = WeaverTypes.int32Type;
```
This is a DRY violation: I have to modify 3 different code sections just to say that I want the int32 type.
# After
Get rid of all the duplication, and use the type instead of a string:
```cs
var intType = WeaverTypes.Import<int>();
```
No need for static variable, or to add it in SetupTargetTypes.
* fixing null ref error when local player is destroyed
* removing null objects
* fixing InvalidOperationException
* moving code to its own function
* Update Assets/Mirror/Runtime/ClientScene.cs
* Update ClientScene.cs
Improving logging
- making sure sceneId is always hex
- only logging "Client spawn for ..." if it was successful
* Update ClientSceneTests_OnSpawn.cs
- Adding handlers in Awake instead of Start to make sure they are added before start on headless
- using GetComponent for NetworkManagerListServer
- Adding asserts to make sure values are set
* moving FakeNetworkConnection to common test folder
* adding test for local player destroy
* adding method to clear local player
* temp move test functions
* adding test for destroying non player
* moving asset to setup
* adding tests for destroy message and host mode
* adding ClearLocalPlayer to reset
* Removing manual invoke for Cmd and RPC
There should be no reason to manaully invoke remote code
they are marked with EditorBrowsableState.Never which implies they should not be called by the user
* removing tests
* adding note to guides about removed SyncEvent
* updating Obsolete
making Obsolete error whe used
updating text to say it has been removed
linking to issue
* adding Obsolete note to other references to SyncEvent
* Remove ScriptTemplates to clean up folder
* Update main.yml
Removing script templates from CI
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
* fix adding error for gernated read writer for abstract class
weaver can not initialize class abstract class so cant not create a reader
this gives a helpful error telling the server to make a custom reader
* adding tests for error message
* fixing typo
* renaming
* fixing expected error messages
Reader code doesn't run on Rpc now if a valid writer can not be found
In future PR write and read functions should be generated together as they share most of the same checks
* replacing assert with haserror
* adding IsSuccess and HasWarning functions
* using IsSuccess
* checking weaverWarnings empty in success
* using HasWarning
* replacing asserts missed by regex
* fixing typo
* adding HasNoErrors function to be used when tests only have warnings
* fixing typo
* making fields public to stop warnings
* simplifying more test files
* adding generated test for other baseclasses
* removing errors when attribute is not in networkbehaviour
* temp weaver tests
* updating weaver tests for monobehaviour
* adding weaver tests for non-networkbehaviour
* moving where serverclient attributes are processed
* removing un-used code
* regenerate tests
* adding check for no connections
Dont need to run Server Update if there are no connections
* adding toggle to disable skip
* formatt
* removing skipUpdateIfNoConnections check, and merging if checks
* removing extra line
* adding tests for NoConnections
* replacing isHeadless with isServerBuild
* renaming startOnHeadless
* fixing isServerBuild bool
* making property a field instead
* replacing isServerBuild for #if UNITY_SERVER
* fixing comment and removing extra lines
* removing system from System.Obsolete
* renaming to autoStartServerBuild
* adding assert to make sure transport is set
this helps people who want to connect without using networkmanager
* moving Transport.activeTransport to setup
* replacing Substitute.For for addComponent
Can't used Substitute for monobehaviours as they will still be null with unity equals
* weaver test for abstract methods
* doing nothing is method is abstract
* not calling base if it is abstract
* adding tests for message to make sure they work
* weaver tests for list read write
* generated tests for list read write
* adding method to check for list type
* temp
* weaver functions for creating read write for list
* generating tests for lists
* adding generated tests for collection writers
tests for read+write for array and array segment
* changing menu path
* adding tests for collections of classes
* swapping order in class name
* tests for Server attribute on virtual methods
test for virtual, abstract and override methods
* adding test for client attribute
* adding error when attribute is put on abstract method
* improving error message
* updating error mesages in tests
* updating to use WeaverTypes
* adding check before error
* class to create test functions
* generated test folder
* generated attribute tests
* adding out function and long type
* generated test file
* using OneTimeSetUp to make tests run faster
* Added Layer Weight to NetworkAnimator
Now NetworkAnimator is aware of each layer weight on it's references
Animator and will sync layer weights across the network.
* NetworkAnimator layers Float equality fix
* Update Assets/Mirror/Components/NetworkAnimator.cs
Co-authored-by: James Frowen <jamesfrowen5@gmail.com>
* Update Assets/Mirror/Components/NetworkAnimator.cs
Co-authored-by: James Frowen <jamesfrowen5@gmail.com>
* Remove GetLayerWeight check every incoming packet as is extern call
Co-authored-by: James Frowen <jamesfrowen5@gmail.com>
* Adding asmdef to telepathy
mirror has to reference telepathy as it is the default transport
this also means that TelepathyTransport has to be in the mirror asmdef
* references telepathy in tests
* formatting asmdef
Note this method is being called in 3 places:
one in MessageClassProcessor and 2 in NetworkBehaviorProcessor.
The NetworkBehaviorProcess is really a don't care, this condition cannot happen since it would not be invoked unless the class extends from NetworkBehavior. In this case, it will always resolve.
but even if it does not resolve, they handle the null case gracefully by not calling the base method.
MessageClassProcessor also calls this method, and if it is null it does not call the base method. That is precisely the behavior we want to resolve#2117
so all 3 places are perfectly fine receiving null.
The only way to trigger the error was #2117
I renamed the method to make it clearer that this may not find the method in the parent class.
Instead of doing
```cs
[SyncEvent]
public event MySyncEventDelegate EventOnly;
```
You can now do
```cs
[SyncEvent]
public event MySyncEventDelegate Only;
```
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>
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>
Instead of doing
```cs
[TargetRpc]
public void TargetPepe() {}
```
You can now do
```cs
[TargetRpc]
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>
Instead of doing
```cs
[Command]
public void CmdPepe() {}
```
You can now do
```cs
[Command]
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>
* finding all fields
* adding test for message with base
* undoing FindAllPublicFields
* adding tests for Inheritance with define order
* making sure that messages are processed in order
do not need to check if message has already been processed becuase
OnSerialize is only added/changed if it is missing or empty
* removing un-needed comments
* using recursion instead of loops
* remove white space
* perf: Use invokeRepeating instead of Update
If you have low frequency calls, InvokeRepeating is a lot faster than
Update(). Use InvokeRepeating for NetworkProximityChecker
* Fix indentation
Co-authored-by: Paul Pacheco <paul.pacheco@aa.com>
* weaver test for mutlitple events
* tests for multiple sync events in 1 class
* removing break so that multiple events will be proccessed
It seems like this break was here because unet used foreach CustomAttributes
but mirror uses GetCustomAttribute
* test to check if fallbacks disables other transport
* using ondisable to disable other transport
* fixing teardown
* adding test for Multiplex
* using ondisable to disable other transport
* fixing NSubstitute for 2019
* fixing pong spawn points
* renaming files and asmdef
* More Cloud examples
* Moving pong example to cloud folder
* Moving shared code to GUI folder
* Adding readme for examples
* Adding tank example
* adding mirror list services
* fixing code smells
* removing runtime example folders
* removing matchmaking code till feature is ready
* fixing scene path
* updating readme to say where example is
* fix: Websockets Transport now handles being disabled for scene changes
* Removed unused method
* Removed test warnings
* Changed back to await Task.Run
* adding queue to ClientJs
keeping standalone client without queue
dont need common class for now as that over complicates the fix
Co-authored-by: Chris Langsenkamp <chris@clevertech.net>
* adding override method that calls base
* trying to debug instruction for call to base
* extra tests
* adding tests for client and target Rpc
* adding fix for calls to base class
Since networkbehaviour parents are processed first we can just fix the
method when we see it in SubstituteMethod
* moving static code from NetworkBehaviour to its own class
* Replacing calls in tests to use new RemoteCallHelper
* updating references to types in weaver
* adding version 15 defines
* renaming function
* moving exists check to its own function
* moving order and adding whitespace
* adding SenderConnection Attribute
* adding weaver tests for SenderConnection Attribute
* tests for sender connection
* updating valid method to work with sender connection
* using RemoteCallType in read write calls
* adding sender connection to CallCmd
* updating CmdDelegate
* adding NetworkConnection to invokeFunction
* updating old tests
* removing SenderConnectionAttribute
* typo
* adding version 14 defines
* allowing assetId to be set at runtime
* removing ignore from tests
* adding errors and warning for settings assetId
* adding tests for settings assetId
* not allowing assetId to be replaced
* fixing test
* giving error when old assetId was not empty
* moving test to runtime
moving base classes to common
* moving more tests to runtime
* changing tests to give error when assetid is changed
* removing un-needed check
* removing NewAssetId tests
* WIP
* WIP
* WIP
* WIP
* feat: Add excludeOwner option to ClientRpc
* removed default value
* Fixed tests
* Update Assets/Mirror/Editor/Weaver/Processors/RpcProcessor.cs
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
* adding weaver test for exlude owner
* adding test for call to exclude owner
* adding comment back
* removing ClientRpcInfo
we don't need ClientRpcInfo as client rpc is only called server side
so we don't need to double check exlucde owner, weaver can handle it
* removing extra register
* fixing test compile errors
* Update Assets/Mirror/Tests/Editor/Weaver/WeaverClientRpcTests~/ClientRpcThatExcludesOwner.cs
* doc: fixed typos in readme
* doc: Updated ChangeLog
* doc: Updated docs for Command ignoreAuthority option
* doc: Updated ChangeLog
* fixing typo in comment (#1963)
* Removed YouTube link. Link is changing soon. (#1962)
* Removed YouTube link. Link is changing soon. (#1961)
* Removed YouTube link. Link is changing soon. (#1960)
* Removed YouTube link. Link is changing soon. (#1959)
* Removed YouTube link. Links are changing. (#1958)
* Removed YouTube link. Links are changing. (#1957)
* Update NetworkBehavior.md (#1956)
* fixed comment typo
* doc: Updated Migration guide example
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
Co-authored-by: FirstGearGames <firstgeargames@gmail.com>
* weaver test for virtual and abstract commands
* adding error for abstract methods
* adding base class for command tests and renaming file
* adding tests for virutal commands
* renaming classes to make more sense
* removing whitespace
* adding tests for Client Target Rpc too
* fixing compile error
* fixing message and typo
* removing line
* renaming namespace and base class to be used by Rpc
* tests for calling Rpc
* tests for virtual rpc
* fixing typo
* white space
* renaming parameter name
* renaming parameter name
* making comment look the same as the one in writeArguments
* removing NetworkBehaviourType2 to make code simplier
* whitesapce