Files
RobustToolbox/Robust.Client/Serialization/ClientRobustSerializer.cs
T
Pieter-Jan Briers 83c2a1be11 [Dependency] source generator part 2 (#6550)
* [Dependency] source generator

No more reflection, no more codegen at runtime

Also various changes to Roslyn helpers to make this easier to write.

Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback.

No fallback is available for [field: Dependency] properties, due to a Roslyn bug.

Code Fixes exist. We love Roslyn

* Apply dependencies generator changes to all code

* Release notes

* Preprocessor got hands

* Handle nullable dependencies

These are bad but gotta deal with it.

* Apply suggestions from code review

Co-authored-by: Moony <moony@hellomouse.net>

* Fine, let's not use collection expressions

---------

Co-authored-by: Moony <moony@hellomouse.net>
2026-05-08 12:38:33 +02:00

19 lines
612 B
C#

using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using System;
namespace Robust.Client.Serialization;
internal sealed partial class ClientRobustSerializer : RobustSerializer, IClientRobustSerializer
{
[Dependency] private IBaseClient _client = default!;
public void SetStringSerializerPackage(byte[] hash, byte[] package)
{
if (_client.RunLevel != ClientRunLevel.SinglePlayerGame)
throw new NotSupportedException("Directly setting string serializer data is only supported in single-player games.");
MappedStringSerializer.SetPackage(hash, package);
}
}