Repository navigation
Description
Summary
I'd like to do a round of housekeeping on the build and test infrastructure:
- migrate to
.slnxand Central Package Management - replace FluentAssertions and move to xUnit v3
- add test coverage for the netstandard build and for wire-format compatibility
The same kind of work is proposed for ZLogger in Cysharp/ZLogger#249. None of this changes the shipped packages.
Updating the TFMs for the .NET 8 / .NET 9 end of support is deliberately left out. In MemoryPack it is more involved than in other libraries, because the netstandard2.1 build and the net* builds are not compatible with each other (see "Target framework dependency" in the README), so I'd like to discuss it in a separate issue. The tests below are meant to be in place before that work starts.
Before opening PRs, I'd appreciate feedback, especially on the open questions at the end.
Tasks
Solution and packages
- Replace
MemoryPack.slnwithMemoryPack.slnx. CI runsdotnet build/test/packwithout a solution path, and already uses a .NET 10 SDK, so no workflow changes are expected. - Adopt Central Package Management (
Directory.Packages.props), as MagicOnion, GrpcWebSocketBridge, Multicaster, and DFrame already do. Once test: run tests against the netstandard2.1 build #468 is merged, the two test projects share the same package list. This doesn't affect Unity, which doesn't read the project files.
Tests
- Run the existing tests against the
netstandard2.1build, which Unity uses (test: run tests against the netstandard2.1 build #468). Today, the#elseside of#if NET7_0_OR_GREATER/NET8_0_OR_GREATERis never tested. - Add wire-format compatibility tests: commit the bytes produced by 1.21.4 for representative types, and check in both test projects that serializing gives the same bytes and deserializing gives the original values. See open question 2.
- Replace FluentAssertions with Shouldly. FluentAssertions 8 and later require a commercial license, and ConsoleAppFramework, R3, GrpcWebSocketBridge, MasterMemory, and DFrame have already moved. This is about 430 assertions in 39 files, rewritten by hand.
- Migrate from xUnit v2 to xUnit v3 on Microsoft.Testing.Platform, the same setup as R3 and ZLinq.
- Update the remaining test packages.
The first two should also be in place before #460, which changes code that runs in the netstandard2.1 build too.
Out of scope
Each of these would be a separate issue if we want to pursue it.
- Updating the TFMs and library dependencies for the .NET 8 / .NET 9 end of support (2026-11-10). This involves the source generator, consumers on dropped runtimes, Add allows ref struct constraint to TBufferWriter for .NET 9+ #448, and possibly a future redesign of the buffer layer, so it deserves its own discussion.
- Generator tests for other language versions. The tests compile generated code only with C# 11, while Unity users get the C# 9 output by default.
- Running tests on
net48(Windows CI).
Open questions
- Test stack. Is Shouldly + xUnit v3 (Microsoft.Testing.Platform) the preferred standard for Cysharp repositories going forward? Similarly, should Central Package Management become the default?
- Wire-format compatibility. The new tests would enforce these rules. Do they sound right?
- Data written by an older version can always be read by a newer version, even across a major version.
- Data written by a newer version can be read by an older version as long as no new format features are used (best effort). This matters for RPC, where one side is updated first.
- The format doesn't depend on which build (
netstandard2.1ornet*) is used, except for the existing documented cases (unmanaged structs whose layout differs between runtimes, Help with custom record struct serialized in .Net6 doesn't deserializing just after upgrade .Net7 #107 / Serialization results differ between Unity and .Net with using LayoutKind.Auto #191). - Maintenance changes don't change the format.
Activity