﻿namespace Fixie.Internal
{
    using System;
    using System.Text;
    using System.Text.Json;

    static class Serialization
    {
        public static string Serialize<TMessage>(TMessage message)
            => Encoding.UTF8.GetString(JsonSerializer.SerializeToUtf8Bytes(message));

        public static TMessage Deserialize<TMessage>(string message)
            => JsonSerializer.Deserialize<TMessage>(new ReadOnlySpan<byte>(Encoding.UTF8.GetBytes(message)))!;
    }
}
﻿namespace Fixie.Internal
{
    using System.Text;
    using System.Text.Json;

    static class Serialization
    {
        public static string Serialize<TMessage>(TMessage message)
            => Encoding.UTF8.GetString(JsonSerializer.SerializeToUtf8Bytes(message));

        public static TMessage Deserialize<TMessage>(string message)
            => JsonSerializer.Deserialize<TMessage>(Encoding.UTF8.GetBytes(message))!;
    }
}
Remove superfluous construction of ReadOnlySpan<byte> from byte[ ]. An implicit cast is available in this context, so the same method overload is in fact called, and the implementation of the implicit cast performs the same construction for us.
Remove superfluous construction of ReadOnlySpan<byte> from byte[ ]. An implicit cast is available in this context, so the same method overload is in fact called, and the implementation of the implicit cast performs the same construction for us.
