// Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. /* THIS (.cs) FILE IS GENERATED. DO NOT CHANGE IT. * CHANGE THE .tt FILE INSTEAD. */ using System; using System.Buffers; #pragma warning disable SA1649 // File name should match first type name namespace MessagePack.Formatters { public sealed class Int16Formatter : IMessagePackFormatter { public static readonly Int16Formatter Instance = new Int16Formatter(); private Int16Formatter() { } public void Serialize(ref MessagePackWriter writer, Int16 value, MessagePackSerializerOptions options) { writer.Write(value); } public Int16 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadInt16(); } } public sealed class NullableInt16Formatter : IMessagePackFormatter { public static readonly NullableInt16Formatter Instance = new NullableInt16Formatter(); private NullableInt16Formatter() { } public void Serialize(ref MessagePackWriter writer, Int16? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Int16? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadInt16(); } } } public sealed class Int16ArrayFormatter : IMessagePackFormatter { public static readonly Int16ArrayFormatter Instance = new Int16ArrayFormatter(); private Int16ArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Int16[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Int16[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Int16[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadInt16(); } return array; } } public sealed class Int32Formatter : IMessagePackFormatter { public static readonly Int32Formatter Instance = new Int32Formatter(); private Int32Formatter() { } public void Serialize(ref MessagePackWriter writer, Int32 value, MessagePackSerializerOptions options) { writer.Write(value); } public Int32 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadInt32(); } } public sealed class NullableInt32Formatter : IMessagePackFormatter { public static readonly NullableInt32Formatter Instance = new NullableInt32Formatter(); private NullableInt32Formatter() { } public void Serialize(ref MessagePackWriter writer, Int32? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Int32? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadInt32(); } } } public sealed class Int32ArrayFormatter : IMessagePackFormatter { public static readonly Int32ArrayFormatter Instance = new Int32ArrayFormatter(); private Int32ArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Int32[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Int32[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Int32[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadInt32(); } return array; } } public sealed class Int64Formatter : IMessagePackFormatter { public static readonly Int64Formatter Instance = new Int64Formatter(); private Int64Formatter() { } public void Serialize(ref MessagePackWriter writer, Int64 value, MessagePackSerializerOptions options) { writer.Write(value); } public Int64 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadInt64(); } } public sealed class NullableInt64Formatter : IMessagePackFormatter { public static readonly NullableInt64Formatter Instance = new NullableInt64Formatter(); private NullableInt64Formatter() { } public void Serialize(ref MessagePackWriter writer, Int64? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Int64? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadInt64(); } } } public sealed class Int64ArrayFormatter : IMessagePackFormatter { public static readonly Int64ArrayFormatter Instance = new Int64ArrayFormatter(); private Int64ArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Int64[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Int64[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Int64[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadInt64(); } return array; } } public sealed class UInt16Formatter : IMessagePackFormatter { public static readonly UInt16Formatter Instance = new UInt16Formatter(); private UInt16Formatter() { } public void Serialize(ref MessagePackWriter writer, UInt16 value, MessagePackSerializerOptions options) { writer.Write(value); } public UInt16 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadUInt16(); } } public sealed class NullableUInt16Formatter : IMessagePackFormatter { public static readonly NullableUInt16Formatter Instance = new NullableUInt16Formatter(); private NullableUInt16Formatter() { } public void Serialize(ref MessagePackWriter writer, UInt16? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public UInt16? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadUInt16(); } } } public sealed class UInt16ArrayFormatter : IMessagePackFormatter { public static readonly UInt16ArrayFormatter Instance = new UInt16ArrayFormatter(); private UInt16ArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, UInt16[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public UInt16[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new UInt16[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadUInt16(); } return array; } } public sealed class UInt32Formatter : IMessagePackFormatter { public static readonly UInt32Formatter Instance = new UInt32Formatter(); private UInt32Formatter() { } public void Serialize(ref MessagePackWriter writer, UInt32 value, MessagePackSerializerOptions options) { writer.Write(value); } public UInt32 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadUInt32(); } } public sealed class NullableUInt32Formatter : IMessagePackFormatter { public static readonly NullableUInt32Formatter Instance = new NullableUInt32Formatter(); private NullableUInt32Formatter() { } public void Serialize(ref MessagePackWriter writer, UInt32? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public UInt32? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadUInt32(); } } } public sealed class UInt32ArrayFormatter : IMessagePackFormatter { public static readonly UInt32ArrayFormatter Instance = new UInt32ArrayFormatter(); private UInt32ArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, UInt32[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public UInt32[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new UInt32[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadUInt32(); } return array; } } public sealed class UInt64Formatter : IMessagePackFormatter { public static readonly UInt64Formatter Instance = new UInt64Formatter(); private UInt64Formatter() { } public void Serialize(ref MessagePackWriter writer, UInt64 value, MessagePackSerializerOptions options) { writer.Write(value); } public UInt64 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadUInt64(); } } public sealed class NullableUInt64Formatter : IMessagePackFormatter { public static readonly NullableUInt64Formatter Instance = new NullableUInt64Formatter(); private NullableUInt64Formatter() { } public void Serialize(ref MessagePackWriter writer, UInt64? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public UInt64? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadUInt64(); } } } public sealed class UInt64ArrayFormatter : IMessagePackFormatter { public static readonly UInt64ArrayFormatter Instance = new UInt64ArrayFormatter(); private UInt64ArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, UInt64[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public UInt64[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new UInt64[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadUInt64(); } return array; } } public sealed class SingleFormatter : IMessagePackFormatter { public static readonly SingleFormatter Instance = new SingleFormatter(); private SingleFormatter() { } public void Serialize(ref MessagePackWriter writer, Single value, MessagePackSerializerOptions options) { writer.Write(value); } public Single Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadSingle(); } } public sealed class NullableSingleFormatter : IMessagePackFormatter { public static readonly NullableSingleFormatter Instance = new NullableSingleFormatter(); private NullableSingleFormatter() { } public void Serialize(ref MessagePackWriter writer, Single? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Single? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadSingle(); } } } public sealed class SingleArrayFormatter : IMessagePackFormatter { public static readonly SingleArrayFormatter Instance = new SingleArrayFormatter(); private SingleArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Single[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Single[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Single[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadSingle(); } return array; } } public sealed class DoubleFormatter : IMessagePackFormatter { public static readonly DoubleFormatter Instance = new DoubleFormatter(); private DoubleFormatter() { } public void Serialize(ref MessagePackWriter writer, Double value, MessagePackSerializerOptions options) { writer.Write(value); } public Double Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadDouble(); } } public sealed class NullableDoubleFormatter : IMessagePackFormatter { public static readonly NullableDoubleFormatter Instance = new NullableDoubleFormatter(); private NullableDoubleFormatter() { } public void Serialize(ref MessagePackWriter writer, Double? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Double? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadDouble(); } } } public sealed class DoubleArrayFormatter : IMessagePackFormatter { public static readonly DoubleArrayFormatter Instance = new DoubleArrayFormatter(); private DoubleArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Double[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Double[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Double[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadDouble(); } return array; } } public sealed class BooleanFormatter : IMessagePackFormatter { public static readonly BooleanFormatter Instance = new BooleanFormatter(); private BooleanFormatter() { } public void Serialize(ref MessagePackWriter writer, Boolean value, MessagePackSerializerOptions options) { writer.Write(value); } public Boolean Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadBoolean(); } } public sealed class NullableBooleanFormatter : IMessagePackFormatter { public static readonly NullableBooleanFormatter Instance = new NullableBooleanFormatter(); private NullableBooleanFormatter() { } public void Serialize(ref MessagePackWriter writer, Boolean? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Boolean? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadBoolean(); } } } public sealed class BooleanArrayFormatter : IMessagePackFormatter { public static readonly BooleanArrayFormatter Instance = new BooleanArrayFormatter(); private BooleanArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Boolean[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Boolean[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Boolean[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadBoolean(); } return array; } } public sealed class ByteFormatter : IMessagePackFormatter { public static readonly ByteFormatter Instance = new ByteFormatter(); private ByteFormatter() { } public void Serialize(ref MessagePackWriter writer, Byte value, MessagePackSerializerOptions options) { writer.Write(value); } public Byte Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadByte(); } } public sealed class NullableByteFormatter : IMessagePackFormatter { public static readonly NullableByteFormatter Instance = new NullableByteFormatter(); private NullableByteFormatter() { } public void Serialize(ref MessagePackWriter writer, Byte? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Byte? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadByte(); } } } public sealed class SByteFormatter : IMessagePackFormatter { public static readonly SByteFormatter Instance = new SByteFormatter(); private SByteFormatter() { } public void Serialize(ref MessagePackWriter writer, SByte value, MessagePackSerializerOptions options) { writer.Write(value); } public SByte Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadSByte(); } } public sealed class NullableSByteFormatter : IMessagePackFormatter { public static readonly NullableSByteFormatter Instance = new NullableSByteFormatter(); private NullableSByteFormatter() { } public void Serialize(ref MessagePackWriter writer, SByte? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public SByte? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadSByte(); } } } public sealed class SByteArrayFormatter : IMessagePackFormatter { public static readonly SByteArrayFormatter Instance = new SByteArrayFormatter(); private SByteArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, SByte[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public SByte[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new SByte[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadSByte(); } return array; } } public sealed class CharFormatter : IMessagePackFormatter { public static readonly CharFormatter Instance = new CharFormatter(); private CharFormatter() { } public void Serialize(ref MessagePackWriter writer, Char value, MessagePackSerializerOptions options) { writer.Write(value); } public Char Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadChar(); } } public sealed class NullableCharFormatter : IMessagePackFormatter { public static readonly NullableCharFormatter Instance = new NullableCharFormatter(); private NullableCharFormatter() { } public void Serialize(ref MessagePackWriter writer, Char? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public Char? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadChar(); } } } public sealed class CharArrayFormatter : IMessagePackFormatter { public static readonly CharArrayFormatter Instance = new CharArrayFormatter(); private CharArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, Char[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public Char[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new Char[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadChar(); } return array; } } public sealed class DateTimeFormatter : IMessagePackFormatter { public static readonly DateTimeFormatter Instance = new DateTimeFormatter(); private DateTimeFormatter() { } public void Serialize(ref MessagePackWriter writer, DateTime value, MessagePackSerializerOptions options) { writer.Write(value); } public DateTime Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { return reader.ReadDateTime(); } } public sealed class NullableDateTimeFormatter : IMessagePackFormatter { public static readonly NullableDateTimeFormatter Instance = new NullableDateTimeFormatter(); private NullableDateTimeFormatter() { } public void Serialize(ref MessagePackWriter writer, DateTime? value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.Write(value.Value); } } public DateTime? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { return reader.ReadDateTime(); } } } public sealed class DateTimeArrayFormatter : IMessagePackFormatter { public static readonly DateTimeArrayFormatter Instance = new DateTimeArrayFormatter(); private DateTimeArrayFormatter() { } public void Serialize(ref MessagePackWriter writer, DateTime[] value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { writer.WriteArrayHeader(value.Length); for (int i = 0; i < value.Length; i++) { writer.Write(value[i]); } } } public DateTime[] Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } var len = reader.ReadArrayHeader(); if (len == 0) { return Array.Empty(); } var array = new DateTime[len]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadDateTime(); } return array; } } }