提交修改

This commit is contained in:
Bob.Song
2025-10-29 17:59:36 +08:00
parent b390cf2051
commit 5750c4fe56
2148 changed files with 13962 additions and 5549 deletions

View File

@@ -0,0 +1,32 @@
#if !NO_RUNTIME
using System;
namespace ProtoBuf.Serializers
{
sealed class CharSerializer : UInt16Serializer
{
static readonly Type expectedType = typeof(char);
public CharSerializer(ProtoBuf.Meta.TypeModel model) : base(model)
{
}
public override Type ExpectedType => expectedType;
public override void Write(object value, ProtoWriter dest)
{
ProtoWriter.WriteUInt16((ushort)(char)value, dest);
}
public override object Read(object value, ProtoReader source)
{
Helpers.DebugAssert(value == null); // since replaces
return (char)source.ReadUInt16();
}
// no need for any special IL here; ushort and char are
// interchangeable as long as there is no boxing/unboxing
}
}
#endif