Nitrox icon indicating copy to clipboard operation
Nitrox copied to clipboard

Refactor server to use .NET Generic Host APIs

Open Measurity opened this issue 8 months ago • 3 comments

  • [x] Wrap NitroxConfig in custom MS configuration provider for validation, CMD args and DI support
  • [x] Replace logging with ZLogger for improved performance, while keeping all prior features of Nitrox.Model.Logger.Log (i.e. redaction and LogOnce).
  • [x] Refactor IPC communication between launcher<->server with MagicOnion for improved stability and performance.
  • [x] Added server.Development.json which allows developers to override any config property. This file is automatically generated on build if it doesn't exist and works with instant launch too.

Missing features

Reviewing

Everything flows from Program.StartServerAsync so I recommend giving it a good look before reviewing the rest.

I tried to compartmentalize dependencies together into extension methods on IServiceCollection. In other words, removing .AddPackets() should still compile and run the server. It just won't have any packet related services (like LiteNetLib) running.

Issues to close

  • Closes #2166

Preview

image

Measurity avatar Apr 17 '25 07:04 Measurity

Seems like another huge piece of work and it will be hard to test/integrate. I think we should probably slice it into multiple PR (.NET Host refactor, Encryption, Sqlite)

dartasen avatar Oct 08 '25 19:10 dartasen

Test Results

238 tests   - 7   237 ✅  - 7   7s ⏱️ ±0s   1 suites ±0     1 💤 ±0    1 files   ±0     0 ❌ ±0 

Results for commit cbb77384. ± Comparison against base commit c586d7e4.

This pull request removes 8 and adds 1 tests. Note that renamed tests count towards both.
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ EntityDataTest (SubnauticaServerJsonSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ EntityDataTest (SubnauticaServerProtoBufSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ GlobalRootDataTest (SubnauticaServerJsonSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ GlobalRootDataTest (SubnauticaServerProtoBufSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ PlayerDataTest (SubnauticaServerJsonSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ PlayerDataTest (SubnauticaServerProtoBufSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ WorldDataTest (SubnauticaServerJsonSerializer)
Nitrox.Server.Subnautica.Models.Serialization.WorldPersistenceTest ‑ WorldDataTest (SubnauticaServerProtoBufSerializer)
Nitrox.Model.Helper.HashTreeTest ‑ ShouldTestForSameValue

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Oct 08 '25 20:10 github-actions[bot]

Ready for review :clown_face:

Measurity avatar Dec 07 '25 13:12 Measurity