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
breaking: no need to override Serialize/Deserialize in messages #2317
Conversation
Messages no longer serilize themselves. This has been decoupled. Serializing a message is now done
via readers and writers, which can be either generated or user provided.
This lifts some restrictions,
* you no longer need to have a default constructor in messages
* Messages types can be recursive
* struct Messages don't need to provide an empty Serialize and Deserialize method
Before:
```cs
public struct ReadyMessage : IMessageBase
{
public void Deserialize(NetworkReader reader) { }
public void Serialize(NetworkWriter writer) { }
}
```
After:
```cs
public struct ReadyMessage : IMessageBase
{
}
```
BREAKING CHANGE: Messages must be public
BREAKING CHANGE: Use custom reader and writer instead of Serialize/Deserialize methods
| @@ -1,23 +0,0 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this being removed?
Assets/Mirror/Tests/Editor/Generated/CollectionWriterTests.gen.cs
Outdated
Show resolved
Hide resolved
|
This breaks a lot of messages that use the Serialize/Deserialize methods. The way in which is breaks the message is the worst part. Some types that were handled manually before are no longer handled causing errors like this when updating: The hint or message to say that a now broken message should have custom writers. Once users figure out (probably with support from discord) then the result will look like this, which writing from scratch seems fine, but going from before->after seems pointless. The worst part is even after fixing the weaver errors the whole game break because custom Serialize/Deserialize methods are no longer being used such has: https://hatebin.com/tufaepvksq. I dont think breaking most messages that take advantage of the Serialize/Deserialize methods is worth 500 LOC. |
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
|
SonarCloud Quality Gate failed.
|
* breaking: no need to override Serialize/Deserialize in messages
Messages no longer serilize themselves. This has been decoupled. Serializing a message is now done
via readers and writers, which can be either generated or user provided.
This lifts some restrictions,
* you no longer need to have a default constructor in messages
* Messages types can be recursive
* struct Messages don't need to provide an empty Serialize and Deserialize method
Before:
```cs
public struct ReadyMessage : IMessageBase
{
public void Deserialize(NetworkReader reader) { }
public void Serialize(NetworkWriter writer) { }
}
```
After:
```cs
public struct ReadyMessage : IMessageBase
{
}
```
BREAKING CHANGE: Messages must be public
BREAKING CHANGE: Use custom reader and writer instead of Serialize/Deserialize methods
* Remove unused method
* remove unused methods
* remove unused methods
* make all messages struct
* Fix test code generator
* Get rid of MessageBase
* Rename IMessageBase -> NetworkMessage
* add MessageBase as obsolete
* Use a default request
* Empty file to make asset store happy
* Apply suggestions from code review
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
Co-authored-by: James Frowen <jamesfrowendev@gmail.com>

Messages no longer serialize themselves. This has been decoupled. Serializing a message is now done
via readers and writers, which can be either generated or user provided.
This lifts some restrictions,
Before:
After:
For custom overrides for Serialize/Deserialize instead use custom reader and writer instead
Before (Click to expand)
After (Click to expand)
BREAKING CHANGE: Messages must be public
BREAKING CHANGE: Use custom reader and writer instead of Serialize/Deserialize methods