ad lz4 project
This commit is contained in:
Родитель
03f9c3652a
Коммит
23674873e0
|
@ -47,6 +47,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePackAnalyzer.Vsix",
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamarinAndroid", "sandbox\XamarinAndroid\XamarinAndroid.csproj", "{307A14EF-C896-4024-BD80-95A55B22C2AB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.LZ4", "src\MessagePack.LZ4\MessagePack.LZ4.csproj", "{6303CD14-F396-409C-BCBF-4DA3105EC45C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -207,6 +209,18 @@ Global
|
|||
{307A14EF-C896-4024-BD80-95A55B22C2AB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{307A14EF-C896-4024-BD80-95A55B22C2AB}.Release|x86.Build.0 = Release|Any CPU
|
||||
{307A14EF-C896-4024-BD80-95A55B22C2AB}.Release|x86.Deploy.0 = Release|Any CPU
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Debug|x64.Build.0 = Debug|x64
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Debug|x86.Build.0 = Debug|x86
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Release|x64.ActiveCfg = Release|x64
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Release|x64.Build.0 = Release|x64
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Release|x86.ActiveCfg = Release|x86
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -224,5 +238,6 @@ Global
|
|||
{2F9A6E0C-DE95-4460-96B7-EB72BBEAEE9E} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}
|
||||
{09B87BEB-D9A3-4EEB-B56A-ED53D27DF1A3} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}
|
||||
{307A14EF-C896-4024-BD80-95A55B22C2AB} = {BF4C4202-5015-4FBD-80E6-D0F36A06F700}
|
||||
{6303CD14-F396-409C-BCBF-4DA3105EC45C} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
22
README.md
22
README.md
|
@ -134,7 +134,7 @@ TODO:
|
|||
|
||||
Extensions
|
||||
---
|
||||
MessagePack for C# has extension point and you can add external type' serialization support. There are official extension support.
|
||||
MessagePack for C# has extension point and you can add external type's serialization support. There are official extension support.
|
||||
|
||||
```
|
||||
Install-Package MessagePack.ImmutableCollection
|
||||
|
@ -148,13 +148,30 @@ Install-Package MessagePack.UnityShims
|
|||
|
||||
`MessagePack.UnityShims` package provides shim of [Unity](https://unity3d.com/)'s standard struct(`Vector2`, `Vector3`, `Vector4`, `Quaternion`, `Color`, `Bounds`, `Rect`) and there formatter. It can enable to commnicate between server and Unity client.
|
||||
|
||||
After install, extension package must enable by configuration. Here is sample of enable all extension.
|
||||
|
||||
```csharp
|
||||
// set extensions to default resolver.
|
||||
MessagePack.Resolvers.CompositeResolver.RegisterAndSetAsDefault(
|
||||
// enable extension packages first
|
||||
ImmutableCollectionResolver.Instance,
|
||||
ReactivePropertyResolver.Instance,
|
||||
MessagePack.Unity.Extension.UnityBlitResolver.Instance,
|
||||
MessagePack.Unity.UnityResolver.Instance,
|
||||
|
||||
// finaly use standard(default) resolver
|
||||
StandardResolver.Instance);
|
||||
);
|
||||
```
|
||||
|
||||
Configuration details, see:Extension section.
|
||||
|
||||
Author is creating other extension packages, too.
|
||||
|
||||
* [MasterMemory](https://github.com/neuecc/MasterMemory) - Embedded Readonly In-Memory Document Database
|
||||
* [MagicOnion](https://github.com/neuecc/MagicOnion) - gRPC based HTTP/2 RPC Streaming Framework
|
||||
|
||||
|
||||
You can make your own extension serializers, let's create them and share it!
|
||||
|
||||
High-Level API(MessagePackSerializer)
|
||||
---
|
||||
|
@ -260,6 +277,7 @@ Extension Point(IFormatterResolver)
|
|||
| --- | --- |
|
||||
| BuiltinResolver | Builtin primitive and standard classes resolver. It includes primitive(int, bool, string...) and there nullable, array and list. and some extra builtin types(Guid, Uri, BigInteger, etc...). |
|
||||
| StandardResolver | Composited resolver . It resolves in the following order `builtin -> dynamic enum -> dynamic generic -> dynamic union -> dynamic object`. This is the default of MessagePackSerializer. |
|
||||
| ContractlessStandardResolver | Composited `StandardResolver` -> `DynamicContractlessObjectResolver`. It enables contractless serialization. |
|
||||
| CompositeResolver | Singleton helper of setup custom resolvers. You can use `Register` or `RegisterAndSetAsDefault` API. |
|
||||
| DynamicEnumResolver | Resolver of enum and there nullable. It uses dynamic code generation to avoid boxing and boostup performance. |
|
||||
| DynamicGenericResolver | Resolver of generic type(`Tuple<>`, `List<>`, `Dictionary<,>`, `Array`, etc). It uses reflection call for resolve generic argument. |
|
||||
|
|
|
@ -13,6 +13,8 @@ mklink ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\StringEncoding.
|
|||
mklink /D ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\Formatters" "..\..\..\..\MessagePack\Formatters"
|
||||
mklink /D ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\Internal" "..\..\..\..\MessagePack\Internal"
|
||||
mklink /D ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\Resolvers" "..\..\..\..\MessagePack\Resolvers"
|
||||
mklink ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\Unity\UnityResolver.cs" "..\..\..\..\..\MessagePack.UnityShims\UnityResolver.cs"
|
||||
mklink ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\Unity\Formatters.cs" "..\..\..\..\..\MessagePack.UnityShims\Formatters.cs"
|
||||
mklink ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\UnsafeExtensions\UnityBlitResolver.cs" "..\..\..\..\..\MessagePack.UnityShims\Extension\UnityBlitResolver.cs"
|
||||
mklink ".\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\UnsafeExtensions\UnsafeBlitFormatter.cs" "..\..\..\..\..\MessagePack.UnityShims\Extension\UnsafeBlitFormatter.cs"
|
||||
mklink ".\src\MessagePack.UnityClient\Assets\Scripts\Tests\Class1.cs" "..\..\..\..\..\sandbox\SharedData\Class1.cs"
|
||||
|
|
|
@ -15,75 +15,6 @@ using UnityEngine;
|
|||
|
||||
namespace Sandbox
|
||||
{
|
||||
public enum MyEnum
|
||||
{
|
||||
Apple, Orange, Pineapple
|
||||
}
|
||||
[MessagePackObject]
|
||||
public class EmptyClass
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public struct EmptyStruct
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[ZeroFormattable]
|
||||
[ProtoBuf.ProtoContract]
|
||||
[MessagePackObject(true)]
|
||||
public class SmallSingleObject
|
||||
{
|
||||
[Index(0)]
|
||||
[Key(0)]
|
||||
[ProtoBuf.ProtoMember(1)]
|
||||
public virtual int MyProperty { get; set; }
|
||||
[Index(1)]
|
||||
[Key(1)]
|
||||
[ProtoBuf.ProtoMember(2)]
|
||||
public virtual int MyProperty2 { get; set; }
|
||||
[Index(2)]
|
||||
[Key(2)]
|
||||
[ProtoBuf.ProtoMember(3)]
|
||||
public virtual MyEnum MyProperty3 { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public struct MyStruct
|
||||
{
|
||||
[Key(0)]
|
||||
public byte[] MyProperty { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[MessagePackObject(true)]
|
||||
public class NewObj
|
||||
{
|
||||
[Key(0)]
|
||||
public int MyProperty { get; private set; }
|
||||
public NewObj(int myProperty)
|
||||
{
|
||||
this.MyProperty = myProperty;
|
||||
}
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public struct Vector2
|
||||
{
|
||||
[Key(0)]
|
||||
public readonly float X;
|
||||
[Key(1)]
|
||||
public readonly float Y;
|
||||
|
||||
public Vector2(float x, float y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[ZeroFormattable]
|
||||
[ProtoBuf.ProtoContract]
|
||||
|
@ -196,11 +127,12 @@ namespace Sandbox
|
|||
|
||||
static void Benchmark<T>(T target)
|
||||
{
|
||||
const int Iteration = 10000;
|
||||
const int Iteration = 10000; // 10000
|
||||
|
||||
var msgpack = MsgPack.Serialization.SerializationContext.Default;
|
||||
msgpack.GetSerializer<T>().PackSingleObject(target);
|
||||
MessagePack.MessagePackSerializer.Serialize(target);
|
||||
LZ4MessagePackSerializer.Serialize(target);
|
||||
ZeroFormatter.ZeroFormatterSerializer.Serialize(target);
|
||||
ProtoBuf.Serializer.Serialize(new MemoryStream(), target);
|
||||
|
||||
|
@ -212,6 +144,7 @@ namespace Sandbox
|
|||
byte[] data0 = null;
|
||||
byte[] data1 = null;
|
||||
byte[] data2 = null;
|
||||
byte[] data3 = null;
|
||||
using (new Measure("MsgPack-Cli"))
|
||||
{
|
||||
for (int i = 0; i < Iteration; i++)
|
||||
|
@ -251,10 +184,20 @@ namespace Sandbox
|
|||
data2 = ms.ToArray();
|
||||
}
|
||||
|
||||
|
||||
using (new Measure("MessagePack(LZ4)"))
|
||||
{
|
||||
for (int i = 0; i < Iteration; i++)
|
||||
{
|
||||
data3 = LZ4MessagePackSerializer.Serialize(target);
|
||||
}
|
||||
}
|
||||
|
||||
msgpack.GetSerializer<T>().UnpackSingleObject(data);
|
||||
MessagePack.MessagePackSerializer.Deserialize<T>(data0);
|
||||
ZeroFormatterSerializer.Deserialize<T>(data1);
|
||||
ProtoBuf.Serializer.Deserialize<T>(new MemoryStream(data2));
|
||||
LZ4MessagePackSerializer.Deserialize<T>(data3);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Deserialize::");
|
||||
|
@ -294,6 +237,14 @@ namespace Sandbox
|
|||
}
|
||||
}
|
||||
|
||||
using (new Measure("MessagePack(LZ4)"))
|
||||
{
|
||||
for (int i = 0; i < Iteration; i++)
|
||||
{
|
||||
LZ4MessagePackSerializer.Deserialize<T>(data3);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("FileSize::");
|
||||
var label = "";
|
||||
|
@ -301,6 +252,7 @@ namespace Sandbox
|
|||
label = "MessagePack-CSharp"; Console.WriteLine($"{label,20} {data0.Length} Byte");
|
||||
label = "ZeroFormatter"; Console.WriteLine($"{label,20} {data1.Length} Byte");
|
||||
label = "protobuf-net"; Console.WriteLine($"{label,20} {data2.Length} Byte");
|
||||
label = "MessagePack(LZ4)"; Console.WriteLine($"{label,20} {data3.Length} Byte");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="lz4net" Version="1.0.11.93" />
|
||||
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
|
||||
<PackageReference Include="MsgPack.Cli" Version="0.9.0-beta2" />
|
||||
<PackageReference Include="protobuf-net" Version="2.1.0" />
|
||||
|
@ -17,6 +18,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\MessagePack.LZ4\MessagePack.LZ4.csproj" />
|
||||
<ProjectReference Include="..\..\src\MessagePack.UnityShims\MessagePack.UnityShims.csproj" />
|
||||
<ProjectReference Include="..\..\src\MessagePack\MessagePack.csproj" />
|
||||
<ProjectReference Include="..\SharedData\SharedData.csproj" />
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace MessagePack
|
||||
{
|
||||
// JSON API
|
||||
public static partial class LZ4MessagePackSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// Dump to JSON string.
|
||||
/// </summary>
|
||||
public static string ToJson<T>(T obj)
|
||||
{
|
||||
return ToJson(Serialize(obj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dump to JSON string.
|
||||
/// </summary>
|
||||
public static string ToJson<T>(T obj, IFormatterResolver resolver)
|
||||
{
|
||||
return ToJson(Serialize(obj, resolver));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dump message-pack binary to JSON string.
|
||||
/// </summary>
|
||||
public static string ToJson(byte[] bytes)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0) return "";
|
||||
|
||||
int readSize;
|
||||
if (MessagePackBinary.GetMessagePackType(bytes, 0) == MessagePackType.Extension)
|
||||
{
|
||||
var header = MessagePackBinary.ReadExtensionFormatHeader(bytes, 0, out readSize);
|
||||
if (header.TypeCode == ExtensionTypeCode)
|
||||
{
|
||||
// decode lz4
|
||||
var offset = checked((int)header.Length);
|
||||
var length = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var buffer = InternalMemoryPool.GetBuffer();
|
||||
if (!(buffer.Length < length))
|
||||
{
|
||||
buffer = new byte[length];
|
||||
}
|
||||
|
||||
// LZ4 Decode
|
||||
global::LZ4.LZ4Codec.Decode(bytes, offset, bytes.Length - offset, buffer, 0, length, true);
|
||||
|
||||
bytes = buffer; // use LZ4 bytes
|
||||
}
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
ToJsonCore(bytes, 0, sb);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
static int ToJsonCore(byte[] bytes, int offset, StringBuilder builder)
|
||||
{
|
||||
var readSize = 0;
|
||||
var type = MessagePackBinary.GetMessagePackType(bytes, offset);
|
||||
switch (type)
|
||||
{
|
||||
case MessagePackType.Integer:
|
||||
var code = bytes[offset];
|
||||
if (MessagePackCode.MinNegativeFixInt <= code && code <= MessagePackCode.MaxNegativeFixInt) builder.Append(MessagePackBinary.ReadSByte(bytes, offset, out readSize));
|
||||
else if (MessagePackCode.MinFixInt <= code && code <= MessagePackCode.MaxFixInt) builder.Append(MessagePackBinary.ReadByte(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.Int8) builder.Append(MessagePackBinary.ReadSByte(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.Int16) builder.Append(MessagePackBinary.ReadInt16(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.Int32) builder.Append(MessagePackBinary.ReadInt32(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.Int64) builder.Append(MessagePackBinary.ReadInt64(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.UInt8) builder.Append(MessagePackBinary.ReadByte(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.UInt16) builder.Append(MessagePackBinary.ReadUInt16(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.UInt32) builder.Append(MessagePackBinary.ReadUInt32(bytes, offset, out readSize));
|
||||
else if (code == MessagePackCode.UInt64) builder.Append(MessagePackBinary.ReadUInt64(bytes, offset, out readSize));
|
||||
break;
|
||||
case MessagePackType.Boolean:
|
||||
builder.Append(MessagePackBinary.ReadBoolean(bytes, offset, out readSize) ? "true" : "false");
|
||||
break;
|
||||
case MessagePackType.Float:
|
||||
builder.Append(MessagePackBinary.ReadDouble(bytes, offset, out readSize));
|
||||
break;
|
||||
case MessagePackType.String:
|
||||
WriteJsonString(MessagePackBinary.ReadString(bytes, offset, out readSize), builder);
|
||||
break;
|
||||
case MessagePackType.Binary:
|
||||
builder.Append("\"" + Convert.ToBase64String(MessagePackBinary.ReadBytes(bytes, offset, out readSize)) + "\"");
|
||||
break;
|
||||
case MessagePackType.Array:
|
||||
{
|
||||
var length = MessagePackBinary.ReadArrayHeaderRaw(bytes, offset, out readSize);
|
||||
var totalReadSize = readSize;
|
||||
offset += readSize;
|
||||
builder.Append("[");
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
readSize = ToJsonCore(bytes, offset, builder);
|
||||
offset += readSize;
|
||||
totalReadSize += readSize;
|
||||
|
||||
if (i != length - 1)
|
||||
{
|
||||
builder.Append(",");
|
||||
}
|
||||
}
|
||||
builder.Append("]");
|
||||
|
||||
return totalReadSize;
|
||||
}
|
||||
case MessagePackType.Map:
|
||||
{
|
||||
var length = MessagePackBinary.ReadMapHeaderRaw(bytes, offset, out readSize);
|
||||
var totalReadSize = readSize;
|
||||
offset += readSize;
|
||||
builder.Append("{");
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
// write key
|
||||
{
|
||||
var keyType = MessagePackBinary.GetMessagePackType(bytes, offset);
|
||||
if (keyType == MessagePackType.String || keyType == MessagePackType.Binary)
|
||||
{
|
||||
readSize = ToJsonCore(bytes, offset, builder);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Append("\"");
|
||||
readSize = ToJsonCore(bytes, offset, builder);
|
||||
builder.Append("\"");
|
||||
}
|
||||
offset += readSize;
|
||||
totalReadSize += readSize;
|
||||
}
|
||||
|
||||
builder.Append(":");
|
||||
|
||||
// write body
|
||||
{
|
||||
readSize = ToJsonCore(bytes, offset, builder);
|
||||
offset += readSize;
|
||||
totalReadSize += readSize;
|
||||
}
|
||||
|
||||
if (i != length - 1)
|
||||
{
|
||||
builder.Append(",");
|
||||
}
|
||||
}
|
||||
builder.Append("}");
|
||||
|
||||
return totalReadSize;
|
||||
}
|
||||
case MessagePackType.Extension:
|
||||
var ext = MessagePackBinary.ReadExtensionFormat(bytes, offset, out readSize);
|
||||
if (ext.TypeCode == ReservedMessagePackExtensionTypeCode.DateTime)
|
||||
{
|
||||
var dt = MessagePackBinary.ReadDateTime(bytes, offset, out readSize);
|
||||
builder.Append("\"");
|
||||
builder.Append(dt.ToString("o", CultureInfo.InvariantCulture));
|
||||
builder.Append("\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Append("[");
|
||||
builder.Append(ext.TypeCode);
|
||||
builder.Append(",");
|
||||
builder.Append("\"");
|
||||
builder.Append(Convert.ToBase64String(ext.Data));
|
||||
builder.Append("\"");
|
||||
builder.Append("]");
|
||||
}
|
||||
break;
|
||||
case MessagePackType.Unknown:
|
||||
case MessagePackType.Nil:
|
||||
default:
|
||||
readSize = 1;
|
||||
builder.Append("null");
|
||||
break;
|
||||
}
|
||||
|
||||
return readSize;
|
||||
}
|
||||
|
||||
// escape string
|
||||
static void WriteJsonString(string value, StringBuilder builder)
|
||||
{
|
||||
builder.Append('\"');
|
||||
|
||||
var len = value.Length;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
var c = value[i];
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
builder.Append("\\\"");
|
||||
break;
|
||||
case '\\':
|
||||
builder.Append("\\\\");
|
||||
break;
|
||||
case '\b':
|
||||
builder.Append("\\b");
|
||||
break;
|
||||
case '\f':
|
||||
builder.Append("\\f");
|
||||
break;
|
||||
case '\n':
|
||||
builder.Append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.Append("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
builder.Append("\\t");
|
||||
break;
|
||||
default:
|
||||
builder.Append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append('\"');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace MessagePack
|
||||
{
|
||||
public static partial class LZ4MessagePackSerializer
|
||||
{
|
||||
public static class NonGeneric
|
||||
{
|
||||
static readonly System.Collections.Generic.Dictionary<Type, CompiledMethods> serializes = new System.Collections.Generic.Dictionary<Type, CompiledMethods>();
|
||||
|
||||
public static byte[] Serialize(Type type, object obj)
|
||||
{
|
||||
return GetOrAdd(type).serialize1.Invoke(obj);
|
||||
}
|
||||
|
||||
public static byte[] Serialize(Type type, object obj, IFormatterResolver resolver)
|
||||
{
|
||||
return GetOrAdd(type).serialize2.Invoke(obj, resolver);
|
||||
}
|
||||
|
||||
public static void Serialize(Type type, Stream stream, object obj)
|
||||
{
|
||||
GetOrAdd(type).serialize3.Invoke(stream, obj);
|
||||
}
|
||||
|
||||
public static void Serialize(Type type, Stream stream, object obj, IFormatterResolver resolver)
|
||||
{
|
||||
GetOrAdd(type).serialize4.Invoke(stream, obj, resolver);
|
||||
}
|
||||
|
||||
public static object Deserialize(Type type, byte[] bytes)
|
||||
{
|
||||
return GetOrAdd(type).deserialize1.Invoke(bytes);
|
||||
}
|
||||
|
||||
public static object Deserialize(Type type, byte[] bytes, IFormatterResolver resolver)
|
||||
{
|
||||
return GetOrAdd(type).deserialize2.Invoke(bytes, resolver);
|
||||
}
|
||||
|
||||
public static object Deserialize(Type type, Stream stream)
|
||||
{
|
||||
return GetOrAdd(type).deserialize3.Invoke(stream);
|
||||
}
|
||||
|
||||
public static object Deserialize(Type type, Stream stream, IFormatterResolver resolver)
|
||||
{
|
||||
return GetOrAdd(type).deserialize4.Invoke(stream, resolver);
|
||||
}
|
||||
|
||||
static CompiledMethods GetOrAdd(Type type)
|
||||
{
|
||||
lock (serializes)
|
||||
{
|
||||
CompiledMethods method;
|
||||
if (serializes.TryGetValue(type, out method))
|
||||
{
|
||||
return method;
|
||||
}
|
||||
else
|
||||
{
|
||||
method = new CompiledMethods(type);
|
||||
serializes.Add(type, method);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CompiledMethods
|
||||
{
|
||||
public readonly Func<object, byte[]> serialize1;
|
||||
public readonly Func<object, IFormatterResolver, byte[]> serialize2;
|
||||
public readonly Action<Stream, object> serialize3;
|
||||
public readonly Action<Stream, object, IFormatterResolver> serialize4;
|
||||
|
||||
public readonly Func<byte[], object> deserialize1;
|
||||
public readonly Func<byte[], IFormatterResolver, object> deserialize2;
|
||||
public readonly Func<Stream, object> deserialize3;
|
||||
public readonly Func<Stream, IFormatterResolver, object> deserialize4;
|
||||
|
||||
public CompiledMethods(Type type)
|
||||
{
|
||||
var ti = type.GetTypeInfo();
|
||||
{
|
||||
// public static byte[] Serialize<T>(T obj)
|
||||
var serialize = GetMethod(type, new Type[] { null });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(object), "obj");
|
||||
var body = Expression.Call(serialize, ti.IsValueType
|
||||
? Expression.Unbox(param1, type)
|
||||
: Expression.Convert(param1, type));
|
||||
var lambda = Expression.Lambda<Func<object, byte[]>>(body, param1).Compile();
|
||||
|
||||
this.serialize1 = lambda;
|
||||
}
|
||||
{
|
||||
// public static byte[] Serialize<T>(T obj, IFormatterResolver resolver)
|
||||
var serialize = GetMethod(type, new Type[] { null, typeof(IFormatterResolver) });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(object), "obj");
|
||||
var param2 = Expression.Parameter(typeof(IFormatterResolver), "formatterResolver");
|
||||
|
||||
var body = Expression.Call(serialize, ti.IsValueType
|
||||
? Expression.Unbox(param1, type)
|
||||
: Expression.Convert(param1, type), param2);
|
||||
var lambda = Expression.Lambda<Func<object, IFormatterResolver, byte[]>>(body, param1, param2).Compile();
|
||||
|
||||
this.serialize2 = lambda;
|
||||
}
|
||||
{
|
||||
// public static void Serialize<T>(Stream stream, T obj)
|
||||
var serialize = GetMethod(type, new Type[] { typeof(Stream), null });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(Stream), "stream");
|
||||
var param2 = Expression.Parameter(typeof(object), "obj");
|
||||
|
||||
var body = Expression.Call(serialize, param1, ti.IsValueType
|
||||
? Expression.Unbox(param2, type)
|
||||
: Expression.Convert(param2, type));
|
||||
var lambda = Expression.Lambda<Action<Stream, object>>(body, param1, param2).Compile();
|
||||
|
||||
this.serialize3 = lambda;
|
||||
}
|
||||
{
|
||||
// public static void Serialize<T>(Stream stream, T obj, IFormatterResolver resolver)
|
||||
var serialize = GetMethod(type, new Type[] { typeof(Stream), null, typeof(IFormatterResolver) });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(Stream), "stream");
|
||||
var param2 = Expression.Parameter(typeof(object), "obj");
|
||||
var param3 = Expression.Parameter(typeof(IFormatterResolver), "formatterResolver");
|
||||
|
||||
var body = Expression.Call(serialize, param1, ti.IsValueType
|
||||
? Expression.Unbox(param2, type)
|
||||
: Expression.Convert(param2, type), param3);
|
||||
var lambda = Expression.Lambda<Action<Stream, object, IFormatterResolver>>(body, param1, param2, param3).Compile();
|
||||
|
||||
this.serialize4 = lambda;
|
||||
}
|
||||
|
||||
{
|
||||
// public static T Deserialize<T>(byte[] bytes)
|
||||
var deserialize = GetMethod(type, new Type[] { typeof(byte[]) });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(byte[]), "bytes");
|
||||
var body = Expression.Convert(Expression.Call(deserialize, param1), typeof(object));
|
||||
var lambda = Expression.Lambda<Func<byte[], object>>(body, param1).Compile();
|
||||
|
||||
this.deserialize1 = lambda;
|
||||
}
|
||||
{
|
||||
// public static T Deserialize<T>(byte[] bytes, IFormatterResolver resolver)
|
||||
var deserialize = GetMethod(type, new Type[] { typeof(byte[]), typeof(IFormatterResolver) });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(byte[]), "bytes");
|
||||
var param2 = Expression.Parameter(typeof(IFormatterResolver), "resolver");
|
||||
var body = Expression.Convert(Expression.Call(deserialize, param1, param2), typeof(object));
|
||||
var lambda = Expression.Lambda<Func<byte[], IFormatterResolver, object>>(body, param1, param2).Compile();
|
||||
|
||||
this.deserialize2 = lambda;
|
||||
}
|
||||
{
|
||||
// public static T Deserialize<T>(Stream stream)
|
||||
var deserialize = GetMethod(type, new Type[] { typeof(Stream) });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(Stream), "stream");
|
||||
var body = Expression.Convert(Expression.Call(deserialize, param1), typeof(object));
|
||||
var lambda = Expression.Lambda<Func<Stream, object>>(body, param1).Compile();
|
||||
|
||||
this.deserialize3 = lambda;
|
||||
}
|
||||
|
||||
{
|
||||
// public static T Deserialize<T>(Stream stream, IFormatterResolver resolver)
|
||||
var deserialize = GetMethod(type, new Type[] { typeof(Stream), typeof(IFormatterResolver) });
|
||||
|
||||
var param1 = Expression.Parameter(typeof(Stream), "stream");
|
||||
var param2 = Expression.Parameter(typeof(IFormatterResolver), "resolver");
|
||||
var body = Expression.Convert(Expression.Call(deserialize, param1, param2), typeof(object));
|
||||
var lambda = Expression.Lambda<Func<Stream, IFormatterResolver, object>>(body, param1, param2).Compile();
|
||||
|
||||
this.deserialize4 = lambda;
|
||||
}
|
||||
}
|
||||
|
||||
// null is generic type marker.
|
||||
static MethodInfo GetMethod(Type type, Type[] parameters)
|
||||
{
|
||||
return typeof(LZ4MessagePackSerializer).GetRuntimeMethods().Where(x =>
|
||||
{
|
||||
if (!(x.Name == "Serialize" || x.Name == "Deserialize")) return false;
|
||||
var ps = x.GetParameters();
|
||||
if (ps.Length != parameters.Length) return false;
|
||||
for (int i = 0; i < ps.Length; i++)
|
||||
{
|
||||
if (parameters[i] == null && ps[i].ParameterType.IsGenericParameter) continue;
|
||||
if (ps[i].ParameterType != parameters[i]) return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.Single()
|
||||
.MakeGenericMethod(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MessagePack
|
||||
{
|
||||
/// <summary>
|
||||
/// LZ4 Compressed special serializer.
|
||||
/// </summary>
|
||||
public static partial class LZ4MessagePackSerializer
|
||||
{
|
||||
public const byte ExtensionTypeCode = 99;
|
||||
|
||||
public const int MinSize = 50;
|
||||
|
||||
static IFormatterResolver defaultResolver;
|
||||
|
||||
/// <summary>
|
||||
/// FormatterResolver that used resolver less overloads. If does not set it, used StandardResolver.
|
||||
/// </summary>
|
||||
public static IFormatterResolver DefaultResolver
|
||||
{
|
||||
get
|
||||
{
|
||||
if (defaultResolver == null)
|
||||
{
|
||||
defaultResolver = MessagePack.Resolvers.StandardResolver.Instance;
|
||||
}
|
||||
|
||||
return defaultResolver;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is resolver decided?
|
||||
/// </summary>
|
||||
public static bool IsInitialized
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultResolver != null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set default resolver of MessagePackSerializer APIs.
|
||||
/// </summary>
|
||||
/// <param name="resolver"></param>
|
||||
public static void SetDefaultResolver(IFormatterResolver resolver)
|
||||
{
|
||||
defaultResolver = resolver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize to binary with default resolver.
|
||||
/// </summary>
|
||||
public static byte[] Serialize<T>(T obj)
|
||||
{
|
||||
return Serialize(obj, defaultResolver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize to binary with specified resolver.
|
||||
/// </summary>
|
||||
public static byte[] Serialize<T>(T obj, IFormatterResolver resolver)
|
||||
{
|
||||
if (resolver == null) resolver = DefaultResolver;
|
||||
var buffer = SerializeCore(obj, resolver);
|
||||
|
||||
return MessagePackBinary.FastCloneWithResize(buffer.Array, buffer.Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize to stream.
|
||||
/// </summary>
|
||||
public static void Serialize<T>(Stream stream, T obj)
|
||||
{
|
||||
Serialize(stream, obj, defaultResolver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize to stream with specified resolver.
|
||||
/// </summary>
|
||||
public static void Serialize<T>(Stream stream, T obj, IFormatterResolver resolver)
|
||||
{
|
||||
if (resolver == null) resolver = DefaultResolver;
|
||||
var buffer = SerializeCore(obj, resolver);
|
||||
|
||||
stream.Write(buffer.Array, 0, buffer.Count);
|
||||
}
|
||||
|
||||
static ArraySegment<byte> SerializeCore<T>(T obj, IFormatterResolver resolver)
|
||||
{
|
||||
var formatter = resolver.GetFormatterWithVerify<T>();
|
||||
|
||||
var serializedData = MessagePackSerializer.SerializeUnsafe(obj, resolver);
|
||||
|
||||
if (serializedData.Count < MinSize)
|
||||
{
|
||||
return serializedData;
|
||||
}
|
||||
else
|
||||
{
|
||||
var offset = 0;
|
||||
var buffer = InternalMemoryPool.GetBuffer();
|
||||
var maxOutCount = global::LZ4.LZ4Codec.MaximumOutputLength(serializedData.Count);
|
||||
if (buffer.Length + 18 + 5 < maxOutCount) // (max ext header size + fixed length size)
|
||||
{
|
||||
buffer = new byte[maxOutCount];
|
||||
}
|
||||
|
||||
// write ext header
|
||||
offset += MessagePackBinary.WriteExtensionFormatHeader(ref buffer, offset, (sbyte)ExtensionTypeCode, serializedData.Count + 5);
|
||||
|
||||
// write length(always 5 bytes)
|
||||
offset += MessagePackBinary.WriteInt32ForceInt32Block(ref buffer, offset, serializedData.Count);
|
||||
|
||||
// write body
|
||||
var lz4Length = global::LZ4.LZ4Codec.Encode(serializedData.Array, serializedData.Offset, serializedData.Count, buffer, offset, serializedData.Count);
|
||||
|
||||
return new ArraySegment<byte>(buffer, 0, lz4Length + offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(byte[] bytes)
|
||||
{
|
||||
return Deserialize<T>(bytes, defaultResolver);
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(byte[] bytes, IFormatterResolver resolver)
|
||||
{
|
||||
if (resolver == null) resolver = DefaultResolver;
|
||||
var formatter = resolver.GetFormatterWithVerify<T>();
|
||||
|
||||
int readSize;
|
||||
if (MessagePackBinary.GetMessagePackType(bytes, 0) == MessagePackType.Extension)
|
||||
{
|
||||
var header = MessagePackBinary.ReadExtensionFormatHeader(bytes, 0, out readSize);
|
||||
if (header.TypeCode == ExtensionTypeCode)
|
||||
{
|
||||
// decode lz4
|
||||
var offset = readSize;
|
||||
var length = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var buffer = InternalMemoryPool.GetBuffer();
|
||||
if (!(buffer.Length < length))
|
||||
{
|
||||
buffer = new byte[length];
|
||||
}
|
||||
|
||||
// LZ4 Decode
|
||||
global::LZ4.LZ4Codec.Decode(bytes, offset, bytes.Length - offset, buffer, 0, length, true);
|
||||
|
||||
return formatter.Deserialize(buffer, 0, resolver, out readSize);
|
||||
}
|
||||
}
|
||||
|
||||
return formatter.Deserialize(bytes, 0, resolver, out readSize);
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(Stream stream)
|
||||
{
|
||||
return Deserialize<T>(stream, defaultResolver);
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(Stream stream, IFormatterResolver resolver)
|
||||
{
|
||||
if (resolver == null) resolver = DefaultResolver;
|
||||
var formatter = resolver.GetFormatterWithVerify<T>();
|
||||
|
||||
var buffer = InternalMemoryPool.GetBuffer();
|
||||
|
||||
FillFromStream(stream, ref buffer);
|
||||
|
||||
return Deserialize<T>(buffer, resolver);
|
||||
}
|
||||
|
||||
static int FillFromStream(Stream input, ref byte[] buffer)
|
||||
{
|
||||
int length = 0;
|
||||
int read;
|
||||
while ((read = input.Read(buffer, length, buffer.Length - length)) > 0)
|
||||
{
|
||||
length += read;
|
||||
if (length == buffer.Length)
|
||||
{
|
||||
MessagePackBinary.FastResize(ref buffer, length * 2);
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class InternalMemoryPool
|
||||
{
|
||||
[ThreadStatic]
|
||||
static byte[] buffer = null;
|
||||
|
||||
public static byte[] GetBuffer()
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
buffer = new byte[65536];
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard1.6</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;RELEASE;NETSTANDARD1_6</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="lz4net" Version="1.0.11.93" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MessagePack\MessagePack.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1 @@
|
|||
../../../../../MessagePack.UnityShims/Formatters.cs
|
|
@ -0,0 +1 @@
|
|||
../../../../../MessagePack.UnityShims/UnityResolver.cs
|
|
@ -186,7 +186,7 @@ namespace MessagePack.UnityClient.Tests
|
|||
{
|
||||
return (IMessagePackFormatter<T>)(object)new ValueTupleFormatter<int, int, int, int>();
|
||||
}
|
||||
return DefaultResolver.Instance.GetFormatter<T>();
|
||||
return StandardResolver.Instance.GetFormatter<T>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using MessagePack.Resolvers;
|
||||
using MessagePack.Unity.Extension;
|
||||
using MsgPack.Serialization;
|
||||
using Sandbox.Shared;
|
||||
using Sandbox.Shared.GeneratedSerializers;
|
||||
|
@ -102,10 +101,10 @@ namespace MessagePack.UnityClient.Tests
|
|||
return;
|
||||
}
|
||||
|
||||
formatter = UnityBlitResolver.Instance.GetFormatter<T>();
|
||||
formatter = Unity.Extension.UnityBlitResolver.Instance.GetFormatter<T>();
|
||||
if (formatter == null)
|
||||
{
|
||||
formatter = DefaultResolver.Instance.GetFormatter<T>();
|
||||
formatter = StandardResolver.Instance.GetFormatter<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace MessagePack.UnityClient.Tests
|
|||
var f = DynamicUnionResolver.Instance.GetFormatter<IUnionChecker>();
|
||||
|
||||
byte[] b = null;
|
||||
f.Serialize(ref b, 0, null, DefaultResolver.Instance);
|
||||
f.Serialize(ref b, 0, null, StandardResolver.Instance);
|
||||
|
||||
//var data = new MySubUnion1 { One = 23 };
|
||||
//var data2 = new MySubUnion1 { One = 23 };
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
using MessagePack.Resolvers;
|
||||
using MessagePack.Unity.Extension;
|
||||
using RuntimeUnitTestToolkit;
|
||||
using SharedData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -15,7 +12,7 @@ namespace MessagePack.UnityClient.Tests
|
|||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return (UnityBlitWithPrimitiveArrayResolver.Instance.GetFormatter<T>()
|
||||
?? DefaultResolver.Instance.GetFormatter<T>());
|
||||
?? StandardResolver.Instance.GetFormatter<T>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<IntermediateOutputPath>Temp\UnityVS_obj\Debug\</IntermediateOutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_7;UNITY_5_3;UNITY_5;UNITY_64;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;UNSAFE;</DefineConstants>
|
||||
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_7;UNITY_5_3;UNITY_5;UNITY_64;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;ENABLE_UNSAFE_RESOLVER;</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
|
@ -37,7 +37,7 @@
|
|||
<IntermediateOutputPath>Temp\UnityVS_obj\Release\</IntermediateOutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DefineConstants>TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_7;UNITY_5_3;UNITY_5;UNITY_64;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;UNSAFE;</DefineConstants>
|
||||
<DefineConstants>TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_7;UNITY_5_3;UNITY_5;UNITY_64;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;ENABLE_UNSAFE_RESOLVER;</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
@ -108,13 +108,15 @@
|
|||
<Compile Include="Assets\Scripts\MessagePack\Nil.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\BuiltinResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\CompositeResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\DefaultResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\DynamicEnumResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\DynamicGenericResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\DynamicObjectResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\DynamicUnionResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Resolvers\StandardResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Shims\Reflection.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\StringEncoding.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Unity\Formatters.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\Unity\UnityResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\UnsafeExtensions\UnityBlitResolver.cs" />
|
||||
<Compile Include="Assets\Scripts\MessagePack\UnsafeExtensions\UnsafeBlitFormatter.cs" />
|
||||
<Compile Include="Assets\Scripts\RuntimeUnitTestToolkit\Assert.cs" />
|
||||
|
|
Двоичный файл не отображается.
|
@ -1,4 +1,4 @@
|
|||
#if UNSAFE
|
||||
#if ENABLE_UNSAFE_RESOLVER
|
||||
|
||||
using MessagePack.Formatters;
|
||||
using System;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if UNSAFE
|
||||
#if ENABLE_UNSAFE_RESOLVER
|
||||
|
||||
using MessagePack.Formatters;
|
||||
using System;
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __x__ = default(float);
|
||||
var __y__ = default(float);
|
||||
var x = default(float);
|
||||
var y = default(float);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -37,13 +37,13 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__x__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
x = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__y__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
y = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -51,8 +51,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Vector2(__x__, __y__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Vector2(x, y);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,9 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __x__ = default(float);
|
||||
var __y__ = default(float);
|
||||
var __z__ = default(float);
|
||||
var x = default(float);
|
||||
var y = default(float);
|
||||
var z = default(float);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -93,16 +93,16 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__x__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
x = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__y__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
y = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 2:
|
||||
__z__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
z = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -110,8 +110,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Vector3(__x__, __y__, __z__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Vector3(x, y, z);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,10 +142,10 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __x__ = default(float);
|
||||
var __y__ = default(float);
|
||||
var __z__ = default(float);
|
||||
var __w__ = default(float);
|
||||
var x = default(float);
|
||||
var y = default(float);
|
||||
var z = default(float);
|
||||
var w = default(float);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -154,19 +154,19 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__x__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
x = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__y__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
y = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 2:
|
||||
__z__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
z = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 3:
|
||||
__w__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
w = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -174,8 +174,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Vector4(__x__, __y__, __z__, __w__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Vector4(x, y, z, w);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,10 +206,10 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __x__ = default(float);
|
||||
var __y__ = default(float);
|
||||
var __z__ = default(float);
|
||||
var __w__ = default(float);
|
||||
var x = default(float);
|
||||
var y = default(float);
|
||||
var z = default(float);
|
||||
var w = default(float);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -218,19 +218,19 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__x__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
x = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__y__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
y = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 2:
|
||||
__z__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
z = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 3:
|
||||
__w__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
w = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -238,8 +238,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Quaternion(__x__, __y__, __z__, __w__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Quaternion(x, y, z, w);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,10 +270,10 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __r__ = default(float);
|
||||
var __g__ = default(float);
|
||||
var __b__ = default(float);
|
||||
var __a__ = default(float);
|
||||
var r = default(float);
|
||||
var g = default(float);
|
||||
var b = default(float);
|
||||
var a = default(float);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -282,19 +282,19 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__r__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
r = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__g__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
g = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 2:
|
||||
__b__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
b = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 3:
|
||||
__a__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
a = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -302,8 +302,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Color(__r__, __g__, __b__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Color(r, g, b, a);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,8 +332,8 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __center__ = default(global::UnityEngine.Vector3);
|
||||
var __size__ = default(global::UnityEngine.Vector3);
|
||||
var center = default(global::UnityEngine.Vector3);
|
||||
var size = default(global::UnityEngine.Vector3);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -342,13 +342,13 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__center__ = formatterResolver.GetFormatterWithVerify<global::UnityEngine.Vector3>().Deserialize(bytes, offset, formatterResolver, out readSize);
|
||||
center = formatterResolver.GetFormatterWithVerify<global::UnityEngine.Vector3>().Deserialize(bytes, offset, formatterResolver, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__size__ = formatterResolver.GetFormatterWithVerify<global::UnityEngine.Vector3>().Deserialize(bytes, offset, formatterResolver, out readSize);
|
||||
size = formatterResolver.GetFormatterWithVerify<global::UnityEngine.Vector3>().Deserialize(bytes, offset, formatterResolver, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -356,8 +356,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Bounds(__center__, __size__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Bounds(center, size);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,10 +388,10 @@ namespace MessagePack.Unity
|
|||
var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
|
||||
offset += readSize;
|
||||
|
||||
var __x__ = default(float);
|
||||
var __y__ = default(float);
|
||||
var __width__ = default(float);
|
||||
var __height__ = default(float);
|
||||
var x = default(float);
|
||||
var y = default(float);
|
||||
var width = default(float);
|
||||
var height = default(float);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -400,19 +400,19 @@ namespace MessagePack.Unity
|
|||
switch (key)
|
||||
{
|
||||
case 0:
|
||||
__x__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
x = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 1:
|
||||
__y__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
y = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 2:
|
||||
__width__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
width = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
case 3:
|
||||
__height__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
height = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
|
||||
break;
|
||||
default:
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNext(bytes, offset);
|
||||
readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
|
||||
break;
|
||||
}
|
||||
offset += readSize;
|
||||
|
@ -420,8 +420,8 @@ namespace MessagePack.Unity
|
|||
|
||||
readSize = offset - startOffset;
|
||||
|
||||
var ____result = new global::UnityEngine.Rect(__x__, __y__, __width__, __height__);
|
||||
return ____result;
|
||||
var result = new global::UnityEngine.Rect(x, y, width, height);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,12 +9,12 @@
|
|||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<DocumentationFile>bin\Release\netstandard1.4\MessagePack.UnityShims.xml</DocumentationFile>
|
||||
<NoWarn>1701;1702;1705;1591</NoWarn>
|
||||
<DefineConstants>TRACE;RELEASE;NETSTANDARD1_4;UNSAFE</DefineConstants>
|
||||
<DefineConstants>TRACE;RELEASE;NETSTANDARD1_4;UNSAFE;RELEASE;NETSTANDARD1_4;ENABLE_UNSAFE_RESOLVER</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_4;UNSAFE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_4;ENABLE_UNSAFE_RESOLVER;</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace UnityEngine
|
|||
[Key(1)]
|
||||
public float y;
|
||||
|
||||
[SerializationConstructor]
|
||||
public Vector2(float x, float y)
|
||||
{
|
||||
this.x = x;
|
||||
|
@ -27,6 +28,7 @@ namespace UnityEngine
|
|||
[Key(2)]
|
||||
public float z;
|
||||
|
||||
[SerializationConstructor]
|
||||
public Vector3(float x, float y, float z)
|
||||
{
|
||||
this.x = x;
|
||||
|
@ -52,6 +54,7 @@ namespace UnityEngine
|
|||
[Key(3)]
|
||||
public float w;
|
||||
|
||||
[SerializationConstructor]
|
||||
public Vector4(float x, float y, float z, float w)
|
||||
{
|
||||
this.x = x;
|
||||
|
@ -73,6 +76,7 @@ namespace UnityEngine
|
|||
[Key(3)]
|
||||
public float w;
|
||||
|
||||
[SerializationConstructor]
|
||||
public Quaternion(float x, float y, float z, float w)
|
||||
{
|
||||
this.x = x;
|
||||
|
@ -100,6 +104,7 @@ namespace UnityEngine
|
|||
|
||||
}
|
||||
|
||||
[SerializationConstructor]
|
||||
public Color(float r, float g, float b, float a)
|
||||
{
|
||||
this.r = r;
|
||||
|
@ -131,6 +136,7 @@ namespace UnityEngine
|
|||
}
|
||||
}
|
||||
|
||||
[SerializationConstructor]
|
||||
public Bounds(Vector3 center, Vector3 size)
|
||||
{
|
||||
this.center = center;
|
||||
|
|
|
@ -45,8 +45,8 @@ namespace MessagePack.Unity
|
|||
{typeof(Vector3?), new StaticNullableFormatter<Vector3>(new Vector3Formatter())},
|
||||
{typeof(Vector4?), new StaticNullableFormatter<Vector4>(new Vector4Formatter())},
|
||||
{typeof(Quaternion?),new StaticNullableFormatter<Quaternion>(new QuaternionFormatter())},
|
||||
{typeof(Color?),new StaticNullableFormatter<Color>( new ColorFormatter())},
|
||||
{typeof(Bounds?),new StaticNullableFormatter<Bounds>( new BoundsFormatter())},
|
||||
{typeof(Color?),new StaticNullableFormatter<Color>(new ColorFormatter())},
|
||||
{typeof(Bounds?),new StaticNullableFormatter<Bounds>(new BoundsFormatter())},
|
||||
{typeof(Rect?),new StaticNullableFormatter<Rect>(new RectFormatter())},
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_4;</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_4;NETSTANDARD1_4</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
|
|
@ -211,6 +211,9 @@ namespace MessagePack
|
|||
dateTimeDecoders[MessagePackCode.Ext8] = Decoders.Ext8DateTime.Instance;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static void EnsureCapacity(ref byte[] bytes, int offset, int appendLength)
|
||||
{
|
||||
var newLength = offset + appendLength;
|
||||
|
@ -243,6 +246,9 @@ namespace MessagePack
|
|||
}
|
||||
|
||||
// Buffer.BlockCopy version of Array.Resize
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static void FastResize(ref byte[] array, int newSize)
|
||||
{
|
||||
if (newSize < 0) throw new ArgumentOutOfRangeException("newSize");
|
||||
|
@ -262,6 +268,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static byte[] FastCloneWithResize(byte[] array, int newSize)
|
||||
{
|
||||
if (newSize < 0) throw new ArgumentOutOfRangeException("newSize");
|
||||
|
@ -278,11 +287,17 @@ namespace MessagePack
|
|||
return array3;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static MessagePackType GetMessagePackType(byte[] bytes, int offset)
|
||||
{
|
||||
return MessagePackCode.ToMessagePackType(bytes[offset]);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static bool IsMessagePackPrimitive(Type type)
|
||||
{
|
||||
if (type == typeof(Int16)
|
||||
|
@ -307,11 +322,17 @@ namespace MessagePack
|
|||
return false;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int ReadNext(byte[] bytes, int offset)
|
||||
{
|
||||
return readNextDecoders[bytes[offset]].Read(bytes, offset);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int ReadNextBlock(byte[] bytes, int offset)
|
||||
{
|
||||
switch (GetMessagePackType(bytes, offset))
|
||||
|
@ -354,6 +375,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteNil(ref byte[] bytes, int offset)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 1);
|
||||
|
@ -362,6 +386,9 @@ namespace MessagePack
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static Nil ReadNil(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
if (bytes[offset] == MessagePackCode.Nil)
|
||||
|
@ -375,6 +402,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static bool IsNil(byte[] bytes, int offset)
|
||||
{
|
||||
return bytes[offset] == MessagePackCode.Nil;
|
||||
|
@ -384,6 +414,9 @@ namespace MessagePack
|
|||
/// Unsafe. If value is guranteed 0 ~ MessagePackRange.MaxFixMapCount(15), can use this method.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteFixedMapHeaderUnsafe(ref byte[] bytes, int offset, int count)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 1);
|
||||
|
@ -394,6 +427,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Write map count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteMapHeader(ref byte[] bytes, int offset, int count)
|
||||
{
|
||||
checked
|
||||
|
@ -405,6 +441,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Write map count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteMapHeader(ref byte[] bytes, int offset, uint count)
|
||||
{
|
||||
if (count <= MessagePackRange.MaxFixMapCount)
|
||||
|
@ -442,6 +481,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Return map count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int ReadMapHeader(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
checked
|
||||
|
@ -453,11 +495,17 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Return map count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static uint ReadMapHeaderRaw(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return mapHeaderDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int GetArrayHeaderLength(int count)
|
||||
{
|
||||
if (count <= MessagePackRange.MaxFixArrayCount)
|
||||
|
@ -478,6 +526,9 @@ namespace MessagePack
|
|||
/// Unsafe. If value is guranteed 0 ~ MessagePackRange.MaxFixArrayCount(15), can use this method.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteFixedArrayHeaderUnsafe(ref byte[] bytes, int offset, int count)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 1);
|
||||
|
@ -488,6 +539,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Write array count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteArrayHeader(ref byte[] bytes, int offset, int count)
|
||||
{
|
||||
checked
|
||||
|
@ -499,6 +553,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Write array count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteArrayHeader(ref byte[] bytes, int offset, uint count)
|
||||
{
|
||||
if (count <= MessagePackRange.MaxFixArrayCount)
|
||||
|
@ -536,6 +593,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Return array count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int ReadArrayHeader(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
checked
|
||||
|
@ -547,11 +607,17 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Return array count.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static uint ReadArrayHeaderRaw(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return arrayHeaderDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteBoolean(ref byte[] bytes, int offset, bool value)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 1);
|
||||
|
@ -560,12 +626,18 @@ namespace MessagePack
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static bool ReadBoolean(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
readSize = 1;
|
||||
return booleanDecoders[bytes[offset]].Read();
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteByte(ref byte[] bytes, int offset, byte value)
|
||||
{
|
||||
if (value <= MessagePackCode.MaxFixInt)
|
||||
|
@ -583,11 +655,17 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static byte ReadByte(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return byteDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteBytes(ref byte[] bytes, int offset, byte[] value)
|
||||
{
|
||||
if (value == null)
|
||||
|
@ -600,6 +678,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteBytes(ref byte[] dest, int dstOffset, byte[] src, int srcOffset, int count)
|
||||
{
|
||||
if (src == null)
|
||||
|
@ -651,11 +732,17 @@ namespace MessagePack
|
|||
return size;
|
||||
}
|
||||
}
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static byte[] ReadBytes(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return bytesDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteSByte(ref byte[] bytes, int offset, sbyte value)
|
||||
{
|
||||
if (value < MessagePackRange.MinFixNegativeInt)
|
||||
|
@ -673,11 +760,17 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static sbyte ReadSByte(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return sbyteDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteSingle(ref byte[] bytes, int offset, float value)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 5);
|
||||
|
@ -703,11 +796,17 @@ namespace MessagePack
|
|||
return 5;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static float ReadSingle(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return singleDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteDouble(ref byte[] bytes, int offset, double value)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 9);
|
||||
|
@ -741,11 +840,17 @@ namespace MessagePack
|
|||
return 9;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static double ReadDouble(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return doubleDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteInt16(ref byte[] bytes, int offset, short value)
|
||||
{
|
||||
if (value >= 0)
|
||||
|
@ -800,6 +905,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static short ReadInt16(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return int16Decoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
|
@ -808,7 +916,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Unsafe. If value is guranteed 0 ~ MessagePackCode.MaxFixInt(127), can use this method.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WritePositiveFixedIntUnsafe(ref byte[] bytes, int offset, int value)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 1);
|
||||
|
@ -816,6 +926,9 @@ namespace MessagePack
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteInt32(ref byte[] bytes, int offset, int value)
|
||||
{
|
||||
if (value >= 0)
|
||||
|
@ -893,6 +1006,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Acquire static message block(always 5 bytes).
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteInt32ForceInt32Block(ref byte[] bytes, int offset, int value)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, 5);
|
||||
|
@ -904,11 +1020,17 @@ namespace MessagePack
|
|||
return 5;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int ReadInt32(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return int32Decoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteInt64(ref byte[] bytes, int offset, long value)
|
||||
{
|
||||
if (value >= 0)
|
||||
|
@ -1011,11 +1133,17 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static long ReadInt64(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return int64Decoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteUInt16(ref byte[] bytes, int offset, ushort value)
|
||||
{
|
||||
if (value <= MessagePackRange.MaxFixPositiveInt)
|
||||
|
@ -1041,11 +1169,17 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static ushort ReadUInt16(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return uint16Decoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteUInt32(ref byte[] bytes, int offset, uint value)
|
||||
{
|
||||
if (value <= MessagePackRange.MaxFixPositiveInt)
|
||||
|
@ -1081,11 +1215,17 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static uint ReadUInt32(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return uint32Decoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteUInt64(ref byte[] bytes, int offset, ulong value)
|
||||
{
|
||||
if (value <= MessagePackRange.MaxFixPositiveInt)
|
||||
|
@ -1135,16 +1275,25 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static ulong ReadUInt64(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return uint64Decoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteChar(ref byte[] bytes, int offset, char value)
|
||||
{
|
||||
return WriteUInt16(ref bytes, offset, (ushort)value);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static char ReadChar(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return (char)ReadUInt16(bytes, offset, out readSize);
|
||||
|
@ -1153,6 +1302,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Unsafe. If value is guranteed length is 0 ~ 31, can use this method.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteFixedStringUnsafe(ref byte[] bytes, int offset, string value, int byteCount)
|
||||
{
|
||||
EnsureCapacity(ref bytes, offset, byteCount + 1);
|
||||
|
@ -1165,6 +1317,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// Unsafe. If pre-calculated byteCount of target string, can use this method.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteStringUnsafe(ref byte[] bytes, int offset, string value, int byteCount)
|
||||
{
|
||||
if (byteCount <= MessagePackRange.MaxFixStringLength)
|
||||
|
@ -1204,6 +1359,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteString(ref byte[] bytes, int offset, string value)
|
||||
{
|
||||
if (value == null) return WriteNil(ref bytes, offset);
|
||||
|
@ -1212,11 +1370,17 @@ namespace MessagePack
|
|||
return WriteStringUnsafe(ref bytes, offset, value, byteCount);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static string ReadString(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return stringDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteExtensionFormatHeader(ref byte[] bytes, int offset, sbyte typeCode, int dataLength)
|
||||
{
|
||||
switch (dataLength)
|
||||
|
@ -1281,6 +1445,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteExtensionFormat(ref byte[] bytes, int offset, sbyte typeCode, byte[] data)
|
||||
{
|
||||
var length = data.Length;
|
||||
|
@ -1380,6 +1547,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static ExtensionResult ReadExtensionFormat(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return extDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
|
@ -1388,6 +1558,9 @@ namespace MessagePack
|
|||
/// <summary>
|
||||
/// return byte length of ExtensionFormat.
|
||||
/// </summary>
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static ExtensionHeader ReadExtensionFormatHeader(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return extHeaderDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
|
@ -1399,6 +1572,9 @@ namespace MessagePack
|
|||
// FixExt8(-1) => nanoseconds + seconds | [1970-01-01 00:00:00.000000000 UTC, 2514-05-30 01:53:04.000000000 UTC) range
|
||||
// Ext8(12,-1) => nanoseconds + seconds | [-584554047284-02-23 16:59:44 UTC, 584554051223-11-09 07:00:16.000000000 UTC) range
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static int WriteDateTime(ref byte[] bytes, int offset, DateTime dateTime)
|
||||
{
|
||||
dateTime = dateTime.ToUniversalTime();
|
||||
|
@ -1491,6 +1667,9 @@ namespace MessagePack
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_4
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public static DateTime ReadDateTime(byte[] bytes, int offset, out int readSize)
|
||||
{
|
||||
return dateTimeDecoders[bytes[offset]].Read(bytes, offset, out readSize);
|
||||
|
@ -2439,7 +2618,7 @@ namespace MessagePack.Decoders
|
|||
readSize = 5;
|
||||
unchecked
|
||||
{
|
||||
return (long)((long)(bytes[offset + 1] << 24) | (long)(bytes[offset + 2] << 16) | (long)(bytes[offset + 3] << 8) | (long)bytes[offset + 4]);
|
||||
return (long)((long)(bytes[offset + 1] << 24) + (long)(bytes[offset + 2] << 16) + (long)(bytes[offset + 3] << 8) + (long)bytes[offset + 4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2714,7 +2893,7 @@ namespace MessagePack.Decoders
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class UInt64UInt64 : IUInt64Decoder
|
||||
{
|
||||
internal static readonly IUInt64Decoder Instance = new UInt64UInt64();
|
||||
|
|
|
@ -13,6 +13,13 @@ namespace MessagePack.Resolvers
|
|||
{
|
||||
BuiltinResolver.Instance, // Try Builtin
|
||||
|
||||
#if !NETSTANDARD1_4
|
||||
MessagePack.Unity.UnityResolver.Instance,
|
||||
#if ENABLE_UNSAFE_RESOLVER
|
||||
MessagePack.Unity.Extension.UnityBlitResolver.Instance,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !ENABLE_IL2CPP
|
||||
|
||||
DynamicEnumResolver.Instance, // Try Enum
|
||||
|
@ -51,9 +58,9 @@ namespace MessagePack.Resolvers
|
|||
}
|
||||
}
|
||||
|
||||
public class DefaultWithContractlessResolver : IFormatterResolver
|
||||
public class ContractlessStandardResolver : IFormatterResolver
|
||||
{
|
||||
public static IFormatterResolver Instance = new DefaultWithContractlessResolver();
|
||||
public static IFormatterResolver Instance = new ContractlessStandardResolver();
|
||||
|
||||
static readonly IFormatterResolver[] resolvers = new[]
|
||||
{
|
||||
|
@ -61,7 +68,7 @@ namespace MessagePack.Resolvers
|
|||
DynamicContractlessObjectResolver.Instance,
|
||||
};
|
||||
|
||||
DefaultWithContractlessResolver()
|
||||
ContractlessStandardResolver()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MessagePack.Tests.ExtensionTests
|
|||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return (ImmutableCollectionResolver.Instance.GetFormatter<T>()
|
||||
?? DefaultResolver.Instance.GetFormatter<T>());
|
||||
?? StandardResolver.Instance.GetFormatter<T>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace MessagePack.Tests.ExtensionTests
|
|||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return (ReactivePropertyResolver.Instance.GetFormatter<T>()
|
||||
?? DefaultResolver.Instance.GetFormatter<T>());
|
||||
?? StandardResolver.Instance.GetFormatter<T>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MessagePack.Tests.ExtensionTests
|
|||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return (UnityBlitWithPrimitiveArrayResolver.Instance.GetFormatter<T>()
|
||||
?? DefaultResolver.Instance.GetFormatter<T>());
|
||||
?? StandardResolver.Instance.GetFormatter<T>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,16 @@ namespace MessagePack.Tests
|
|||
var ms = new MemoryStream();
|
||||
|
||||
var data1 = MessagePackSerializer.NonGeneric.Deserialize(t, MessagePackSerializer.NonGeneric.Serialize(t, data)) as FirstSimpleData;
|
||||
var data2 = MessagePackSerializer.NonGeneric.Deserialize(t, MessagePackSerializer.NonGeneric.Serialize(t, data, DefaultResolver.Instance)) as FirstSimpleData;
|
||||
var data2 = MessagePackSerializer.NonGeneric.Deserialize(t, MessagePackSerializer.NonGeneric.Serialize(t, data, StandardResolver.Instance)) as FirstSimpleData;
|
||||
|
||||
MessagePackSerializer.NonGeneric.Serialize(t, ms, data);
|
||||
ms.Position = 0;
|
||||
var data3 = MessagePackSerializer.NonGeneric.Deserialize(t, ms) as FirstSimpleData;
|
||||
|
||||
ms = new MemoryStream();
|
||||
MessagePackSerializer.NonGeneric.Serialize(t, ms, data, DefaultResolver.Instance);
|
||||
MessagePackSerializer.NonGeneric.Serialize(t, ms, data, StandardResolver.Instance);
|
||||
ms.Position = 0;
|
||||
var data4 = MessagePackSerializer.NonGeneric.Deserialize(t, ms, DefaultResolver.Instance) as FirstSimpleData;
|
||||
var data4 = MessagePackSerializer.NonGeneric.Deserialize(t, ms, StandardResolver.Instance) as FirstSimpleData;
|
||||
|
||||
new[] { data1.Prop1, data2.Prop1, data3.Prop1, data4.Prop1 }.Distinct().Is(data.Prop1);
|
||||
new[] { data1.Prop2, data2.Prop2, data3.Prop2, data4.Prop2 }.Distinct().Is(data.Prop2);
|
||||
|
|
Загрузка…
Ссылка в новой задаче