Consider a Uri with default port (https://example.com:443/)
After a serialization/deserialization roundtrip, the resulting Uri.OriginalString doesn't contain the port anymore (https://example.com/). The messagepack UriFormatter should use Uri.OriginalString instead of Uri.ToString() to ensure lossless serialization?
Newtonsoft.Json and System.Text.Json both use Uri.OriginalString: https://github.com/dotnet/corefx/pull/39015
var uri = new Uri("https://example.com:443/");
// Call Serialize/Deserialize, that's all.
byte[] bytes = MessagePackSerializer.Serialize(uri);
var uri2 = MessagePackSerializer.Deserialize<Uri>(bytes);
Console.WriteLine("Before: " + uri.OriginalString);
Console.WriteLine("After : " + uri2.OriginalString);
// Before: https://example.com:443/
// After : https://example.com/
Resulting Uri.OriginalString should still be https://example.com:443/
Resulting Uri.OriginalString is https://example.com/
@AArnott if it's okay, I can give this a shot?
Is this the right UriFormatter class?
https://github.com/neuecc/MessagePack-CSharp/blob/master/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs#L287
Not sure because the root folder says MessagePack.UnityClient/Assets
Thanks, @degant. Yes, that's the right one. When you open the solution in VS you'll see that the file you found is in fact included in the compiled projects. It's under Unity because Unity requires it to be in its own directory. But that's the one.
Also please add a test for this. The case you used in this bug description would make a good one.