Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto fill serialize/deserialize for classes #2120

Merged
merged 3 commits into from
Aug 1, 2020
Merged

Conversation

paulpach
Copy link
Contributor

@paulpach paulpach commented Aug 1, 2020

fixes #2117

This now works:

 class ArrayIntMessage : IMessageBase
    {
        public int[] array;

        // Mirror will fill out these empty methods
        public void Deserialize(NetworkReader reader) { }
        public void Serialize(NetworkWriter writer) { }
    }

@sonarcloud
Copy link

sonarcloud bot commented Aug 1, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@paulpach
Copy link
Contributor Author

paulpach commented Aug 1, 2020

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.

@paulpach paulpach merged commit 890ee6b into master Aug 1, 2020
@paulpach paulpach deleted the classmsgweave branch August 1, 2020 13:46
github-actions bot referenced this pull request in MirageNet/Mirage Sep 21, 2020
# [43.7.0](v43.6.0...v43.7.0) (2020-09-21)

### Bug Fixes

* adding error for generated read writer for abstract class ([#2191](https://github.com/MirrorNG/MirrorNG/issues/2191)) ([a9d21ea](a9d21ea))
* adding error when Server/Client is used on abstract methods ([#1978](https://github.com/MirrorNG/MirrorNG/issues/1978)) ([c1410b0](c1410b0))
* adding version define from v17 breaking change ([c6fa49c](c6fa49c))
* auto fill serialize/deserialize for classes ([#2120](https://github.com/MirrorNG/MirrorNG/issues/2120)) ([890ee6b](890ee6b)), closes [#2117](https://github.com/MirrorNG/MirrorNG/issues/2117) [#2117](https://github.com/MirrorNG/MirrorNG/issues/2117)
* ClientScene.localplayer is now set to null when it is destroyed ([#2227](https://github.com/MirrorNG/MirrorNG/issues/2227)) ([5edba81](5edba81))
* fixing cloud log not using logger ([#2141](https://github.com/MirrorNG/MirrorNG/issues/2141)) ([a124f3f](a124f3f))
* Fixing IndexChanged hook not being called for NetworkRoomPlayer ([#2242](https://github.com/MirrorNG/MirrorNG/issues/2242)) ([94da8ae](94da8ae))
* fixing NullReferenceException when loading scene ([#2240](https://github.com/MirrorNG/MirrorNG/issues/2240)) ([5eb5ff6](5eb5ff6))
* fixing unity crash on StackOverflowException ([#2146](https://github.com/MirrorNG/MirrorNG/issues/2146)) ([ec54ee6](ec54ee6))
* fixing warning message for client attribute ([#2144](https://github.com/MirrorNG/MirrorNG/issues/2144)) ([ddc6139](ddc6139))
* fixing width and layout group on cloud example ([#2201](https://github.com/MirrorNG/MirrorNG/issues/2201)) ([fc53078](fc53078))
* isServer false in OnDestroy ([#2101](https://github.com/MirrorNG/MirrorNG/issues/2101)) ([d46469a](d46469a))
* making triggers be called right away instead on owner ([#2125](https://github.com/MirrorNG/MirrorNG/issues/2125)) ([7604e65](7604e65))
* Nested messages ([#2148](https://github.com/MirrorNG/MirrorNG/issues/2148)) ([e4a5ce7](e4a5ce7))
* Unity Editor 2019/2020 crashes in Play Mode when resizing Editor for Macbooks with on board graphics cards. Using Metal instead of OpenGL fixes it. See also: https://forum.unity.com/threads/unity-editor-crashes-macos.739535/ ([e2fd195](e2fd195))
* weaver test for abstract methods ([#2166](https://github.com/MirrorNG/MirrorNG/issues/2166)) ([3a276b4](3a276b4))

### Features

* Added Layer Weight to NetworkAnimator ([#2134](https://github.com/MirrorNG/MirrorNG/issues/2134)) ([23b9fb0](23b9fb0))
* Adding Custom Data and Custom Address fields to list server ([#2110](https://github.com/MirrorNG/MirrorNG/issues/2110)) ([e136f48](e136f48))
* adding script to help debug list server ([#2202](https://github.com/MirrorNG/MirrorNG/issues/2202)) ([5701369](5701369))
* allowing lists to automatically be sent in Commands, Rpc, and Messages ([#2151](https://github.com/MirrorNG/MirrorNG/issues/2151)) ([381e5a1](381e5a1))
* making NetworkBehaviour.IsDirty public ([#2208](https://github.com/MirrorNG/MirrorNG/issues/2208)) ([1ade82d](1ade82d))
* Use Server Client attribute outside of NetworkBehaviour ([#2150](https://github.com/MirrorNG/MirrorNG/issues/2150)) ([eec49fa](eec49fa))

### Performance Improvements

* **weaver:** No need to manually load mirror and unity assemblies ([#2261](https://github.com/MirrorNG/MirrorNG/issues/2261)) ([e50ea63](e50ea63))
* adding check for no connections ([#2130](https://github.com/MirrorNG/MirrorNG/issues/2130)) ([150b14a](150b14a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weaver doesn't auto fill OnSerialize/OnDeserialize for classes without base.Serialize function
2 participants