mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 17:47:24 +02:00
* [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>
113 lines
2.8 KiB
C#
113 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
using NetSerializer;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Network.Messages;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Serialization.Markdown;
|
|
using YamlDotNet.RepresentationModel;
|
|
|
|
namespace Robust.UnitTesting
|
|
{
|
|
internal sealed partial class IntegrationMappedStringSerializer : IRobustMappedStringSerializer
|
|
{
|
|
[Dependency] private INetManager _net = default!;
|
|
|
|
public bool Locked => false;
|
|
|
|
public ITypeSerializer TypeSerializer { get; } = new TypeSerializerImpl();
|
|
|
|
public Task Handshake(INetChannel channel)
|
|
{
|
|
var message = new MsgMapStrServerHandshake();
|
|
message.Hash = _hash;
|
|
_net.ServerSendMessage(message, channel);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private readonly byte[] _hash = new byte[64];
|
|
public ReadOnlySpan<byte> MappedStringsHash => _hash;
|
|
|
|
public bool EnableCaching { get; set; }
|
|
|
|
public void AddString(string str)
|
|
{
|
|
// Nada.
|
|
}
|
|
|
|
public void AddStrings(Assembly asm)
|
|
{
|
|
// Nada.
|
|
}
|
|
|
|
public void AddStrings(YamlStream yaml)
|
|
{
|
|
// Nada.
|
|
}
|
|
|
|
public void AddStrings(DataNode dataNode)
|
|
{
|
|
// Nada.
|
|
}
|
|
|
|
public void AddStrings(IEnumerable<string> strings)
|
|
{
|
|
// Nada.
|
|
}
|
|
|
|
public event Action? ClientHandshakeComplete;
|
|
|
|
public void LockStrings()
|
|
{
|
|
// Nada.
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
_net.RegisterNetMessage<MsgMapStrServerHandshake>(HandleServerHandshake, NetMessageAccept.Client);
|
|
}
|
|
|
|
private void HandleServerHandshake(MsgMapStrServerHandshake message)
|
|
{
|
|
ClientHandshakeComplete?.Invoke();
|
|
}
|
|
|
|
public (byte[] mapHash, byte[] package) GeneratePackage()
|
|
{
|
|
return (Array.Empty<byte>(), Array.Empty<byte>());
|
|
}
|
|
|
|
public void SetPackage(byte[] hash, byte[] package)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
private sealed class TypeSerializerImpl : IStaticTypeSerializer
|
|
{
|
|
public bool Handles(Type type)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public IEnumerable<Type> GetSubtypes(Type type)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public MethodInfo GetStaticWriter(Type type)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public MethodInfo GetStaticReader(Type type)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
}
|
|
}
|
|
}
|