WIP, Additional Built-in Unity Type Support #178

This commit is contained in:
Yoshifumi Kawai 2017-12-22 01:06:46 +09:00
Родитель a5a9ea0e16
Коммит fbc2fde7d9
9 изменённых файлов: 1498 добавлений и 530 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,6 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Thread" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -35,23 +35,23 @@
<Reference Include="Esent.Interop, Version=1.9.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.2.0.0-rc4\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0-rc4\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp.Workspaces, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.0.0-rc4\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.CSharp.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Elfie, Version=0.10.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Elfie.0.10.6-rc2\lib\net46\Microsoft.CodeAnalysis.Elfie.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Workspaces, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0-rc4\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.Workspaces, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.6.1\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Workspaces.Desktop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0-rc4\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.Workspaces.Desktop, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.6.1\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@ -62,20 +62,20 @@
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Composition.AttributedModel, Version=1.0.27.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll</HintPath>
<Reference Include="System.Composition.AttributedModel, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Convention, Version=1.0.27.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll</HintPath>
<Reference Include="System.Composition.Convention, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Composition.Convention.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Hosting, Version=1.0.27.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll</HintPath>
<Reference Include="System.Composition.Hosting, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Runtime, Version=1.0.27.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll</HintPath>
<Reference Include="System.Composition.Runtime, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Composition.TypedParts, Version=1.0.27.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
<Reference Include="System.Composition.TypedParts, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
</Reference>
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>

Просмотреть файл

@ -54,6 +54,8 @@ namespace MessagePack.CodeGenerator
}
var workspace = MSBuildWorkspace.Create();
workspace.WorkspaceFailed += Workspace_WorkspaceFailed;
var project = await workspace.OpenProjectAsync(csprojPath).ConfigureAwait(false);
project = project.AddMetadataReferences(externalReferences); // workaround:)
project = project.WithParseOptions((project.ParseOptions as CSharpParseOptions).WithPreprocessorSymbols(preprocessorSymbols));
@ -62,6 +64,11 @@ namespace MessagePack.CodeGenerator
return compilation;
}
private static void Workspace_WorkspaceFailed(object sender, WorkspaceDiagnosticEventArgs e)
{
// throw new Exception(e.Diagnostic.ToString());
}
public static IEnumerable<INamedTypeSymbol> GetNamedTypeSymbols(this Compilation compilation)
{
foreach (var syntaxTree in compilation.SyntaxTrees)

Просмотреть файл

@ -2,16 +2,22 @@
<packages>
<package id="ManagedEsent" version="1.9.4" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Common" version="2.0.0-rc4" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.0.0-rc4" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="2.0.0-rc4" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Common" version="2.6.1" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.6.1" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="2.6.1" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Elfie" version="0.10.6-rc2" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="2.0.0-rc4" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="2.6.1" targetFramework="net461" />
<package id="Microsoft.Composition" version="1.0.30" targetFramework="net461" />
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net461" />
<package id="System.Composition" version="1.0.31" targetFramework="net461" />
<package id="System.Composition.AttributedModel" version="1.0.31" targetFramework="net461" />
<package id="System.Composition.Convention" version="1.0.31" targetFramework="net461" />
<package id="System.Composition.Hosting" version="1.0.31" targetFramework="net461" />
<package id="System.Composition.Runtime" version="1.0.31" targetFramework="net461" />
<package id="System.Composition.TypedParts" version="1.0.31" targetFramework="net461" />
<package id="System.Console" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net461" />

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -184,4 +184,366 @@ namespace UnityEngine
this.height = source.height;
}
}
}
// additional from 1.7.3
[MessagePackObject]
public sealed class AnimationCurve
{
[Key(0)]
public Keyframe[] keys { get; set; }
[IgnoreMember]
public int length { get { return keys.Length; } }
[Key(1)]
public WrapMode postWrapMode { get; set; }
[Key(2)]
public WrapMode preWrapMode { get; set; }
}
[MessagePackObject]
public struct Keyframe
{
private float m_Time;
private float m_Value;
private float m_InTangent;
private float m_OutTangent;
[Key(0)]
public float time
{
get
{
return this.m_Time;
}
set
{
this.m_Time = value;
}
}
[Key(1)]
public float value
{
get
{
return this.m_Value;
}
set
{
this.m_Value = value;
}
}
[Key(2)]
public float inTangent
{
get
{
return this.m_InTangent;
}
set
{
this.m_InTangent = value;
}
}
[Key(3)]
public float outTangent
{
get
{
return this.m_OutTangent;
}
set
{
this.m_OutTangent = value;
}
}
public Keyframe(float time, float value)
{
this.m_Time = time;
this.m_Value = value;
this.m_InTangent = 0f;
this.m_OutTangent = 0f;
}
[SerializationConstructor]
public Keyframe(float time, float value, float inTangent, float outTangent)
{
this.m_Time = time;
this.m_Value = value;
this.m_InTangent = inTangent;
this.m_OutTangent = outTangent;
}
}
public enum WrapMode
{
Once = 1,
Loop,
PingPong = 4,
Default = 0,
ClampForever = 8,
Clamp = 1
}
[MessagePackObject]
public struct Matrix4x4
{
[Key(0)]
public float m00;
[Key(1)]
public float m10;
[Key(2)]
public float m20;
[Key(3)]
public float m30;
[Key(4)]
public float m01;
[Key(5)]
public float m11;
[Key(6)]
public float m21;
[Key(7)]
public float m31;
[Key(8)]
public float m02;
[Key(9)]
public float m12;
[Key(10)]
public float m22;
[Key(11)]
public float m32;
[Key(12)]
public float m03;
[Key(13)]
public float m13;
[Key(14)]
public float m23;
[Key(15)]
public float m33;
}
[MessagePackObject]
public sealed class Gradient
{
[Key(0)]
public GradientColorKey[] colorKeys { get; set; }
[Key(1)]
public GradientAlphaKey[] alphaKeys { get; set; }
[Key(2)]
public GradientMode mode { get; set; }
}
[MessagePackObject]
public struct GradientColorKey
{
[Key(0)]
public Color color;
[Key(1)]
public float time;
public GradientColorKey(Color col, float time)
{
this.color = col;
this.time = time;
}
}
[MessagePackObject]
public struct GradientAlphaKey
{
[Key(0)]
public float alpha;
[Key(1)]
public float time;
public GradientAlphaKey(float alpha, float time)
{
this.alpha = alpha;
this.time = time;
}
}
public enum GradientMode
{
Blend,
Fixed
}
[MessagePackObject]
public struct Color32
{
[Key(0)]
public byte r;
[Key(1)]
public byte g;
[Key(2)]
public byte b;
[Key(3)]
public byte a;
public Color32(byte r, byte g, byte b, byte a)
{
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
}
[MessagePackObject]
public sealed class RectOffset
{
[Key(0)]
public int left { get; set; }
[Key(1)]
public int right { get; set; }
[Key(2)]
public int top { get; set; }
[Key(3)]
public int bottom { get; set; }
public RectOffset()
{
}
public RectOffset(int left, int right, int top, int bottom)
{
this.left = left;
this.right = right;
this.top = top;
this.bottom = bottom;
}
}
[MessagePackObject]
public struct LayerMask
{
[Key(0)]
public int value { get; set; }
}
// from Unity2017.2
[MessagePackObject]
public struct Vector2Int
{
[Key(0)]
public int x;
[Key(1)]
public int y;
[SerializationConstructor]
public Vector2Int(int x, int y)
{
this.x = x;
this.y = y;
}
}
[MessagePackObject]
public struct Vector3Int
{
[Key(0)]
public int x;
[Key(1)]
public int y;
[Key(2)]
public int z;
[SerializationConstructor]
public Vector3Int(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public static Vector3Int operator *(Vector3Int a, int d)
{
return new Vector3Int(a.x * d, a.y * d, a.z * d);
}
}
[MessagePackObject]
public struct RangeInt
{
[Key(0)]
public int start;
[Key(1)]
public int length;
public RangeInt(int start, int length)
{
this.start = start;
this.length = length;
}
}
[MessagePackObject]
public struct RectInt
{
[Key(0)]
public int x { get; set; }
[Key(1)]
public int y { get; set; }
[Key(2)]
public int width { get; set; }
[Key(3)]
public int height { get; set; }
[SerializationConstructor]
public RectInt(int x, int y, int width, int height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public RectInt(Vector2Int position, Vector2Int size)
{
this.x = position.x;
this.y = position.y;
this.width = size.x;
this.height = size.y;
}
public RectInt(RectInt source)
{
this.x = source.x;
this.y = source.y;
this.width = source.width;
this.height = source.height;
}
}
[MessagePackObject]
public struct BoundsInt
{
[Key(0)]
public Vector3Int position { get; set; }
[Key(1)]
public Vector3Int size { get; set; }
[SerializationConstructor]
public BoundsInt(Vector3Int position, Vector3Int size)
{
this.position = position;
this.size = size;
}
}
}

Просмотреть файл

@ -48,6 +48,31 @@ namespace MessagePack.Unity
{typeof(Color?),new StaticNullableFormatter<Color>(new ColorFormatter())},
{typeof(Bounds?),new StaticNullableFormatter<Bounds>(new BoundsFormatter())},
{typeof(Rect?),new StaticNullableFormatter<Rect>(new RectFormatter())},
//// TODO:
//// new
//{typeof(global::UnityEngine.Keyframe[]), 0 },
//{typeof(global::UnityEngine.GradientColorKey[]), 1 },
//{typeof(global::UnityEngine.GradientAlphaKey[]), 2 },
//{typeof(global::UnityEngine.WrapMode), 3 },
//{typeof(global::UnityEngine.GradientMode), 4 },
//{typeof(global::UnityEngine.Keyframe), 5 },
//{typeof(global::UnityEngine.AnimationCurve), 6 },
//{typeof(global::UnityEngine.Matrix4x4), 7 },
//{typeof(global::UnityEngine.GradientColorKey), 8 },
//{typeof(global::UnityEngine.GradientAlphaKey), 9 },
//{typeof(global::UnityEngine.Gradient), 10 },
//{typeof(global::UnityEngine.Color32), 11 },
//{typeof(global::UnityEngine.RectOffset), 12 },
//{typeof(global::UnityEngine.LayerMask), 13 },
//// Unity 2017.2
//{typeof(global::UnityEngine.Vector2Int), 14 },
//{typeof(global::UnityEngine.Vector3Int), 15 },
//{typeof(global::UnityEngine.RangeInt), 16 },
//{typeof(global::UnityEngine.RectInt), 17 },
//{typeof(global::UnityEngine.BoundsInt), 18 },
};
internal static object GetFormatter(Type t)