diff --git a/MsgPack.CodeGeneration.nuspec b/MsgPack.CodeGeneration.nuspec new file mode 100644 index 000000000..2afab7389 --- /dev/null +++ b/MsgPack.CodeGeneration.nuspec @@ -0,0 +1,31 @@ + + + + MsgPack.Cli.CodeGeneration + MessagePack for CLI numeric types serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains ahead of time source code generation features. + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.Core.nuspec b/MsgPack.Core.nuspec new file mode 100644 index 000000000..412c95c8a --- /dev/null +++ b/MsgPack.Core.nuspec @@ -0,0 +1,46 @@ + + + + MsgPack.Cli.Core + MessagePack for CLI Core + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package provides MessagePack core libraries only. +If you want to use serialization features, check MsgPack.Cli.Serialization, MsgPack.Cli.*.Serializers packages. +You can also install all packages with MsgPack.Cli (meta) package. + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.CryptographyPrimitiveSerializers.nuspec b/MsgPack.CryptographyPrimitiveSerializers.nuspec new file mode 100644 index 000000000..cc016928f --- /dev/null +++ b/MsgPack.CryptographyPrimitiveSerializers.nuspec @@ -0,0 +1,33 @@ + + + + MsgPack.Cli.CryptographyPrimitiveSerializers + MessagePack for CLI cryptography primitive types serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains MessagePack out-of-box serializers for cryptography primitive types namely: +- System.Security.Cryptography.HashAlgorithmNameMessagePackSerializer + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.DbTypeSerializers.nuspec b/MsgPack.DbTypeSerializers.nuspec new file mode 100644 index 000000000..be4b19203 --- /dev/null +++ b/MsgPack.DbTypeSerializers.nuspec @@ -0,0 +1,33 @@ + + + + MsgPack.Cli.DbTypeSerializers + MessagePack for CLI DB type serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains MessagePack out-of-box serializers for ADO.NET common types namely: +- System.Data.Common.DBNull + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.LegacyCollectionSerializers.nuspec b/MsgPack.LegacyCollectionSerializers.nuspec new file mode 100644 index 000000000..875a7d3d5 --- /dev/null +++ b/MsgPack.LegacyCollectionSerializers.nuspec @@ -0,0 +1,39 @@ + + + + MsgPack.Cli.LegacyCollectionSerializers + MessagePack for CLI legacy collection serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains MessagePack out-of-box serializers for legacy collections namely: +- System.Collections.Stack +- System.Collections.Queue +- System.Collections.Specialized.BitVector32 +- System.Collections.Specialized.NameValueCollection + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.NumericSerializers.nuspec b/MsgPack.NumericSerializers.nuspec new file mode 100644 index 000000000..509aa24c6 --- /dev/null +++ b/MsgPack.NumericSerializers.nuspec @@ -0,0 +1,34 @@ + + + + MsgPack.Cli.NumericSerializers + MessagePack for CLI numeric types serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains MessagePack out-of-box serializers for numeric types namely: +- System.Numerics.BigInteger +- System.Numerics.Complex + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.RuntimeGeneration.nuspec b/MsgPack.RuntimeGeneration.nuspec new file mode 100644 index 000000000..ca02dc0d7 --- /dev/null +++ b/MsgPack.RuntimeGeneration.nuspec @@ -0,0 +1,28 @@ + + + + MsgPack.Cli.RuntimeGeneration + MessagePack for CLI numeric types serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains runtime (on-the-fly) builder code generation feature which is available only non AOT environments. + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.Serialization.nuspec b/MsgPack.Serialization.nuspec new file mode 100644 index 000000000..ba0f2950d --- /dev/null +++ b/MsgPack.Serialization.nuspec @@ -0,0 +1,59 @@ + + + + MsgPack.Cli.Serialization + MessagePack for CLI Serialization + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package provides MessagePack serialization APIs. +If you want to use built-in serializers for known structures and collections, check MsgPack.Cli.*.Serializers packages. +You can also install all packages with MsgPack.Cli (meta) package. + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.VectorSerializers.nuspec b/MsgPack.VectorSerializers.nuspec new file mode 100644 index 000000000..c648e57c9 --- /dev/null +++ b/MsgPack.VectorSerializers.nuspec @@ -0,0 +1,40 @@ + + + + MsgPack.Cli.VectorSerializers + MessagePack for CLI SIMD ready vector types serializers + 0.0.0-development + FUJIWARA, Yusuke + FUJIWARA, Yusuke + http://www.apache.org/licenses/LICENSE-2.0 + https://github.com/msgpack/msgpack-cli + http://cli.msgpack.org/images/msgpack.ico + false + MessagePack is fast, compact, and interoperable binary serialization format. +This package contains MessagePack out-of-box serializers for SIMD ready vector types namely: +- System.Numerics.Vectors.Vector2 +- System.Numerics.Vectors.Vector3 +- System.Numerics.Vectors.Vector4 +- System.Numerics.Vectors.Plane +- System.Numerics.Vectors.Quaternion +- System.Numerics.Vectors.Matrix3x2 +- System.Numerics.Vectors.Matrix4x4 + + + This release includes new code generators and package reorganization to reduce entire size in most cases. + Copyright 2010-2016 FUJIWARA, Yusuke, all rights reserved. + MsgPack MessagePack Serialization Formatter Serializer + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MsgPack.sln b/MsgPack.sln index 2f81409d1..fcd3aa0d5 100644 --- a/MsgPack.sln +++ b/MsgPack.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{60EC42E9-D79B-4ADF-8F80-4DCD580061FD}" ProjectSection(SolutionItems) = preProject @@ -42,7 +42,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET45", ".NET45", "{3E9C77 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsgPack.Net45", "src\MsgPack.Net45\MsgPack.Net45.csproj", "{9C7B55A6-AF7F-4D26-AB5B-297B7FF25B6D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsgPack.PerformanceTest", "test\MsgPack.PerformanceTest\MsgPack.PerformanceTest.csproj", "{568D0201-0204-41FB-8BCA-C19F145B7167}" +EndProject Global + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution CodeAnalysis|Any CPU = CodeAnalysis|Any CPU CodeAnalysis|ARM = CodeAnalysis|ARM @@ -234,6 +239,46 @@ Global {9C7B55A6-AF7F-4D26-AB5B-297B7FF25B6D}.Release|Mixed Platforms.Build.0 = Release|Any CPU {9C7B55A6-AF7F-4D26-AB5B-297B7FF25B6D}.Release|x64.ActiveCfg = Release|Any CPU {9C7B55A6-AF7F-4D26-AB5B-297B7FF25B6D}.Release|x86.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|ARM.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|ARM.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|Mixed Platforms.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|Mixed Platforms.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|x64.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|x64.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|x86.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.CodeAnalysis|x86.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|Any CPU.Build.0 = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|ARM.ActiveCfg = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|ARM.Build.0 = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|x64.ActiveCfg = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|x64.Build.0 = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|x86.ActiveCfg = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Debug|x86.Build.0 = Debug|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|Any CPU.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|Any CPU.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|ARM.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|ARM.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|Mixed Platforms.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|x64.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|x64.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|x86.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.PerformanceTest|x86.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|Any CPU.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|Any CPU.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|ARM.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|ARM.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|x64.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|x64.Build.0 = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|x86.ActiveCfg = Release|Any CPU + {568D0201-0204-41FB-8BCA-C19F145B7167}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -250,5 +295,6 @@ Global {EACF1BF1-CB21-4D62-942C-3488F60B8D70} = {87A17015-9338-431E-B338-57BDA03984C1} {3E9C7751-EE97-4820-BFEF-BA5F532A45C9} = {1BD5D488-707E-4030-8AE8-80D93D04963F} {9C7B55A6-AF7F-4D26-AB5B-297B7FF25B6D} = {3E9C7751-EE97-4820-BFEF-BA5F532A45C9} + {568D0201-0204-41FB-8BCA-C19F145B7167} = {AF25D7E8-2F55-4431-BCE1-7C3E3C0E74E1} EndGlobalSection EndGlobal diff --git a/src/MsgPack.CodeGeneration/NuGet.config b/src/MsgPack.CodeGeneration/NuGet.config new file mode 100644 index 000000000..e1237ef0e --- /dev/null +++ b/src/MsgPack.CodeGeneration/NuGet.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/MsgPack.CodeGeneration/Properties/AssemblyInfo.cs b/src/MsgPack.CodeGeneration/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..0b00f1da5 --- /dev/null +++ b/src/MsgPack.CodeGeneration/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Code Generation" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) serializer source code generation feature." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.CodeGeneration/project.json b/src/MsgPack.CodeGeneration/project.json new file mode 100644 index 000000000..84441158e --- /dev/null +++ b/src/MsgPack.CodeGeneration/project.json @@ -0,0 +1,78 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": { + "version": "4.4.0-beta-00000-00", + "suppressParent": "all" + }, + "System.CodeDom": { + "version": "4.4.0-beta-00000-00", + "suppressParent": "all" + }, + "System.IO.FileSystem": { + "version": "4.4.0-beta-00000-00", + "suppressParent": "all" + }, + "System.Runtime.Serialization.Primitives": { + "version": "4.4.0-beta-00000-00", + "suppressParent": "all" + }, + "MsgPack.Core": { + "version": "*", + "target": "project", + "suppressParent": "all" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project", + "suppressParent": "all" + }, + "MsgPack.RuntimeGeneration": { + "version": "*", + "target": "project", + "suppressParent": "all" + } + }, + "frameworks": { + "netstandard1.7": {} + }, + "buildOptions": { + "outputName": "MsgPack.CodeGeneration", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerationContext.cs", + "../MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerator.cs", + "../MsgPack/Serialization/CodeDomSerializers/*.cs", + "../MsgPack/Serialization/CodeGenerationSink.cs", + "../MsgPack/Serialization/IndividualFileCodeGenerationSink.cs", + "../MsgPack/Serialization/ISerializerGeneratorConfiguration.cs", + "../MsgPack/Serialization/SerializerAssemblyGenerationConfiguration.cs", + "../MsgPack/Serialization/SerializerCodeGenerationConfiguration.cs", + "../MsgPack/Serialization/SerializerCodeInformation.cs", + "../MsgPack/Serialization/SerializerGenerator.cs", + "../MsgPack/Serialization/SerializerCodeGenerationContext.cs", + "../MsgPack/Serialization/SerializerCodeGenerationResult.cs", + "../MsgPack/Serialization/SingleTextWriterCodeGenerationSink.cs", + "../MsgPack/Serialization/TeeTextWriter.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.Core/BufferedStream.cs b/src/MsgPack.Core/BufferedStream.cs new file mode 100644 index 000000000..50e773e4e --- /dev/null +++ b/src/MsgPack.Core/BufferedStream.cs @@ -0,0 +1,1294 @@ +// This file is based on https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/IO/BufferedStream.cs 814c2882a5c27ac40781bc20d6978708848784eb + +// ReSharper disable ArrangeThisQualifier +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PossibleNullReferenceException +// ReSharper disable RedundantUsingDirective + +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/*============================================================ +** +** +** +** +** Purpose: A composable Stream that buffers reads & writes to the underlying stream. +** +** +===========================================================*/ +using System; +using System.Runtime.InteropServices; +using System.Globalization; +#if XAMIOS || XAMDROID || CORE_CLR || NETSTANDARD1_1 +using Contract = MsgPack.MPContract; +#if CORE_CLR || NETSTANDARD1_1 +using PureAttribute = MsgPack.PureAttribute; +#endif // CORE_CLR +#else +using System.Diagnostics.Contracts; +#endif // XAMIOS || XAMDROID || CORE_CLR || NETSTANDARD1_1 +using System.Runtime.CompilerServices; +using System.Threading; +using System.Collections.ObjectModel; +using System.Security; +using System.Threading.Tasks; + +namespace System.IO +{ + + /// + /// One of the design goals here is to prevent the buffer from getting in the way and slowing + /// down underlying stream accesses when it is not needed. If you always read & write for sizes + /// greater than the internal buffer size, then this class may not even allocate the internal buffer. + /// See a large comment in Write for the details of the write buffer heuristic. + /// + /// This class buffers reads & writes in a shared buffer. + /// (If you maintained two buffers separately, one operation would always trash the other buffer + /// anyways, so we might as well use one buffer.) + /// The assumption here is you will almost always be doing a series of reads or writes, but rarely + /// alternate between the two of them on the same stream. + /// + /// Class Invariants: + /// The class has one buffer, shared for reading & writing. + /// It can only be used for one or the other at any point in time - not both. + /// The following should be true: + /// 0 implies the read buffer is valid, but we're at the end of the buffer. + /// * _readPos == _readLen == 0 means the read buffer contains garbage. + /// * Either _writePos can be greater than 0, or _readLen & _readPos can be greater than zero, + /// but neither can be greater than zero at the same time. + /// ]]> + /// This class will never cache more bytes than the max specified buffer size. + /// However, it may use a temporary buffer of up to twice the size in order to combine several IO operations on + /// the underlying stream into a single operation. This is because we assume that memory copies are significantly + /// faster than IO operations on the underlying stream (if this was not true, using buffering is never appropriate). + /// The max size of this "shadow" buffer is limited as to not allocate it on the LOH. + /// Shadowing is always transient. Even when using this technique, this class still guarantees that the number of + /// bytes cached (not yet written to the target stream or not yet consumed by the user) is never larger than the + /// actual specified buffer size. + /// + [ComVisible( true )] + internal sealed class BufferedStream : Stream + { + + + private const Int32 _DefaultBufferSize = 4096; + + + private Stream _stream; // Underlying stream. Close sets _stream to null. + + private Byte[] _buffer; // Shared read/write buffer. Alloc on first use. + + private readonly Int32 _bufferSize; // Length of internal buffer (not counting the shadow buffer). + + private Int32 _readPos; // Read pointer within shared buffer. + private Int32 _readLen; // Number of bytes read in buffer from _stream. + private Int32 _writePos; // Write pointer within shared buffer. + + private Task _lastSyncCompletedReadTask; // The last successful Task returned from ReadAsync + // (perf optimization for successive reads of the same size) + + + // ReSharper disable once UnusedMember.Local + // Removing a private default constructor is a breaking change for the DataContractSerializer. + // Because this ctor was here previously we need to keep it around. + private BufferedStream() { } + + + public BufferedStream( Stream stream ) + + : this( stream, _DefaultBufferSize ) + { + } + + + public BufferedStream( Stream stream, Int32 bufferSize ) + { + + if ( stream == null ) + throw new ArgumentNullException( "stream" ); + + if ( bufferSize <= 0 ) + throw new ArgumentOutOfRangeException( "bufferSize", "The value must be positive." ); + + Contract.EndContractBlock(); + + _stream = stream; + _bufferSize = bufferSize; + + // Allocate _buffer on its first use - it will not be used if all reads + // & writes are greater than or equal to buffer size. + + if ( !_stream.CanRead && !_stream.CanWrite ) + __Error.StreamIsClosed(); + } + + + private void EnsureNotClosed() + { + + if ( _stream == null ) + __Error.StreamIsClosed(); + } + + + private void EnsureCanSeek() + { + + Contract.Requires( _stream != null ); + + if ( !_stream.CanSeek ) + __Error.SeekNotSupported(); + } + + + private void EnsureCanRead() + { + + Contract.Requires( _stream != null ); + + if ( !_stream.CanRead ) + __Error.ReadNotSupported(); + } + + + private void EnsureCanWrite() + { + + Contract.Requires( _stream != null ); + + if ( !_stream.CanWrite ) + __Error.WriteNotSupported(); + } + + /// MaxShadowBufferSize is chosed such that shadow buffers are not allocated on the Large Object Heap. + /// Currently, an object is allocated on the LOH if it is larger than 85000 bytes. See LARGE_OBJECT_SIZE in ndp\clr\src\vm\gc.h + /// We will go with exactly 80 KBytes, although this is somewhat arbitrary. + private const Int32 MaxShadowBufferSize = 81920; // Make sure not to get to the Large Object Heap. + private void EnsureShadowBufferAllocated() + { + + Contract.Assert( _buffer != null ); + Contract.Assert( _bufferSize > 0 ); + + // Already have shadow buffer? + if ( _buffer.Length != _bufferSize || _bufferSize >= MaxShadowBufferSize ) + return; + + Byte[] shadowBuffer = new Byte[Math.Min(_bufferSize + _bufferSize, MaxShadowBufferSize)]; + Buffer.BlockCopy( _buffer, 0, shadowBuffer, 0, _writePos ); + _buffer = shadowBuffer; + } + + + private void EnsureBufferAllocated() + { + + Contract.Assert( _bufferSize > 0 ); + + // BufferedStream is not intended for multi-threaded use, so no worries about the get/set race conditions on _buffer. + if ( _buffer == null ) + _buffer = new Byte[ _bufferSize ]; + } + + + internal Stream UnderlyingStream + { + [Pure] + get + { return _stream; } + } + + + internal Int32 BufferSize + { + [Pure] + get + { return _bufferSize; } + } + + + public override bool CanRead + { + [Pure] + get + { return _stream != null && _stream.CanRead; } + } + + + public override bool CanWrite + { + [Pure] + get + { return _stream != null && _stream.CanWrite; } + } + + + public override bool CanSeek + { + [Pure] + get + { return _stream != null && _stream.CanSeek; } + } + + + public override Int64 Length + { + get + { + EnsureNotClosed(); + + if ( _writePos > 0 ) + FlushWrite(); + + return _stream.Length; + } + } + + + public override Int64 Position + { + get + { + EnsureNotClosed(); + EnsureCanSeek(); + + Contract.Assert( !( _writePos > 0 && _readPos != _readLen ), "Read and Write buffers cannot both have data in them at the same time." ); + return _stream.Position + ( _readPos - _readLen + _writePos ); + } + set + { + if ( value < 0 ) + throw new ArgumentOutOfRangeException( "value", "The value cannot be negative." ); + Contract.EndContractBlock(); + + EnsureNotClosed(); + EnsureCanSeek(); + + if ( _writePos > 0 ) + FlushWrite(); + + _readPos = 0; + _readLen = 0; + _stream.Seek( value, SeekOrigin.Begin ); + } + } + + + protected override void Dispose( bool disposing ) + { + + try + { + if ( disposing && _stream != null ) + { + try + { + Flush(); + } + finally + { + _stream.Dispose(); + } + } + } + finally + { + _stream = null; + _buffer = null; + _lastSyncCompletedReadTask = null; + + // Call base.Dispose(bool) to cleanup async IO resources + base.Dispose( disposing ); + } + } + + + public override void Flush() + { + + EnsureNotClosed(); + + // Has WRITE data in the buffer: + if ( _writePos > 0 ) + { + + FlushWrite(); + Contract.Assert( _writePos == 0 && _readPos == 0 && _readLen == 0 ); + return; + } + + // Has READ data in the buffer: + if ( _readPos < _readLen ) + { + + // If the underlying stream is not seekable AND we have something in the read buffer, then FlushRead would throw. + // We can either throw away the buffer resulting in data loss (!) or ignore the Flush. + // (We cannot throw becasue it would be a breaking change.) We opt into ignoring the Flush in that situation. + if ( !_stream.CanSeek ) + return; + + FlushRead(); + + // User streams may have opted to throw from Flush if CanWrite is false (although the abstract Stream does not do so). + // However, if we do not forward the Flush to the underlying stream, we may have problems when chaining several streams. + // Let us make a best effort attempt: + if ( _stream.CanWrite || _stream is BufferedStream ) + _stream.Flush(); + + Contract.Assert( _writePos == 0 && _readPos == 0 && _readLen == 0 ); + return; + } + + // We had no data in the buffer, but we still need to tell the underlying stream to flush. + if ( _stream.CanWrite || _stream is BufferedStream ) + _stream.Flush(); + + _writePos = _readPos = _readLen = 0; + } + + public override Task FlushAsync( CancellationToken cancellationToken ) + { + + if ( cancellationToken.IsCancellationRequested ) + return _Task.FromCancellation( cancellationToken ); + + EnsureNotClosed(); + + return FlushAsyncInternal( cancellationToken, this, _stream, _writePos, _readPos, _readLen ); + } + + + private static async Task FlushAsyncInternal( CancellationToken cancellationToken, + BufferedStream _this, Stream stream, Int32 writePos, Int32 readPos, Int32 readLen ) + { + + // We bring instance fields down as local parameters to this async method becasue BufferedStream is derived from MarshalByRefObject. + // Field access would be from the async state machine i.e., not via the this pointer and would require runtime checking to see + // if we are talking to a remote object, which is currently very slow + + Contract.Assert( stream != null ); + + SemaphoreSlim sem = _this.EnsureAsyncActiveSemaphoreInitialized(); + await sem.WaitAsync().ConfigureAwait( false ); + try + { + + if ( writePos > 0 ) + { + + await _this.FlushWriteAsync( cancellationToken ).ConfigureAwait( false ); + Contract.Assert( _this._writePos == 0 && _this._readPos == 0 && _this._readLen == 0 ); + return; + } + + if ( readPos < readLen ) + { + + // If the underlying stream is not seekable AND we have something in the read buffer, then FlushRead would throw. + // We can either throw away the buffer resulting in date loss (!) or ignore the Flush. (We cannot throw becasue it + // would be a breaking change.) We opt into ignoring the Flush in that situation. + if ( !stream.CanSeek ) + return; + + _this.FlushRead(); // not async; it uses Seek, but there's no SeekAsync + + // User streams may have opted to throw from Flush if CanWrite is false (although the abstract Stream does not do so). + // However, if we do not forward the Flush to the underlying stream, we may have problems when chaining several streams. + // Let us make a best effort attempt: + if ( stream.CanRead || stream is BufferedStream ) + await stream.FlushAsync( cancellationToken ).ConfigureAwait( false ); + + Contract.Assert( _this._writePos == 0 && _this._readPos == 0 && _this._readLen == 0 ); + return; + } + + // We had no data in the buffer, but we still need to tell the underlying stream to flush. + if ( stream.CanWrite || stream is BufferedStream ) + await stream.FlushAsync( cancellationToken ).ConfigureAwait( false ); + + // There was nothing in the buffer: + Contract.Assert( _this._writePos == 0 && _this._readPos == _this._readLen ); + + } + finally + { + sem.Release(); + } + } + + + // Reading is done in blocks, but someone could read 1 byte from the buffer then write. + // At that point, the underlying stream's pointer is out of sync with this stream's position. + // All write functions should call this function to ensure that the buffered data is not lost. + private void FlushRead() + { + + Contract.Assert( _writePos == 0, "BufferedStream: Write buffer must be empty in FlushRead!" ); + + if ( _readPos - _readLen != 0 ) + _stream.Seek( _readPos - _readLen, SeekOrigin.Current ); + + _readPos = 0; + _readLen = 0; + } + + + private void ClearReadBufferBeforeWrite() + { + + // This is called by write methods to clear the read buffer. + + Contract.Assert( _readPos <= _readLen, "_readPos <= _readLen [" + _readPos + " <= " + _readLen + "]" ); + + // No READ data in the buffer: + if ( _readPos == _readLen ) + { + + _readPos = _readLen = 0; + return; + } + + // Must have READ data. + Contract.Assert( _readPos < _readLen ); + + // If the underlying stream cannot seek, FlushRead would end up throwing NotSupported. + // However, since the user did not call a method that is intuitively expected to seek, a better message is in order. + // Ideally, we would throw an InvalidOperation here, but for backward compat we have to stick with NotSupported. + if ( !_stream.CanSeek ) + throw new NotSupportedException( "Cannot write stream because read buffer cannot be flushed." ); + + FlushRead(); + } + + + private void FlushWrite() + { + + Contract.Assert( _readPos == 0 && _readLen == 0, + "BufferedStream: Read buffer must be empty in FlushWrite!" ); + Contract.Assert( _buffer != null && _bufferSize >= _writePos, + "BufferedStream: Write buffer must be allocated and write position must be in the bounds of the buffer in FlushWrite!" ); + + _stream.Write( _buffer, 0, _writePos ); + _writePos = 0; + _stream.Flush(); + } + + + private async Task FlushWriteAsync( CancellationToken cancellationToken ) + { + + Contract.Assert( _readPos == 0 && _readLen == 0, + "BufferedStream: Read buffer must be empty in FlushWrite!" ); + Contract.Assert( _buffer != null && _bufferSize >= _writePos, + "BufferedStream: Write buffer must be allocated and write position must be in the bounds of the buffer in FlushWrite!" ); + + await _stream.WriteAsync( _buffer, 0, _writePos, cancellationToken ).ConfigureAwait( false ); + _writePos = 0; + await _stream.FlushAsync( cancellationToken ).ConfigureAwait( false ); + } + + + private Int32 ReadFromBuffer( Byte[] array, Int32 offset, Int32 count ) + { + + Int32 readBytes = _readLen - _readPos; + Contract.Assert( readBytes >= 0 ); + + if ( readBytes == 0 ) + return 0; + + Contract.Assert( readBytes > 0 ); + + if ( readBytes > count ) + readBytes = count; + + Buffer.BlockCopy( _buffer, _readPos, array, offset, readBytes ); + _readPos += readBytes; + + return readBytes; + } + + + private Int32 ReadFromBuffer( Byte[] array, Int32 offset, Int32 count, out Exception error ) + { + + try + { + + error = null; + return ReadFromBuffer( array, offset, count ); + + } + catch ( Exception ex ) + { + error = ex; + return 0; + } + } + + + public override int Read( [In, Out] Byte[] array, Int32 offset, Int32 count ) + { + + if ( array == null ) + throw new ArgumentNullException( "array" ); + if ( offset < 0 ) + throw new ArgumentOutOfRangeException( "offset", "The value cannot be negative." ); + if ( count < 0 ) + throw new ArgumentOutOfRangeException( "count", "The value cannot be negative." ); + if ( array.Length - offset < count ) + throw new ArgumentException( "The offset is too big for length." ); + Contract.EndContractBlock(); + + EnsureNotClosed(); + EnsureCanRead(); + + Int32 bytesFromBuffer = ReadFromBuffer(array, offset, count); + + // We may have read less than the number of bytes the user asked for, but that is part of the Stream contract. + + // Reading again for more data may cause us to block if we're using a device with no clear end of file, + // such as a serial port or pipe. If we blocked here and this code was used with redirected pipes for a + // process's standard output, this can lead to deadlocks involving two processes. + // BUT - this is a breaking change. + // So: If we could not read all bytes the user asked for from the buffer, we will try once from the underlying + // stream thus ensuring the same blocking behaviour as if the underlying stream was not wrapped in this BufferedStream. + if ( bytesFromBuffer == count ) + return bytesFromBuffer; + + Int32 alreadySatisfied = bytesFromBuffer; + if ( bytesFromBuffer > 0 ) + { + count -= bytesFromBuffer; + offset += bytesFromBuffer; + } + + // So the READ buffer is empty. + Contract.Assert( _readLen == _readPos ); + _readPos = _readLen = 0; + + // If there was anything in the WRITE buffer, clear it. + if ( _writePos > 0 ) + FlushWrite(); + + // If the requested read is larger than buffer size, avoid the buffer and still use a single read: + if ( count >= _bufferSize ) + { + + return _stream.Read( array, offset, count ) + alreadySatisfied; + } + + // Ok. We can fill the buffer: + EnsureBufferAllocated(); + _readLen = _stream.Read( _buffer, 0, _bufferSize ); + + bytesFromBuffer = ReadFromBuffer( array, offset, count ); + + // We may have read less than the number of bytes the user asked for, but that is part of the Stream contract. + // Reading again for more data may cause us to block if we're using a device with no clear end of stream, + // such as a serial port or pipe. If we blocked here & this code was used with redirected pipes for a process's + // standard output, this can lead to deadlocks involving two processes. Additionally, translating one read on the + // BufferedStream to more than one read on the underlying Stream may defeat the whole purpose of buffering of the + // underlying reads are significantly more expensive. + + return bytesFromBuffer + alreadySatisfied; + } + + private Task LastSyncCompletedReadTask( Int32 val ) + { + + Task t = _lastSyncCompletedReadTask; + Contract.Assert( t == null || t.Status == TaskStatus.RanToCompletion ); + + if ( t != null && t.Result == val ) + return t; + + // ReSharper disable once RedundantTypeArgumentsOfMethod + t = Task.FromResult( val ); + _lastSyncCompletedReadTask = t; + return t; + } + + + public override Task ReadAsync( Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken ) + { + + if ( buffer == null ) + throw new ArgumentNullException( "buffer" ); + if ( offset < 0 ) + throw new ArgumentOutOfRangeException( "offset", "The value cannot be negative." ); + if ( count < 0 ) + throw new ArgumentOutOfRangeException( "count", "The value cannot be negative." ); + if ( buffer.Length - offset < count ) + throw new ArgumentException( "The offset is too big for length." ); + Contract.EndContractBlock(); + + // Fast path check for cancellation already requested + if ( cancellationToken.IsCancellationRequested ) + return _Task.FromCancellation( cancellationToken ); + + EnsureNotClosed(); + EnsureCanRead(); + + Int32 bytesFromBuffer = 0; + // Try to satisfy the request from the buffer synchronously. But still need a sem-lock in case that another + // Async IO Task accesses the buffer concurrently. If we fail to acquire the lock without waiting, make this + // an Async operation. + SemaphoreSlim sem = this.EnsureAsyncActiveSemaphoreInitialized(); + Task semaphoreLockTask = sem.WaitAsync(); + if ( semaphoreLockTask.Status == TaskStatus.RanToCompletion ) + { + + bool completeSynchronously = true; + try + { + Exception error; + bytesFromBuffer = ReadFromBuffer( buffer, offset, count, out error ); + + // If we satistied enough data from the buffer, we can complete synchronously. + // Reading again for more data may cause us to block if we're using a device with no clear end of file, + // such as a serial port or pipe. If we blocked here and this code was used with redirected pipes for a + // process's standard output, this can lead to deadlocks involving two processes. + // BUT - this is a breaking change. + // So: If we could not read all bytes the user asked for from the buffer, we will try once from the underlying + // stream thus ensuring the same blocking behaviour as if the underlying stream was not wrapped in this BufferedStream. + completeSynchronously = ( bytesFromBuffer == count || error != null ); + + if ( completeSynchronously ) + { + + return ( error == null ) + ? LastSyncCompletedReadTask( bytesFromBuffer ) + : _Task.FromException( error ); + } + } + finally + { + if ( completeSynchronously ) // if this is FALSE, we will be entering ReadFromUnderlyingStreamAsync and releasing there. + sem.Release(); + } + } + + // Delegate to the async implementation. + return ReadFromUnderlyingStreamAsync( buffer, offset + bytesFromBuffer, count - bytesFromBuffer, cancellationToken, + bytesFromBuffer, semaphoreLockTask ); + } + + + /// BufferedStream should be as thin a wrapper as possible. We want that ReadAsync delegates to + /// ReadAsync of the underlying _stream and that BeginRead delegates to BeginRead of the underlying stream, + /// rather than calling the base Stream which implements the one in terms of the other. This allows BufferedStream + /// to affect the semantics of the stream it wraps as little as possible. At the same time, we want to share as + /// much code between the APM and the Async pattern implementations as possible. This method is called by both with + /// a corresponding useApmPattern value. Recall that Task implements IAsyncResult. + /// -2 if _bufferSize was set to 0 while waiting on the semaphore; otherwise num of bytes read. + private async Task ReadFromUnderlyingStreamAsync( Byte[] array, Int32 offset, Int32 count, + CancellationToken cancellationToken, + Int32 bytesAlreadySatisfied, + Task semaphoreLockTask ) + { + + // Same conditions validated with exceptions in ReadAsync: + // (These should be Contract.Requires(..) but that method had some issues in async methods; using Assert(..) for now.) + Contract.Assert( array != null ); + Contract.Assert( offset >= 0 ); + Contract.Assert( count >= 0 ); + Contract.Assert( array.Length - offset >= count ); + Contract.Assert( _stream != null ); + Contract.Assert( _stream.CanRead ); + Contract.Assert( _bufferSize > 0 ); + Contract.Assert( semaphoreLockTask != null ); + + // Employ async waiting based on the same synchronization used in BeginRead of the abstract Stream. + await semaphoreLockTask.ConfigureAwait( false ); + try + { + + // The buffer might have been changed by another async task while we were waiting on the semaphore. + // Check it now again. + Int32 bytesFromBuffer = ReadFromBuffer(array, offset, count); + if ( bytesFromBuffer == count ) + return bytesAlreadySatisfied + bytesFromBuffer; + + if ( bytesFromBuffer > 0 ) + { + count -= bytesFromBuffer; + offset += bytesFromBuffer; + bytesAlreadySatisfied += bytesFromBuffer; + } + + Contract.Assert( _readLen == _readPos ); + _readPos = _readLen = 0; + + // If there was anything in the WRITE buffer, clear it. + if ( _writePos > 0 ) + await FlushWriteAsync( cancellationToken ).ConfigureAwait( false ); // no Begin-End read version for Flush. Use Async. + + // If the requested read is larger than buffer size, avoid the buffer and still use a single read: + if ( count >= _bufferSize ) + { + return bytesAlreadySatisfied + await _stream.ReadAsync( array, offset, count, cancellationToken ).ConfigureAwait( false ); + } + + // Ok. We can fill the buffer: + EnsureBufferAllocated(); + _readLen = await _stream.ReadAsync( _buffer, 0, _bufferSize, cancellationToken ).ConfigureAwait( false ); + + bytesFromBuffer = ReadFromBuffer( array, offset, count ); + return bytesAlreadySatisfied + bytesFromBuffer; + + } + finally + { + SemaphoreSlim sem = this.EnsureAsyncActiveSemaphoreInitialized(); + sem.Release(); + } + } + + + public override Int32 ReadByte() + { + + EnsureNotClosed(); + EnsureCanRead(); + + if ( _readPos == _readLen ) + { + + if ( _writePos > 0 ) + FlushWrite(); + + EnsureBufferAllocated(); + _readLen = _stream.Read( _buffer, 0, _bufferSize ); + _readPos = 0; + } + + if ( _readPos == _readLen ) + return -1; + + Int32 b = _buffer[_readPos++]; + return b; + } + + + private void WriteToBuffer( Byte[] array, ref Int32 offset, ref Int32 count ) + { + + Int32 bytesToWrite = Math.Min(_bufferSize - _writePos, count); + + if ( bytesToWrite <= 0 ) + return; + + EnsureBufferAllocated(); + Buffer.BlockCopy( array, offset, _buffer, _writePos, bytesToWrite ); + + _writePos += bytesToWrite; + count -= bytesToWrite; + offset += bytesToWrite; + } + + + private void WriteToBuffer( Byte[] array, ref Int32 offset, ref Int32 count, out Exception error ) + { + + try + { + + error = null; + WriteToBuffer( array, ref offset, ref count ); + + } + catch ( Exception ex ) + { + error = ex; + } + } + + + public override void Write( Byte[] array, Int32 offset, Int32 count ) + { + + if ( array == null ) + throw new ArgumentNullException( "array" ); + if ( offset < 0 ) + throw new ArgumentOutOfRangeException( "offset", "The value cannot be negative." ); + if ( count < 0 ) + throw new ArgumentOutOfRangeException( "count", "The value cannot be negative." ); + if ( array.Length - offset < count ) + throw new ArgumentException( "The offset is too big for length." ); + Contract.EndContractBlock(); + + EnsureNotClosed(); + EnsureCanWrite(); + + if ( _writePos == 0 ) + ClearReadBufferBeforeWrite(); + + #region Write algorithm comment + // We need to use the buffer, while avoiding unnecessary buffer usage / memory copies. + // We ASSUME that memory copies are much cheaper than writes to the underlying stream, so if an extra copy is + // guaranteed to reduce the number of writes, we prefer it. + // We pick a simple strategy that makes degenerate cases rare if our assumptions are right. + // + // For every write, we use a simple heuristic (below) to decide whether to use the buffer. + // The heuristic has the desirable property (*) that if the specified user data can fit into the currently available + // buffer space without filling it up completely, the heuristic will always tell us to use the buffer. It will also + // tell us to use the buffer in cases where the current write would fill the buffer, but the remaining data is small + // enough such that subsequent operations can use the buffer again. + // + // Algorithm: + // Determine whether or not to buffer according to the heuristic (below). + // If we decided to use the buffer: + // Copy as much user data as we can into the buffer. + // If we consumed all data: We are finished. + // Otherwise, write the buffer out. + // Copy the rest of user data into the now cleared buffer (no need to write out the buffer again as the heuristic + // will prevent it from being filled twice). + // If we decided not to use the buffer: + // Can the data already in the buffer and current user data be combines to a single write + // by allocating a "shadow" buffer of up to twice the size of _bufferSize (up to a limit to avoid LOH)? + // Yes, it can: + // Allocate a larger "shadow" buffer and ensure the buffered data is moved there. + // Copy user data to the shadow buffer. + // Write shadow buffer to the underlying stream in a single operation. + // No, it cannot (amount of data is still too large): + // Write out any data possibly in the buffer. + // Write out user data directly. + // + // Heuristic: + // If the subsequent write operation that follows the current write operation will result in a write to the + // underlying stream in case that we use the buffer in the current write, while it would not have if we avoided + // using the buffer in the current write (by writing current user data to the underlying stream directly), then we + // prefer to avoid using the buffer since the corresponding memory copy is wasted (it will not reduce the number + // of writes to the underlying stream, which is what we are optimising for). + // ASSUME that the next write will be for the same amount of bytes as the current write (most common case) and + // determine if it will cause a write to the underlying stream. If the next write is actually larger, our heuristic + // still yields the right behaviour, if the next write is actually smaller, we may making an unnecessary write to + // the underlying stream. However, this can only occur if the current write is larger than half the buffer size and + // we will recover after one iteration. + // We have: + // useBuffer = (_writePos + count + count < _bufferSize + _bufferSize) + // + // Example with _bufferSize = 20, _writePos = 6, count = 10: + // + // +---------------------------------------+---------------------------------------+ + // | current buffer | next iteration's "future" buffer | + // +---------------------------------------+---------------------------------------+ + // |0| | | | | | | | | |1| | | | | | | | | |2| | | | | | | | | |3| | | | | | | | | | + // |0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9| + // +-----------+-------------------+-------------------+---------------------------+ + // | _writePos | current count | assumed next count|avail buff after next write| + // +-----------+-------------------+-------------------+---------------------------+ + // + // A nice property (*) of this heuristic is that it will always succeed if the user data completely fits into the + // available buffer, i.e. if count < (_bufferSize - _writePos). + #endregion Write algorithm comment + + Contract.Assert( _writePos < _bufferSize ); + + Int32 totalUserBytes; + bool useBuffer; + checked + { // We do not expect buffer sizes big enough for an overflow, but if it happens, lets fail early: + totalUserBytes = _writePos + count; + useBuffer = ( totalUserBytes + count < ( _bufferSize + _bufferSize ) ); + } + + if ( useBuffer ) + { + + WriteToBuffer( array, ref offset, ref count ); + + if ( _writePos < _bufferSize ) + { + + Contract.Assert( count == 0 ); + return; + } + + Contract.Assert( count >= 0 ); + Contract.Assert( _writePos == _bufferSize ); + Contract.Assert( _buffer != null ); + + _stream.Write( _buffer, 0, _writePos ); + _writePos = 0; + + WriteToBuffer( array, ref offset, ref count ); + + Contract.Assert( count == 0 ); + Contract.Assert( _writePos < _bufferSize ); + + } + else + { // if (!useBuffer) + + // Write out the buffer if necessary. + if ( _writePos > 0 ) + { + + Contract.Assert( _buffer != null ); + Contract.Assert( totalUserBytes >= _bufferSize ); + + // Try avoiding extra write to underlying stream by combining previously buffered data with current user data: + if ( totalUserBytes <= ( _bufferSize + _bufferSize ) && totalUserBytes <= MaxShadowBufferSize ) + { + + EnsureShadowBufferAllocated(); + Buffer.BlockCopy( array, offset, _buffer, _writePos, count ); + _stream.Write( _buffer, 0, totalUserBytes ); + _writePos = 0; + return; + } + + _stream.Write( _buffer, 0, _writePos ); + _writePos = 0; + } + + // Write out user data. + _stream.Write( array, offset, count ); + } + } + + public override Task WriteAsync( Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken ) + { + + if ( buffer == null ) + throw new ArgumentNullException( "buffer" ); + if ( offset < 0 ) + throw new ArgumentOutOfRangeException( "offset", "The value cannot be negative." ); + if ( count < 0 ) + throw new ArgumentOutOfRangeException( "count", "The value cannot be negative." ); + if ( buffer.Length - offset < count ) + throw new ArgumentException( "The offset is too big for length." ); + Contract.EndContractBlock(); + + // Fast path check for cancellation already requested + if ( cancellationToken.IsCancellationRequested ) + return _Task.FromCancellation( cancellationToken ); + + EnsureNotClosed(); + EnsureCanWrite(); + + // Try to satisfy the request from the buffer synchronously. But still need a sem-lock in case that another + // Async IO Task accesses the buffer concurrently. If we fail to acquire the lock without waiting, make this + // an Async operation. + SemaphoreSlim sem = this.EnsureAsyncActiveSemaphoreInitialized(); + Task semaphoreLockTask = sem.WaitAsync(); + if ( semaphoreLockTask.Status == TaskStatus.RanToCompletion ) + { + + bool completeSynchronously = true; + try + { + + if ( _writePos == 0 ) + ClearReadBufferBeforeWrite(); + + Contract.Assert( _writePos < _bufferSize ); + + // If the write completely fits into the buffer, we can complete synchronously: + completeSynchronously = ( count < _bufferSize - _writePos ); + + if ( completeSynchronously ) + { + + Exception error; + WriteToBuffer( buffer, ref offset, ref count, out error ); + Contract.Assert( count == 0 ); + + return ( error == null ) + ? _Task.CompletedTask + : _Task.FromException( error ); + } + } + finally + { + if ( completeSynchronously ) // if this is FALSE, we will be entering WriteToUnderlyingStreamAsync and releasing there. + sem.Release(); + } + } + + // Delegate to the async implementation. + return WriteToUnderlyingStreamAsync( buffer, offset, count, cancellationToken, semaphoreLockTask ); + } + + + /// BufferedStream should be as thin a wrapper as possible. We want that WriteAsync delegates to + /// WriteAsync of the underlying _stream and that BeginWrite delegates to BeginWrite of the underlying stream, + /// rather than calling the base Stream which implements the one in terms of the other. This allows BufferedStream + /// to affect the semantics of the stream it wraps as little as possible. At the same time, we want to share as + /// much code between the APM and the Async pattern implementations as possible. This method is called by both with + /// a corresponding useApmPattern value. Recall that Task implements IAsyncResult. + private async Task WriteToUnderlyingStreamAsync( Byte[] array, Int32 offset, Int32 count, + CancellationToken cancellationToken, + Task semaphoreLockTask ) + { + + // (These should be Contract.Requires(..) but that method had some issues in async methods; using Assert(..) for now.) + Contract.Assert( array != null ); + Contract.Assert( offset >= 0 ); + Contract.Assert( count >= 0 ); + Contract.Assert( array.Length - offset >= count ); + Contract.Assert( _stream != null ); + Contract.Assert( _stream.CanWrite ); + Contract.Assert( _bufferSize > 0 ); + Contract.Assert( semaphoreLockTask != null ); + + // See the LARGE COMMENT in Write(..) for the explanation of the write buffer algorithm. + + await semaphoreLockTask.ConfigureAwait( false ); + try + { + + // The buffer might have been changed by another async task while we were waiting on the semaphore. + // However, note that if we recalculate the sync completion condition to TRUE, then useBuffer will also be TRUE. + + if ( _writePos == 0 ) + ClearReadBufferBeforeWrite(); + + Int32 totalUserBytes; + bool useBuffer; + checked + { // We do not expect buffer sizes big enough for an overflow, but if it happens, lets fail early: + totalUserBytes = _writePos + count; + useBuffer = ( totalUserBytes + count < ( _bufferSize + _bufferSize ) ); + } + + if ( useBuffer ) + { + + WriteToBuffer( array, ref offset, ref count ); + + if ( _writePos < _bufferSize ) + { + + Contract.Assert( count == 0 ); + return; + } + + Contract.Assert( count >= 0 ); + Contract.Assert( _writePos == _bufferSize ); + Contract.Assert( _buffer != null ); + + await _stream.WriteAsync( _buffer, 0, _writePos, cancellationToken ).ConfigureAwait( false ); + _writePos = 0; + + WriteToBuffer( array, ref offset, ref count ); + + Contract.Assert( count == 0 ); + Contract.Assert( _writePos < _bufferSize ); + + } + else + { // if (!useBuffer) + + // Write out the buffer if necessary. + if ( _writePos > 0 ) + { + + Contract.Assert( _buffer != null ); + Contract.Assert( totalUserBytes >= _bufferSize ); + + // Try avoiding extra write to underlying stream by combining previously buffered data with current user data: + if ( totalUserBytes <= ( _bufferSize + _bufferSize ) && totalUserBytes <= MaxShadowBufferSize ) + { + + EnsureShadowBufferAllocated(); + Buffer.BlockCopy( array, offset, _buffer, _writePos, count ); + await _stream.WriteAsync( _buffer, 0, totalUserBytes, cancellationToken ).ConfigureAwait( false ); + _writePos = 0; + return; + } + + await _stream.WriteAsync( _buffer, 0, _writePos, cancellationToken ).ConfigureAwait( false ); + _writePos = 0; + } + + // Write out user data. + await _stream.WriteAsync( array, offset, count, cancellationToken ).ConfigureAwait( false ); + } + } + finally + { + SemaphoreSlim sem = this.EnsureAsyncActiveSemaphoreInitialized(); + sem.Release(); + } + } + + + public override void WriteByte( Byte value ) + { + + EnsureNotClosed(); + + if ( _writePos == 0 ) + { + + EnsureCanWrite(); + ClearReadBufferBeforeWrite(); + EnsureBufferAllocated(); + } + + // We should not be flushing here, but only writing to the underlying stream, but previous version flushed, so we keep this. + if ( _writePos >= _bufferSize - 1 ) + FlushWrite(); + + _buffer[ _writePos++ ] = value; + + Contract.Assert( _writePos < _bufferSize ); + } + + + public override Int64 Seek( Int64 offset, SeekOrigin origin ) + { + + EnsureNotClosed(); + EnsureCanSeek(); + + // If we have bytes in the WRITE buffer, flush them out, seek and be done. + if ( _writePos > 0 ) + { + + // We should be only writing the buffer and not flushing, + // but the previous version did flush and we stick to it for back-compat reasons. + FlushWrite(); + return _stream.Seek( offset, origin ); + } + + // The buffer is either empty or we have a buffered READ. + + if ( _readLen - _readPos > 0 && origin == SeekOrigin.Current ) + { + + // If we have bytes in the READ buffer, adjust the seek offset to account for the resulting difference + // between this stream's position and the underlying stream's position. + offset -= ( _readLen - _readPos ); + } + + Int64 oldPos = Position; + Contract.Assert( oldPos == _stream.Position + ( _readPos - _readLen ) ); + + Int64 newPos = _stream.Seek(offset, origin); + + // If the seek destination is still within the data currently in the buffer, we want to keep the buffer data and continue using it. + // Otherwise we will throw away the buffer. This can only happen on READ, as we flushed WRITE data above. + + // The offset of the new/updated seek pointer within _buffer: + _readPos = ( Int32 )( newPos - ( oldPos - _readPos ) ); + + // If the offset of the updated seek pointer in the buffer is still legal, then we can keep using the buffer: + if ( 0 <= _readPos && _readPos < _readLen ) + { + + // Adjust the seek pointer of the underlying stream to reflect the amount of useful bytes in the read buffer: + _stream.Seek( _readLen - _readPos, SeekOrigin.Current ); + + } + else + { // The offset of the updated seek pointer is not a legal offset. Loose the buffer. + + _readPos = _readLen = 0; + } + + Contract.Assert( newPos == Position, "newPos (=" + newPos + ") == Position (=" + Position + ")" ); + return newPos; + } + + + public override void SetLength( Int64 value ) + { + + if ( value < 0 ) + throw new ArgumentOutOfRangeException( "value", "The size cannot be negative." ); + Contract.EndContractBlock(); + + EnsureNotClosed(); + EnsureCanSeek(); + EnsureCanWrite(); + + Flush(); + _stream.SetLength( value ); + } + + // From https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/IO/Stream.cs ef1e2ab328087c61a6878c1e84f4fc5d710aebce + + // To implement Async IO operations on streams that don't support async IO + + private SemaphoreSlim _asyncActiveSemaphore; + + internal SemaphoreSlim EnsureAsyncActiveSemaphoreInitialized() + { + // Lazily-initialize _asyncActiveSemaphore. As we're never accessing the SemaphoreSlim's + // WaitHandle, we don't need to worry about Disposing it. + return LazyInitializer.EnsureInitialized( ref _asyncActiveSemaphore, () => new SemaphoreSlim( 1, 1 ) ); + } + + // End From Stream.cs + + // From https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/IO/__Error.cs ef1e2ab328087c61a6878c1e84f4fc5d710aebce + private static class __Error + { + internal static void StreamIsClosed() + { + throw new ObjectDisposedException( null, "This stream is already closed." ); + } + + internal static void ReadNotSupported() + { + throw new NotSupportedException( "Cannot read on the current stream." ); + } + internal static void WriteNotSupported() + { + throw new NotSupportedException( "Cannot write on the current stream." ); + } + + internal static void SeekNotSupported() + { + throw new NotSupportedException( "Cannot seek on the current stream." ); + } + } + + // From + private static class _Task + { + /// Gets a task that's already been completed successfully. + /// May not always return the same instance. + public static Task CompletedTask + { + get + { + var tcs = new TaskCompletionSource(); + tcs.SetResult( null ); + return tcs.Task; + } + } + + // ReSharper disable once UnusedParameter.Local + public static Task FromCancellation(CancellationToken cancellationToken) + { + var tcs = new TaskCompletionSource(); + tcs.SetCanceled(); + return tcs.Task; + } + + public static Task FromException(Exception ex) + { + return FromException( ex ); + } + + public static Task FromException( Exception ex ) + { + var tcs = new TaskCompletionSource(); + tcs.SetException( ex ); + return tcs.Task; + } + } + + } // class BufferedStream +} // namespace diff --git a/src/MsgPack.Core/MPContract.cs b/src/MsgPack.Core/MPContract.cs new file mode 100644 index 000000000..bffdff1b7 --- /dev/null +++ b/src/MsgPack.Core/MPContract.cs @@ -0,0 +1,72 @@ +#region -- License Terms -- +// MessagePack for CLI +// +// Copyright (C) 2015 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +using System; +using System.Diagnostics; + +namespace MsgPack +{ + /// + /// System.Contract alternative working on Xamarin. + /// + internal static class MPContract + { + [Conditional( "DEBUG" )] + public static void Assert( bool condition ) + { + if ( !condition ) + { + throw new Exception( "Assertion error." ); + } + } + + [Conditional( "DEBUG" )] + public static void Assert( bool condition, string userMessage ) + { + if ( !condition ) + { + throw new Exception( "Assertion error: " + userMessage ); + } + } + + [Conditional("__NEVER")] + public static void EndContractBlock() + { + // nop + } + + [Conditional( "__NEVER" )] + public static void Requires( bool expression ) + { + // nop + } + + [Conditional( "__NEVER" )] + public static void Ensures( bool expression ) + { + // nop + } + + public static T Result() + { + return default( T ); + } + } + + internal sealed class PureAttribute : Attribute { } +} \ No newline at end of file diff --git a/src/MsgPack.Core/MsgPack.Core.csproj b/src/MsgPack.Core/MsgPack.Core.csproj new file mode 100644 index 000000000..476417a80 --- /dev/null +++ b/src/MsgPack.Core/MsgPack.Core.csproj @@ -0,0 +1,272 @@ + + + + + 14.0 + Debug + AnyCPU + {08D9A49D-736E-4CAD-919E-72CA8C1D4A9F} + Library + Properties + MsgPack + MsgPack.Core + ja-JP + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + v5.0 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;FEATURE_TAP;NETSTANDARD1_1 + prompt + 4 + bin\Debug\MsgPack.Core.XML + + + pdbonly + true + bin\Release\ + TRACE;FEATURE_TAP;NETSTANDARD1_1 + prompt + 4 + bin\Release\MsgPack.Core.XML + + + true + + + ..\MsgPack.snk + + + + + MsgPack.snk + + + + + + Properties\CommonAssemblyInfo.cs + + + AsyncReadResult.cs + + + AsyncReadResult`1.cs + + + BigEndianBinary.cs + + + Binary.cs + + + BufferManager.cs + + + CollectionDebuggerProxy`1.cs + + + CollectionOperation.cs + + + DictionaryDebuggerProxy`2.cs + + + Float32Bits.cs + + + Float64Bits.cs + + + GlobalSuppressions.cs + + + IAsyncPackable.cs + + + IAsyncUnpackable.cs + + + InvalidMessagePackStreamException.cs + + + IPackable.cs + + + ItemsUnpacker.cs + + + ItemsUnpacker.Read.cs + + + ItemsUnpacker.Skipping.cs + + + ItemsUnpacker.Unpacking.cs + + + IUnpackable.cs + + + KnownExtTypeCode.cs + + + KnownExtTypeName.cs + + + MessageNotSupportedException.cs + + + MessagePackCode.cs + + + MessagePackConvert.cs + + + MessagePackExtendedTypeObject.cs + + + MessagePackObject.cs + + + MessagePackObject.Utilities.cs + + + MessagePackObjectDictionary.cs + + + MessagePackObjectDictionary.Enumerator.cs + + + MessagePackObjectDictionary.KeySet.cs + + + MessagePackObjectDictionary.KeySet.Enumerator.cs + + + MessagePackObjectDictionary.ValueCollection.cs + + + MessagePackObjectDictionary.ValueCollection.Enumerator.cs + + + MessagePackObjectEqualityComparer.cs + + + MessagePackString.cs + + + MessageTypeException.cs + + + Packer.cs + + + Packer.Nullable.cs + + + Packer.Packing.cs + + + PackerCompatibilityOptions.cs + + + PackerUnpackerStreamOptions.cs + + + PackingOptions.cs + + + PreserveAttribute.cs + + + ReflectionAbstractions.cs + + + SetOperation.cs + + + StreamPacker.cs + + + StringEscape.cs + + + SubtreeUnpacker.cs + + + SubtreeUnpacker.Unpacking.cs + + + TupleItems.cs + + + UnassignedMessageTypeException.cs + + + Unpacker.cs + + + Unpacker.Unpacking.cs + + + UnpackException.cs + + + Unpacking.cs + + + Unpacking.Numerics.cs + + + Unpacking.Others.cs + + + Unpacking.Streaming.cs + + + Unpacking.String.cs + + + UnpackingMode.cs + + + UnpackingResult.cs + + + UnpackingStream.cs + + + UnpackingStreamReader.cs + + + UnsafeNativeMethods.cs + + + Validation.cs + + + + + + + + + remarks.xml + + + + + \ No newline at end of file diff --git a/src/MsgPack.Core/NetStandardCompatibility.cs b/src/MsgPack.Core/NetStandardCompatibility.cs new file mode 100644 index 000000000..48c752f16 --- /dev/null +++ b/src/MsgPack.Core/NetStandardCompatibility.cs @@ -0,0 +1,88 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2010-2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; +using System.Collections.Generic; + +namespace MsgPack +{ + // ReSharper disable once InconsistentNaming + internal static class NetStandardCompatibility + { + private static readonly Dictionary _typeCodeTable = + new Dictionary() + { + { typeof( Boolean ), TypeCode.Boolean }, + { typeof( Char ), TypeCode.Char }, + { typeof( Byte ), TypeCode.Byte }, + { typeof( Int16 ), TypeCode.Int16 }, + { typeof( Int32 ), TypeCode.Int32 }, + { typeof( Int64 ), TypeCode.Int64 }, + { typeof( SByte ), TypeCode.SByte }, + { typeof( UInt16 ), TypeCode.UInt16 }, + { typeof( UInt32 ), TypeCode.UInt32 }, + { typeof( UInt64 ), TypeCode.UInt64 }, + { typeof( Single ), TypeCode.Single }, + { typeof( Double ), TypeCode.Double }, + { typeof( DateTime ), TypeCode.DateTime }, + { typeof( Decimal ), TypeCode.Decimal }, + { typeof( String ), TypeCode.String }, + }; + + public static TypeCode GetTypeCode( Type type ) + { + if ( type == null ) + { + return TypeCode.Empty; + } + + TypeCode result; + if ( !_typeCodeTable.TryGetValue( type, out result ) ) + { + result = TypeCode.Object; + } + + return result; + } + } + + internal enum TypeCode + { + Byte, + Int16, + Int32, + Int64, + SByte, + UInt16, + UInt32, + UInt64, + Single, + Double, + Char, + Boolean, + String, + DateTime, + Decimal, + Empty, + // ReSharper disable once InconsistentNaming + DBNull, // Never used + Object + } +} diff --git a/src/MsgPack.Core/Properties/AssemblyInfo.cs b/src/MsgPack.Core/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..20a31f1ec --- /dev/null +++ b/src/MsgPack.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,41 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Core" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) core library." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +[assembly: InternalsVisibleTo( "MsgPack.Serialization, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.RuntimeGeneration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.CodeGeneration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.UnitTest.BclExtensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.Core/project.json b/src/MsgPack.Core/project.json new file mode 100644 index 000000000..0fd1ae46a --- /dev/null +++ b/src/MsgPack.Core/project.json @@ -0,0 +1,59 @@ +{ + "supports": {}, + "dependencies": { + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Linq": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Serialization.Primitives": "4.1.1", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11" + }, + "frameworks": { + "netstandard1.1": {} + }, + "buildOptions": { + "outputName": "MsgPack.Core", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/**/*.cs", + "../CommonAssemblyInfo.cs", + "BufferedStream.cs", + "MPContract.cs", + "NetStandardCompatibility.cs", + "./**/*.cs" + ], + "exclude": [ + "../MsgPack/Properties/AssemblyInfo.cs", + "../MsgPack/Serialization/**/*.*", + "../MsgPack/PackerUnpackerExtensions.cs", + "../MsgPack/Validation.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.CryptographyPrimitiveSerializers/Properties/AssemblyInfo.cs b/src/MsgPack.CryptographyPrimitiveSerializers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..ec7420abf --- /dev/null +++ b/src/MsgPack.CryptographyPrimitiveSerializers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Security Primitive Serializers" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) out-of-box serializers for System.Security.Cryptography.Primitives." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.CryptographyPrimitiveSerializers/Serialization/CryptographyPrimitivBuiltInSerializerProvider.cs b/src/MsgPack.CryptographyPrimitiveSerializers/Serialization/CryptographyPrimitivBuiltInSerializerProvider.cs new file mode 100644 index 000000000..43ec3c6ca --- /dev/null +++ b/src/MsgPack.CryptographyPrimitiveSerializers/Serialization/CryptographyPrimitivBuiltInSerializerProvider.cs @@ -0,0 +1,32 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class CryptographyPrimitivBuiltInSerializerProvider : BuiltInSerializerProvider + { + public CryptographyPrimitivBuiltInSerializerProvider() { } + } +} diff --git a/src/MsgPack.CryptographyPrimitiveSerializers/project.json b/src/MsgPack.CryptographyPrimitiveSerializers/project.json new file mode 100644 index 000000000..a0d38bc2f --- /dev/null +++ b/src/MsgPack.CryptographyPrimitiveSerializers/project.json @@ -0,0 +1,44 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.3": {} + }, + "buildOptions": { + "outputName": "MsgPack.CryptographyPrimitiveSerializers", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/DefaultSerializers/System_Security_Cryptography_HashAlgorithmNameMessagePackSerializer.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.DbTypeSerializers/Properties/AssemblyInfo.cs b/src/MsgPack.DbTypeSerializers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..c2fbb6ec8 --- /dev/null +++ b/src/MsgPack.DbTypeSerializers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) DB Type Serializers" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) out-of-box serializers for System.Data.Common." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.DbTypeSerializers/Serialization/DbTypeBuiltInSerializerProvider.cs b/src/MsgPack.DbTypeSerializers/Serialization/DbTypeBuiltInSerializerProvider.cs new file mode 100644 index 000000000..0911fe4d1 --- /dev/null +++ b/src/MsgPack.DbTypeSerializers/Serialization/DbTypeBuiltInSerializerProvider.cs @@ -0,0 +1,32 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class DbTypeBuiltInSerializerProvider : BuiltInSerializerProvider + { + public DbTypeBuiltInSerializerProvider() { } + } +} diff --git a/src/MsgPack.DbTypeSerializers/project.json b/src/MsgPack.DbTypeSerializers/project.json new file mode 100644 index 000000000..de85c7496 --- /dev/null +++ b/src/MsgPack.DbTypeSerializers/project.json @@ -0,0 +1,45 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "System.Data.Common": "4.1.0", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.2": {} + }, + "buildOptions": { + "outputName": "MsgPack.DbTypeSerializers", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack.Core/MPContract.cs", + "../MsgPack/Serialization/DefaultSerializers/System_DBNullMessagePackSerializer.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.ExtendedSerializers/Properties/AssemblyInfo.cs b/src/MsgPack.ExtendedSerializers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..06540f076 --- /dev/null +++ b/src/MsgPack.ExtendedSerializers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Extended Core Serializers" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) out-of-box serializers for System.dll and System.Core.dll on Unity." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.ExtendedSerializers/Serialization/ExtendedBuiltInSerializerProvider.cs b/src/MsgPack.ExtendedSerializers/Serialization/ExtendedBuiltInSerializerProvider.cs new file mode 100644 index 000000000..777ba2e2b --- /dev/null +++ b/src/MsgPack.ExtendedSerializers/Serialization/ExtendedBuiltInSerializerProvider.cs @@ -0,0 +1,32 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class ExtendedBuiltInSerializerProvider : BuiltInSerializerProvider + { + public ExtendedBuiltInSerializerProvider() { } + } +} diff --git a/src/MsgPack.ExtendedSerializers/project.json b/src/MsgPack.ExtendedSerializers/project.json new file mode 100644 index 000000000..69f2fc7f0 --- /dev/null +++ b/src/MsgPack.ExtendedSerializers/project.json @@ -0,0 +1,46 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.1": {} + }, + "buildOptions": { + "outputName": "MsgPack.ExtendedSerializers", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/PreserveAttribute.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_Generic_Queue_1MessagePackSerializer`1.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_Generic_Stack_1MessagePackSerializer`1.cs", + "../MsgPack/Serialization/DefaultSerializers/System_UriMessagePackSerializer.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.LegacyCollectionSerializers/Properties/AssemblyInfo.cs b/src/MsgPack.LegacyCollectionSerializers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..36040e3d4 --- /dev/null +++ b/src/MsgPack.LegacyCollectionSerializers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Legacy Collection Serializers" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) out-of-box serializers for System.Collections.NonGeneric and System.Collections.Spectialized." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.LegacyCollectionSerializers/Serialization/LegacyCollectionBuiltInSerializerProvider.cs b/src/MsgPack.LegacyCollectionSerializers/Serialization/LegacyCollectionBuiltInSerializerProvider.cs new file mode 100644 index 000000000..962e65cae --- /dev/null +++ b/src/MsgPack.LegacyCollectionSerializers/Serialization/LegacyCollectionBuiltInSerializerProvider.cs @@ -0,0 +1,32 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class LegacyCollectionBuiltInSerializerProvider : BuiltInSerializerProvider + { + public LegacyCollectionBuiltInSerializerProvider() { } + } +} diff --git a/src/MsgPack.LegacyCollectionSerializers/project.json b/src/MsgPack.LegacyCollectionSerializers/project.json new file mode 100644 index 000000000..09f69f430 --- /dev/null +++ b/src/MsgPack.LegacyCollectionSerializers/project.json @@ -0,0 +1,50 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "System.Collections.NonGeneric": "4.0.1", + "System.Collections.Specialized": "4.0.1", + "System.Globalization": "4.0.11", + "System.Runtime.Serialization.Primitives": "4.1.1", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.3": {} + }, + "buildOptions": { + "outputName": "MsgPack.LegacyCollectionSerializers", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/DefaultSerializers/System_Collections_QueueMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_StackMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_BitVector32MessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_NameValueCollectionMessagePackSerializer.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.NumericSerializers/Properties/AssemblyInfo.cs b/src/MsgPack.NumericSerializers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..ec9d738b4 --- /dev/null +++ b/src/MsgPack.NumericSerializers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Numeric Serializers" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) out-of-box serializers for System.Runtime.Numerics." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.NumericSerializers/Serialization/NumericBuiltInSerializerProvider.cs b/src/MsgPack.NumericSerializers/Serialization/NumericBuiltInSerializerProvider.cs new file mode 100644 index 000000000..309461be4 --- /dev/null +++ b/src/MsgPack.NumericSerializers/Serialization/NumericBuiltInSerializerProvider.cs @@ -0,0 +1,32 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class NumericBuiltInSerializerProvider : BuiltInSerializerProvider + { + public NumericBuiltInSerializerProvider() { } + } +} diff --git a/src/MsgPack.NumericSerializers/project.json b/src/MsgPack.NumericSerializers/project.json new file mode 100644 index 000000000..e4c714f12 --- /dev/null +++ b/src/MsgPack.NumericSerializers/project.json @@ -0,0 +1,45 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.3": {} + }, + "buildOptions": { + "outputName": "MsgPack.NumericSerializers", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/DefaultSerializers/System_Numerics_BigIntegerMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Numerics_ComplexMessagePackSerializer.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.RuntimeGeneration/Properties/AssemblyInfo.cs b/src/MsgPack.RuntimeGeneration/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..11c7e0e6c --- /dev/null +++ b/src/MsgPack.RuntimeGeneration/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Runtime CIL Generation" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) runtime CIL generation feature library." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +[assembly: InternalsVisibleTo( "MsgPack.CodeGeneration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.RuntimeGeneration/project.json b/src/MsgPack.RuntimeGeneration/project.json new file mode 100644 index 000000000..7959c4924 --- /dev/null +++ b/src/MsgPack.RuntimeGeneration/project.json @@ -0,0 +1,73 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "System.Reflection.Emit": "4.0.1", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.3": {} + }, + "buildOptions": { + "outputName": "MsgPack.RuntimeGeneration", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/AbstractSerializers/ActionType.cs", + "../MsgPack/Serialization/AbstractSerializers/CachedDelegateInfo.cs", + "../MsgPack/Serialization/AbstractSerializers/ConstructorDefinition.cs", + "../MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs", + "../MsgPack/Serialization/AbstractSerializers/EnumSerializerMethod.cs", + "../MsgPack/Serialization/AbstractSerializers/FieldDefinition.cs", + "../MsgPack/Serialization/AbstractSerializers/FieldName.cs", + "../MsgPack/Serialization/AbstractSerializers/ICodeConstruct.cs", + "../MsgPack/Serialization/AbstractSerializers/MethodDefinition.cs", + "../MsgPack/Serialization/AbstractSerializers/MethodName.cs", + "../MsgPack/Serialization/AbstractSerializers/MethodNamePrefix.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilderHelper.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Collection.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.CommonConstructs.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Enum.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Nullable.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerFieldKey.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerGenerationContext.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerSpecification.cs", + "../MsgPack/Serialization/AbstractSerializers/TypeDefinition.cs", + "../MsgPack/Serialization/EmittingSerializers/*.cs", + "../MsgPack/Serialization/Metadata/*.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ], + "exclude": [ + "../MsgPack/Serialization/EmittingSerializers/AssemblyBuilderCodeGenerationContext.cs", + "../MsgPack/Serialization/Metadata/_MessagePackSerializer.cs", + "../MsgPack/Serialization/Metadata/_SerializationContext.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.Serialization/MsgPack.Serialization.csproj b/src/MsgPack.Serialization/MsgPack.Serialization.csproj new file mode 100644 index 000000000..53efd6892 --- /dev/null +++ b/src/MsgPack.Serialization/MsgPack.Serialization.csproj @@ -0,0 +1,789 @@ + + + + + 14.0 + Debug + AnyCPU + {153CED68-9905-4B1F-9790-F463840895E2} + Library + Properties + MsgPack + MsgPack.Serialization + ja-JP + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + v5.0 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;FEATURE_TAP;NETSTANDARD1_1 + prompt + 4 + bin\Debug\MsgPack.Serialization.XML + + + pdbonly + true + bin\Release\ + TRACE;FEATURE_TAP;NETSTANDARD1_1 + prompt + 4 + bin\Release\MsgPack.Serialization.XML + + + true + + + ..\MsgPack.snk + + + + + MsgPack.snk + + + + + + Properties\CommonAssemblyInfo.cs + + + PackerUnpackerExtensions.cs + + + Serialization\AbstractSerializers\ActionType.cs + + + Serialization\AbstractSerializers\CachedDelegateInfo.cs + + + Serialization\AbstractSerializers\ConstructorDefinition.cs + + + Serialization\AbstractSerializers\DynamicUnpackingContext.cs + + + Serialization\AbstractSerializers\EnumSerializerMethod.cs + + + Serialization\AbstractSerializers\FieldDefinition.cs + + + Serialization\AbstractSerializers\FieldName.cs + + + Serialization\AbstractSerializers\ICodeConstruct.cs + + + Serialization\AbstractSerializers\ISerializerBuilder.cs + + + Serialization\AbstractSerializers\MethodDefinition.cs + + + Serialization\AbstractSerializers\MethodName.cs + + + Serialization\AbstractSerializers\MethodNamePrefix.cs + + + Serialization\AbstractSerializers\SerializerBuilderHelper.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.Collection.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.CommonConstructs.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.Enum.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.Nullable.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.Object.cs + + + Serialization\AbstractSerializers\SerializerBuilder`2.Tuple.cs + + + Serialization\AbstractSerializers\SerializerFieldKey.cs + + + Serialization\AbstractSerializers\SerializerGenerationContext.cs + + + Serialization\AbstractSerializers\SerializerSpecification.cs + + + Serialization\AbstractSerializers\TypeDefinition.cs + + + Serialization\CollectionDetailedKind.cs + + + Serialization\CollectionKind.cs + + + Serialization\CollectionSerializers\CollectionMessagePackSerializerBase`2.cs + + + Serialization\CollectionSerializers\CollectionMessagePackSerializer`2.cs + + + Serialization\CollectionSerializers\CollectionSerializerHelpers.cs + + + Serialization\CollectionSerializers\DictionaryMessagePackSerializerBase`3.cs + + + Serialization\CollectionSerializers\DictionaryMessagePackSerializer`3.cs + + + Serialization\CollectionSerializers\EnumerableMessagePackSerializerBase`2.cs + + + Serialization\CollectionSerializers\EnumerableMessagePackSerializer`2.cs + + + Serialization\CollectionSerializers\ICollectionInstanceFactory.cs + + + Serialization\CollectionSerializers\NonGenericCollectionMessagePackSerializer`1.cs + + + Serialization\CollectionSerializers\NonGenericDictionaryMessagePackSerializer`1.cs + + + Serialization\CollectionSerializers\NonGenericEnumerableMessagePackSerializerBase`1.cs + + + Serialization\CollectionSerializers\NonGenericEnumerableMessagePackSerializer`1.cs + + + Serialization\CollectionSerializers\NonGenericListMessagePackSerializer`1.cs + + + Serialization\CollectionSerializers\ReadOnlyCollectionMessagePackSerializer`2.cs + + + Serialization\CollectionSerializers\ReadOnlyDictionaryMessagePackSerializer`3.cs + + + Serialization\CollectionTraitOptions.cs + + + Serialization\CollectionTraits.cs + + + Serialization\DataMemberContract.cs + + + Serialization\DateTimeConversionMethod.cs + + + Serialization\DateTimeMemberConversionMethod.cs + + + Serialization\DateTimeMessagePackSerializerHelpers.cs + + + Serialization\DefaultConcreteTypeRepository.cs + + + Serialization\DefaultSerializerNameResolver.cs + + + Serialization\DefaultSerializers\AbstractCollectionMessagePackSerializer`2.cs + + + Serialization\DefaultSerializers\AbstractCollectionSerializerHelper.cs + + + Serialization\DefaultSerializers\AbstractDictionaryMessagePackSerializer`3.cs + + + Serialization\DefaultSerializers\AbstractEnumerableMessagePackSerializer`2.cs + + + Serialization\DefaultSerializers\AbstractNonGenericCollectionMessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\AbstractNonGenericDictionaryMessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\AbstractNonGenericEnumerableMessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\AbstractNonGenericListMessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\AbstractReadOnlyCollectionMessagePackSerializer`2.cs + + + Serialization\DefaultSerializers\AbstractReadOnlyDictionaryMessagePackSerializer`3.cs + + + Serialization\DefaultSerializers\ArraySegmentMessageSerializer.cs + + + Serialization\DefaultSerializers\ArraySerializer.cs + + + Serialization\DefaultSerializers\ArraySerializer.Primitives.cs + + + Serialization\DefaultSerializers\ArraySerializer`1.cs + + + Serialization\DefaultSerializers\DateTimeMessagePackSerializerProvider.cs + + + Serialization\DefaultSerializers\DateTimeOffsetMessagePackSerializer.cs + + + Serialization\DefaultSerializers\DateTimeOffsetMessagePackSerializerProvider.cs + + + Serialization\DefaultSerializers\FileTimeMessagePackSerializerProvider.cs + + + Serialization\DefaultSerializers\FSharpCollectionSerializer`2.cs + + + Serialization\DefaultSerializers\FSharpMapSerializer`3.cs + + + Serialization\DefaultSerializers\GenericSerializer.cs + + + Serialization\DefaultSerializers\ImmutableCollectionSerializer`2.cs + + + Serialization\DefaultSerializers\ImmutableDictionarySerializer`3.cs + + + Serialization\DefaultSerializers\ImmutableStackSerializer`2.cs + + + Serialization\DefaultSerializers\InternalDateTimeExtensions.cs + + + Serialization\DefaultSerializers\MessagePackObjectExtensions.cs + + + Serialization\DefaultSerializers\MsgPack_MessagePackExtendedTypeObjectMessagePackSerializer.cs + + + Serialization\DefaultSerializers\MsgPack_MessagePackObjectDictionaryMessagePackSerializer.cs + + + Serialization\DefaultSerializers\MsgPack_MessagePackObjectMessagePackSerializer.cs + + + Serialization\DefaultSerializers\MultidimensionalArraySerializer`1.cs + + + Serialization\DefaultSerializers\NativeDateTimeMessagePackSerializer.cs + + + Serialization\DefaultSerializers\NativeFileTimeMessagePackSerializer.cs + + + Serialization\DefaultSerializers\NullableMessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\System_ArraySegment_1MessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\System_ByteArrayMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_CharArrayMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_Collections_Generic_Dictionary_2MessagePackSerializer`2.cs + + + Serialization\DefaultSerializers\System_Collections_Generic_KeyValuePair_2MessagePackSerializer`2.cs + + + Serialization\DefaultSerializers\System_Collections_Generic_ListOfMessagePackObjectMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_Collections_Generic_List_1MessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\System_Collections_Generic_Queue_1MessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\System_Collections_Generic_Stack_1MessagePackSerializer`1.cs + + + Serialization\DefaultSerializers\System_Globalization_CultureInfoMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_ObjectMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_StringMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_Text_StringBuilderMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_UriMessagePackSerializer.cs + + + Serialization\DefaultSerializers\System_VersionMessagePackSerializer.cs + + + Serialization\DefaultSerializers\UnixEpocDateTimeMessagePackSerializer.cs + + + Serialization\DefaultSerializers\UnixEpocFileTimeMessagePackSerializer.cs + + + Serialization\DictionaryKeyTransformers.cs + + + Serialization\DictionarySerlaizationOptions.cs + + + Serialization\EmitterFlavor.cs + + + Serialization\EmittingSerializers\AndConditionILConstruct.cs + + + Serialization\EmittingSerializers\AssemblyBuilderEmittingContext.cs + + + Serialization\EmittingSerializers\AssemblyBuilderSerializerBuilder.cs + + + Serialization\EmittingSerializers\BinaryOperatorILConstruct.cs + + + Serialization\EmittingSerializers\ConditionalILConstruct.cs + + + Serialization\EmittingSerializers\ContextfulILConstruct.cs + + + Serialization\EmittingSerializers\ILConstruct.cs + + + Serialization\EmittingSerializers\ILMethodConctext.cs + + + Serialization\EmittingSerializers\InvocationILConsruct.cs + + + Serialization\EmittingSerializers\LoadFieldILConstruct.cs + + + Serialization\EmittingSerializers\SequenceILConstruct.cs + + + Serialization\EmittingSerializers\SerializationMethodGeneratorManager.cs + + + Serialization\EmittingSerializers\SerializerEmitter.cs + + + Serialization\EmittingSerializers\SerializerEmitter.enum.cs + + + Serialization\EmittingSerializers\SerializerEmitter.object.cs + + + Serialization\EmittingSerializers\SinglelStepILConstruct.cs + + + Serialization\EmittingSerializers\StatementExpressionILConstruct.cs + + + Serialization\EmittingSerializers\StoreFieldILConstruct.cs + + + Serialization\EmittingSerializers\StoreVariableILConstruct.cs + + + Serialization\EmittingSerializers\UnaryOperatorILConstruct.cs + + + Serialization\EmittingSerializers\VariableILConstruct.cs + + + Serialization\EnumMemberSerializationMethod.cs + + + Serialization\EnumMessagePackSerializerHelpers.cs + + + Serialization\EnumMessagePackSerializerProvider.cs + + + Serialization\EnumMessagePackSerializer`1.cs + + + Serialization\EnumNameTransformers.cs + + + Serialization\EnumSerializationMethod.cs + + + Serialization\EnumSerializationOptions.cs + + + Serialization\ExtTypeCodeMapping.cs + + + Serialization\FromExpression.cs + + + Serialization\FromExpression.ToMethod.cs + + + Serialization\ICustomizableEnumSerializer.cs + + + Serialization\IdentifierUtility.cs + + + Serialization\IMessagePackSerializer.cs + + + Serialization\IMessagePackSingleObjectSerializer.cs + + + Serialization\INilImplicationHandlerOnUnpackedParameter.cs + + + Serialization\INilImplicationHandlerParameter.cs + + + Serialization\ISerializerGeneratorConfiguration.cs + + + Serialization\KeyNameTransformers.cs + + + Serialization\LazyDelegatingMessagePackSerializer`1.cs + + + Serialization\MessagePackDateTimeMemberAttribute.cs + + + Serialization\MessagePackDeserializationConstructorAttribute.cs + + + Serialization\MessagePackEnumAttribute.cs + + + Serialization\MessagePackEnumMemberAttribute.cs + + + Serialization\MessagePackIgnoreAttribute.cs + + + Serialization\MessagePackKnownTypeAttributes.cs + + + Serialization\MessagePackMemberAttribute.cs + + + Serialization\MessagePackRuntimeTypeAttributes.cs + + + Serialization\MessagePackSerializer.cs + + + Serialization\MessagePackSerializer.Factories.cs + + + Serialization\MessagePackSerializerExtensions.cs + + + Serialization\MessagePackSerializerProvider.cs + + + Serialization\MessagePackSerializer`1.cs + + + Serialization\Metadata\_CultureInfo.cs + + + Serialization\Metadata\_DateTimeMessagePackSerializerHelpers.cs + + + Serialization\Metadata\_Decimal.cs + + + Serialization\Metadata\_DictionaryEntry.cs + + + Serialization\Metadata\_DynamicUnpackingContext.cs + + + Serialization\Metadata\_EnumMessagePackSerializerHelpers.cs + + + Serialization\Metadata\_FieldInfo.cs + + + Serialization\Metadata\_IDictionaryEnumerator.cs + + + Serialization\Metadata\_IDisposable.cs + + + Serialization\Metadata\_IEnumreator.cs + + + Serialization\Metadata\_MessagePackObject.cs + + + Serialization\Metadata\_MessagePackSerializer.cs + + + Serialization\Metadata\_MethodBase.cs + + + Serialization\Metadata\_Object.cs + + + Serialization\Metadata\_Packer.cs + + + Serialization\Metadata\_SerializationContext.cs + + + Serialization\Metadata\_String.cs + + + Serialization\Metadata\_Unpacker.cs + + + Serialization\Metadata\_UnpackHelpers.cs + + + Serialization\Metadata\_UnpackHelpers.direct.cs + + + Serialization\NilImplication.cs + + + Serialization\NilImplicationHandler`4.cs + + + Serialization\NullTextWriter.cs + + + Serialization\PackHelperParameters.cs + + + Serialization\PackHelpers.cs + + + Serialization\PolymorphicTypeVerificationContext.cs + + + Serialization\Polymorphism\IPolymorphicDeserializer.cs + + + Serialization\Polymorphism\IPolymorphicHelperAttributes.cs + + + Serialization\Polymorphism\KnownTypePolymorphicMessagePackSerializer`1.cs + + + Serialization\Polymorphism\PolymorphicSerializerProvider`1.cs + + + Serialization\Polymorphism\RuntimeTypeVerifier.cs + + + Serialization\Polymorphism\TypeEmbedingPolymorphicMessagePackSerializer`1.cs + + + Serialization\Polymorphism\TypeInfoEncoder.cs + + + Serialization\Polymorphism\TypeInfoEncoding.cs + + + Serialization\PolymorphismSchema.Constructors.cs + + + Serialization\PolymorphismSchema.cs + + + Serialization\PolymorphismSchema.Internals.cs + + + Serialization\PolymorphismSchemaChildrenType.cs + + + Serialization\PolymorphismTarget.cs + + + Serialization\PolymorphismType.cs + + + Serialization\ReflectionExtensions.cs + + + Serialization\ReflectionHelpers.cs + + + Serialization\ReflectionSerializers\ReflectionCollectionMessagePackSerializer`2.cs + + + Serialization\ReflectionSerializers\ReflectionDictionaryMessagePackSerializer`3.cs + + + Serialization\ReflectionSerializers\ReflectionEnumerableMessagePackSerializer`2.cs + + + Serialization\ReflectionSerializers\ReflectionEnumMessagePackSerializer`1.cs + + + Serialization\ReflectionSerializers\ReflectionNilImplicationHandler.cs + + + Serialization\ReflectionSerializers\ReflectionNonGeenricCollectionMessagePackSerializer`1.cs + + + Serialization\ReflectionSerializers\ReflectionNonGeenricEnumerableMessagePackSerializer`1.cs + + + Serialization\ReflectionSerializers\ReflectionNonGenericDictionaryMessagePackSerializer`1.cs + + + Serialization\ReflectionSerializers\ReflectionNonGenericListMessagePackSerializer`1.cs + + + Serialization\ReflectionSerializers\ReflectionObjectMessagePackSerializer`1.cs + + + Serialization\ReflectionSerializers\ReflectionSerializerHelper.cs + + + Serialization\ReflectionSerializers\ReflectionSerializerNilImplicationHandlerOnUnpackedParameter.cs + + + Serialization\ReflectionSerializers\ReflectionSerializerNilImplicationHandlerParameter.cs + + + Serialization\ReflectionSerializers\ReflectionTupleMessagePackSerializer`1.cs + + + Serialization\Reflection\GenericTypeExtensions.cs + + + Serialization\Reflection\ReflectionExtensions.cs + + + Serialization\Reflection\TracingILGenerator.conveniences.cs + + + Serialization\Reflection\TracingILGenerator.cs + + + Serialization\Reflection\TracingILGenerator.emits.cs + + + Serialization\ResolveSerializerEventArgs.cs + + + Serialization\SerializationCompatibilityOptions.cs + + + Serialization\SerializationContext.cs + + + Serialization\SerializationContext.ExtTypeCodes.cs + + + Serialization\SerializationExceptions.cs + + + Serialization\SerializationMethod.cs + + + Serialization\SerializationMethodGeneratorOption.cs + + + Serialization\SerializationTarget.cs + + + Serialization\SerializerCapabilities.cs + + + Serialization\SerializerDebugging.cs + + + Serialization\SerializerOptions.cs + + + Serialization\SerializerRegistrationOptions.cs + + + Serialization\SerializerRepository.cs + + + Serialization\SerializerTypeKeyRepository.cs + + + Serialization\SerializingMember.cs + + + Serialization\Tracer.cs + + + Serialization\TypeKeyRepository.cs + + + Serialization\UnpackHelperParameters.cs + + + Serialization\UnpackHelpers.cs + + + Serialization\UnpackHelpers.direct.cs + + + Serialization\UnpackHelpers.facade.cs + + + + + + + + + {08d9a49d-736e-4cad-919e-72ca8c1d4a9f} + MsgPack.Core + + + + + \ No newline at end of file diff --git a/src/MsgPack.Serialization/Properties/AssemblyInfo.cs b/src/MsgPack.Serialization/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..10eb90e62 --- /dev/null +++ b/src/MsgPack.Serialization/Properties/AssemblyInfo.cs @@ -0,0 +1,46 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) Serialization" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) serialization library." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +[assembly: InternalsVisibleTo( "MsgPack.RuntimeGeneration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.ExtendedSerializers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.LegacyCollectionSerializers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.DbTypeSerializers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.NumericSerializers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.VectorSerializers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.CryptographyPrimitiveSerializers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.CodeGeneration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +[assembly: InternalsVisibleTo( "MsgPack.UnitTest.BclExtensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.Serialization/Serialization/BuiltInSerializerProvider.cs b/src/MsgPack.Serialization/Serialization/BuiltInSerializerProvider.cs new file mode 100644 index 000000000..c56e63de2 --- /dev/null +++ b/src/MsgPack.Serialization/Serialization/BuiltInSerializerProvider.cs @@ -0,0 +1,57 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace MsgPack.Serialization +{ + /// + /// Defines basic features and interfaces for built-in serializer provider. + /// + internal abstract class BuiltInSerializerProvider + { + private static readonly Type[] ConstructorParameterTypes = new [] { typeof( SerializationContext ) }; + + protected BuiltInSerializerProvider() { } + + public IEnumerable> GetSerializers( SerializationContext context ) + { + return + this.GetType() + .GetAssembly() + .DefinedTypes + .Where( typeInfo => typeof( MessagePackSerializer ).IsAssignableFrom( typeInfo.AsType() ) ) + .Select( typeInfo=> new KeyValuePair( typeInfo.AsType().TypeHandle, this.GetSerializer( context, typeInfo.AsType() ) ) ); + } + + protected virtual object GetSerializer( SerializationContext context, Type serializerType ) + { + if( serializerType.GetIsGenericTypeDefinition() ) + { + return serializerType; + } + + return ReflectionExtensions.InvokePreservingExceptionType( serializerType.GetConstructor( ConstructorParameterTypes ), context ); + } + } +} diff --git a/src/MsgPack.Serialization/Serialization/DefaultBuiltInSerializerProvider.cs b/src/MsgPack.Serialization/Serialization/DefaultBuiltInSerializerProvider.cs new file mode 100644 index 000000000..7ef926005 --- /dev/null +++ b/src/MsgPack.Serialization/Serialization/DefaultBuiltInSerializerProvider.cs @@ -0,0 +1,58 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices.ComTypes; + +using MsgPack.Serialization.DefaultSerializers; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class DefaultBuiltInSerializerProvider : BuiltInSerializerProvider + { + private readonly Dictionary> _customFactories = + new Dictionary>( 6 ) + { + { typeof( DateTime ).TypeHandle, ownerContext => new DateTimeMessagePackSerializerProvider( ownerContext, false ) }, + { typeof( DateTimeOffset ).TypeHandle, ownerContext => new DateTimeOffsetMessagePackSerializerProvider( ownerContext, false ) }, + { typeof( FILETIME ).TypeHandle, ownerContext => new FileTimeMessagePackSerializerProvider( ownerContext, false ) }, + { typeof( DateTime? ).TypeHandle, ownerContext => new DateTimeMessagePackSerializerProvider( ownerContext, true ) }, + { typeof( DateTimeOffset? ).TypeHandle, ownerContext => new DateTimeOffsetMessagePackSerializerProvider( ownerContext, true ) }, + { typeof( FILETIME? ).TypeHandle, ownerContext => new FileTimeMessagePackSerializerProvider( ownerContext, true ) } + }; + + public DefaultBuiltInSerializerProvider() { } + + protected override object GetSerializer( SerializationContext context, Type serializerType ) + { + Func customFactory; + if ( this._customFactories.TryGetValue( serializerType.TypeHandle, out customFactory ) ) + { + return customFactory( context ); + } + + return base.GetSerializer( context, serializerType ); + } + } +} diff --git a/src/MsgPack.Serialization/Serialization/SerializerRepository.composition.cs b/src/MsgPack.Serialization/Serialization/SerializerRepository.composition.cs new file mode 100644 index 000000000..f4dd8f373 --- /dev/null +++ b/src/MsgPack.Serialization/Serialization/SerializerRepository.composition.cs @@ -0,0 +1,93 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +#if UNITY_5 || UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_WII || UNITY_IPHONE || UNITY_ANDROID || UNITY_PS3 || UNITY_XBOX360 || UNITY_FLASH || UNITY_BKACKBERRY || UNITY_WINRT +#define UNITY +#define AOT +#endif + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Reflection; + +using MsgPack; + +namespace MsgPack.Serialization +{ + partial class SerializerRepository + { + private static readonly string AssemblyPublicKeyToken = Binary.ToHexString(typeof( SerializationContext ).GetAssembly().GetName().GetPublicKeyToken()) ?? "null"; + private static readonly string AssemblyVersion = typeof(SerializationContext).GetAssembly().GetName().Version.ToString(); + + private static readonly Func>>[] BuiltInSerializerProviders = + new [] + { + "Extended", + "LegacyCollection", + "DbType", + "Numeric", + "Vector", + "SecurityPrimitive" + }.Select( name => + String.Format( CultureInfo.InvariantCulture, "MsgPack.{0}Serializers, Version={1}, Culture=neutral, PublicKeyToken={2}", name, AssemblyVersion, AssemblyPublicKeyToken ) + ).Select( fullName => TryLoadAssembly( fullName ) ) + .Where( assembly => assembly != null ) + .SelectMany( assembly => assembly.DefinedTypes ) + .Select( typeInfo => typeInfo.AsType() ) + .Where( type => typeof( BuiltInSerializerProvider ).IsAssignableFrom( type ) && !type.GetIsAbstract() ) + .Select( type => + type.GetConstructor( ReflectionAbstractions.EmptyTypes ) +#if !AOT + .CreateConstructorDelegate>()() +#else + .InvokePreservingExceptionType() as BuiltInSerializerProvider +#endif // !AOT + ).Select( x => new Func>>( x.GetSerializers ) ) + .ToArray(); + + private static Assembly TryLoadAssembly( string assemblyName ) + { + try + { + return Assembly.Load( new AssemblyName( assemblyName ) ); + } + catch(Exception ex) + { + Debug.WriteLine(ex); + return null; + } + } + + // Should be 54. + + #if DEBUG + internal + #else + private + #endif // DEBUG + static Dictionary InitializeDefaultTable( SerializationContext ownerContext ) + { + return BuiltInSerializerProviders.SelectMany( factory => factory( ownerContext ) ).ToDictionary( kv => kv.Key, kv => kv.Value ); + } + } +} diff --git a/src/MsgPack.Serialization/project.json b/src/MsgPack.Serialization/project.json new file mode 100644 index 000000000..00f1caa8d --- /dev/null +++ b/src/MsgPack.Serialization/project.json @@ -0,0 +1,175 @@ +{ + "supports": {}, + "dependencies": { + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Linq": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Emit": "4.0.1", + "System.Reflection.Emit.Lightweight": "4.0.1", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Serialization.Primitives": "4.1.1", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Text.RegularExpressions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Linq.Expressions": "4.1.0", + "MsgPack.Core": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.1": {}, + "MonoAndroid10": { + "buildOptions": { + "define": [ "AOT" ] + }, + "frameworkAssemblies": { + "mscorlib": { + "type": "build", + "version": "2.0.5.0" + }, + "System": { + "type": "build", + "version": "2.0.5.0" + }, + "System.Core": { + "type": "build", + "version": "2.0.5.0" + } + } + }, + "Xamarin.iOS10": { + "buildOptions": { + "define": [ "AOT" ] + }, + "frameworkAssemblies": { + "mscorlib": { + "type": "build", + "version": "2.0.5.0" + }, + "System": { + "type": "build", + "version": "2.0.5.0" + }, + "System.Core": { + "type": "build", + "version": "2.0.5.0" + } + } + }, + "uap10.0": { + "buildOptions": { + "define": [ "NETFX_CORE", "AOT" ] + } + } + }, + "buildOptions": { + "outputName": "MsgPack.Serialization", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/**/*.cs", + "../MsgPack/PackerUnpackerExtensions.cs", + "../MsgPack/Validation.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ], + "exclude": [ + "../MsgPack/Serialization/AbstractSerializers/ActionType.cs", + "../MsgPack/Serialization/AbstractSerializers/CachedDelegateInfo.cs", + "../MsgPack/Serialization/AbstractSerializers/ConstructorDefinition.cs", + "../MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs", + "../MsgPack/Serialization/AbstractSerializers/EnumSerializerMethod.cs", + "../MsgPack/Serialization/AbstractSerializers/FieldDefinition.cs", + "../MsgPack/Serialization/AbstractSerializers/FieldName.cs", + "../MsgPack/Serialization/AbstractSerializers/ICodeConstruct.cs", + "../MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerationContext.cs", + "../MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerator.cs", + "../MsgPack/Serialization/AbstractSerializers/MethodDefinition.cs", + "../MsgPack/Serialization/AbstractSerializers/MethodName.cs", + "../MsgPack/Serialization/AbstractSerializers/MethodNamePrefix.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilderHelper.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Collection.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.CommonConstructs.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Enum.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Nullable.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerFieldKey.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerGenerationContext.cs", + "../MsgPack/Serialization/AbstractSerializers/SerializerSpecification.cs", + "../MsgPack/Serialization/AbstractSerializers/TypeDefinition.cs", + "../MsgPack/Serialization/CodeDomSerializers/**/*.*", + "../MsgPack/Serialization/DefaultSerializers/SimdTypeSerializers.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_QueueMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_StackMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_BitVector32MessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_NameValueCollectionMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Collections_StackMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_DBNullMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Numerics_BigIntegerMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Numerics_ComplexMessagePackSerializer.cs", + "../MsgPack/Serialization/DefaultSerializers/System_Security_Cryptography_HashAlgorithmNameMessagePackSerializer.cs", + "../MsgPack/Serialization/EmittingSerializers/**/*.*", + "../MsgPack/Serialization/Metadata/_CultureInfo.cs", + "../MsgPack/Serialization/Metadata/_DateTimeMessagePackSerializerHelpers.cs", + "../MsgPack/Serialization/Metadata/_Decimal.cs", + "../MsgPack/Serialization/Metadata/_DictionaryEntry.cs", + "../MsgPack/Serialization/Metadata/_DynamicUnpackingContext.cs", + "../MsgPack/Serialization/Metadata/_EnumMessagePackSerializerHelpers.cs", + "../MsgPack/Serialization/Metadata/_FieldInfo.cs", + "../MsgPack/Serialization/Metadata/_IDictionaryEnumerator.cs", + "../MsgPack/Serialization/Metadata/_IDisposable.cs", + "../MsgPack/Serialization/Metadata/_IEnumreator.cs", + "../MsgPack/Serialization/Metadata/_MessagePackObject.cs", + "../MsgPack/Serialization/Metadata/_MethodBase.cs", + "../MsgPack/Serialization/Metadata/_Object.cs", + "../MsgPack/Serialization/Metadata/_Packer.cs", + "../MsgPack/Serialization/Metadata/_String.cs", + "../MsgPack/Serialization/Metadata/_Unpacker.cs", + "../MsgPack/Serialization/Metadata/_UnpackHelpers.cs", + "../MsgPack/Serialization/Metadata/_UnpackHelpers.direct.cs", + "../MsgPack/Serialization/CodeGenerationSink.cs", + "../MsgPack/Serialization/IndividualFileCodeGenerationSink.cs", + "../MsgPack/Serialization/ISerializerGeneratorConfiguration.cs", + "../MsgPack/Serialization/SerializerAssemblyGenerationConfiguration.cs", + "../MsgPack/Serialization/SerializerCodeGenerationConfiguration.cs", + "../MsgPack/Serialization/SerializerCodeInformation.cs", + "../MsgPack/Serialization/SerializerGenerator.cs", + "../MsgPack/Serialization/SerializerCodeGenerationContext.cs", + "../MsgPack/Serialization/SerializerCodeGenerationResult.cs", + "../MsgPack/Serialization/SerializerRepository.defaults.cs", + "../MsgPack/Serialization/SingleTextWriterCodeGenerationSink.cs", + "../MsgPack/Serialization/TeeTextWriter.cs", + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack.VectorSerializers/Properties/AssemblyInfo.cs b/src/MsgPack.VectorSerializers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..146535fe2 --- /dev/null +++ b/src/MsgPack.VectorSerializers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +[assembly: AssemblyTitle( "MessagePack for CLI(.NET/Mono) SIMD Vector Serializers" )] +[assembly: AssemblyDescription( "MessagePack for CLI(.NET/Mono) out-of-box serializers for System.Numerics.Vectors." )] + +[assembly: AssemblyFileVersion( "0.7.2259.1047" )] + +[assembly: AllowPartiallyTrustedCallers] + +#if DEBUG || PERFORMANCE_TEST +[assembly: InternalsVisibleTo( "MsgPack.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a967de8de9d45380b93a6aa56f64fc2cb2d3c9d4b400e00de01f31ba9e15cf5ca95926dbf8760cce413eabd711e23df0c133193a570da8a3bb1bdc00ef170fccb2bc033266fa5346442c9cf0b071133d5b484845eab17095652aeafeeb71193506b8294d9c8c91e3fd01cc50bdbc2d0eb78dd655bb8cd0bd3cdbbcb192549cb4" )] +#endif + + diff --git a/src/MsgPack.VectorSerializers/Serialization/VectorBuiltInSerializerProvider.cs b/src/MsgPack.VectorSerializers/Serialization/VectorBuiltInSerializerProvider.cs new file mode 100644 index 000000000..a75b30410 --- /dev/null +++ b/src/MsgPack.VectorSerializers/Serialization/VectorBuiltInSerializerProvider.cs @@ -0,0 +1,32 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; + +namespace MsgPack.Serialization +{ + /// + /// for this assembly. + /// + internal sealed class VectorBuiltInSerializerProvider : BuiltInSerializerProvider + { + public VectorBuiltInSerializerProvider() { } + } +} diff --git a/src/MsgPack.VectorSerializers/project.json b/src/MsgPack.VectorSerializers/project.json new file mode 100644 index 000000000..40da7a407 --- /dev/null +++ b/src/MsgPack.VectorSerializers/project.json @@ -0,0 +1,44 @@ +{ + "supports": {}, + "dependencies": { + "System.Runtime": "4.1.0", + "System.Numerics.Vectors": "4.1.1", + "MsgPack.Core": { + "version": "*", + "target": "project" + }, + "MsgPack.Serialization": { + "version": "*", + "target": "project" + } + }, + "frameworks": { + "netstandard1.1": {} + }, + "buildOptions": { + "outputName": "MsgPack.VectorSerializers", + "keyFile": "../MsgPack.snk", + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "DEBUG" ], + "optimize": false + } + }, + "Release": { + "buildOptions": { + "optimize": true + } + } + }, + "define": [ "TRACE", "FEATURE_TAP", "FEATURE_CONCURRENT" ], + "xmlDoc": true, + "compile": { + "include": [ + "../MsgPack/Serialization/DefaultSerializers/SimdTypeSerializers.cs", + "../CommonAssemblyInfo.cs", + "./**/*.cs" + ] + } + } +} \ No newline at end of file diff --git a/src/MsgPack/BigEndianBinary.cs b/src/MsgPack/BigEndianBinary.cs index 3794eb9ae..cc1fc560b 100644 --- a/src/MsgPack/BigEndianBinary.cs +++ b/src/MsgPack/BigEndianBinary.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 namespace MsgPack { diff --git a/src/MsgPack/CollectionOperation.cs b/src/MsgPack/CollectionOperation.cs index 362b0c7e8..1321e66b0 100644 --- a/src/MsgPack/CollectionOperation.cs +++ b/src/MsgPack/CollectionOperation.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Linq; namespace MsgPack diff --git a/src/MsgPack/Float32Bits.cs b/src/MsgPack/Float32Bits.cs index be6944809..451436654 100644 --- a/src/MsgPack/Float32Bits.cs +++ b/src/MsgPack/Float32Bits.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Runtime.InteropServices; namespace MsgPack diff --git a/src/MsgPack/Float64Bits.cs b/src/MsgPack/Float64Bits.cs index 00f7f9c7c..b36e5b6f1 100644 --- a/src/MsgPack/Float64Bits.cs +++ b/src/MsgPack/Float64Bits.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Runtime.InteropServices; namespace MsgPack diff --git a/src/MsgPack/ItemsUnpacker.cs b/src/MsgPack/ItemsUnpacker.cs index 07259d134..1752d4b24 100644 --- a/src/MsgPack/ItemsUnpacker.cs +++ b/src/MsgPack/ItemsUnpacker.cs @@ -24,11 +24,11 @@ using System; #if DEBUG -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 #endif // DEBUG using System.Globalization; using System.IO; diff --git a/src/MsgPack/MessagePackConvert.cs b/src/MsgPack/MessagePackConvert.cs index 7c5981d73..5572c30b9 100644 --- a/src/MsgPack/MessagePackConvert.cs +++ b/src/MsgPack/MessagePackConvert.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Text; namespace MsgPack diff --git a/src/MsgPack/MessagePackObject.Utilities.cs b/src/MsgPack/MessagePackObject.Utilities.cs index 85d21c8a1..01b8e94c7 100644 --- a/src/MsgPack/MessagePackObject.Utilities.cs +++ b/src/MsgPack/MessagePackObject.Utilities.cs @@ -25,11 +25,11 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || !UNITY || NETSTANDARD1_1 +#endif // !UNITY || NETSTANDARD1_1 using System.Globalization; using System.Linq; #if NETFX_CORE diff --git a/src/MsgPack/MessagePackObject.cs b/src/MsgPack/MessagePackObject.cs index 2322abeb4..9ead7fa56 100644 --- a/src/MsgPack/MessagePackObject.cs +++ b/src/MsgPack/MessagePackObject.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Runtime.InteropServices; namespace MsgPack diff --git a/src/MsgPack/MessagePackObject.tt b/src/MsgPack/MessagePackObject.tt index b563c49e5..19b7ec51a 100644 --- a/src/MsgPack/MessagePackObject.tt +++ b/src/MsgPack/MessagePackObject.tt @@ -79,11 +79,11 @@ Func IsNotCLSCompliant = #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Runtime.InteropServices; namespace MsgPack diff --git a/src/MsgPack/MessagePackObjectDictionary.Enumerator.cs b/src/MsgPack/MessagePackObjectDictionary.Enumerator.cs index e09eedf20..e2fdcefd4 100644 --- a/src/MsgPack/MessagePackObjectDictionary.Enumerator.cs +++ b/src/MsgPack/MessagePackObjectDictionary.Enumerator.cs @@ -25,11 +25,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 namespace MsgPack { diff --git a/src/MsgPack/MessagePackObjectDictionary.KeySet.Enumerator.cs b/src/MsgPack/MessagePackObjectDictionary.KeySet.Enumerator.cs index a9e92c4f4..dd6bb84fd 100644 --- a/src/MsgPack/MessagePackObjectDictionary.KeySet.Enumerator.cs +++ b/src/MsgPack/MessagePackObjectDictionary.KeySet.Enumerator.cs @@ -25,11 +25,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 namespace MsgPack { diff --git a/src/MsgPack/MessagePackObjectDictionary.KeySet.cs b/src/MsgPack/MessagePackObjectDictionary.KeySet.cs index d0ed0acea..5be222337 100644 --- a/src/MsgPack/MessagePackObjectDictionary.KeySet.cs +++ b/src/MsgPack/MessagePackObjectDictionary.KeySet.cs @@ -27,11 +27,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 namespace MsgPack { diff --git a/src/MsgPack/MessagePackObjectDictionary.ValueCollection.Enumerator.cs b/src/MsgPack/MessagePackObjectDictionary.ValueCollection.Enumerator.cs index c8fd89ef6..388b0d1b5 100644 --- a/src/MsgPack/MessagePackObjectDictionary.ValueCollection.Enumerator.cs +++ b/src/MsgPack/MessagePackObjectDictionary.ValueCollection.Enumerator.cs @@ -25,11 +25,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 namespace MsgPack { diff --git a/src/MsgPack/MessagePackObjectDictionary.ValueCollection.cs b/src/MsgPack/MessagePackObjectDictionary.ValueCollection.cs index 06bd73432..ca40f6827 100644 --- a/src/MsgPack/MessagePackObjectDictionary.ValueCollection.cs +++ b/src/MsgPack/MessagePackObjectDictionary.ValueCollection.cs @@ -27,11 +27,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 namespace MsgPack { diff --git a/src/MsgPack/MessagePackObjectDictionary.cs b/src/MsgPack/MessagePackObjectDictionary.cs index cf0d10f87..740d2c60b 100644 --- a/src/MsgPack/MessagePackObjectDictionary.cs +++ b/src/MsgPack/MessagePackObjectDictionary.cs @@ -27,11 +27,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Globalization; using System.Linq; diff --git a/src/MsgPack/MessagePackString.cs b/src/MsgPack/MessagePackString.cs index f86a6051c..edb8ddd4d 100644 --- a/src/MsgPack/MessagePackString.cs +++ b/src/MsgPack/MessagePackString.cs @@ -24,11 +24,11 @@ using System; using System.Diagnostics; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Globalization; using System.Linq; using System.Security; diff --git a/src/MsgPack/MsgPack.csproj b/src/MsgPack/MsgPack.csproj index 6b663f53b..e02c8ab9b 100644 --- a/src/MsgPack/MsgPack.csproj +++ b/src/MsgPack/MsgPack.csproj @@ -256,6 +256,7 @@ + @@ -281,6 +282,7 @@ True MessagePackKnownTypeAttributes.tt + diff --git a/src/MsgPack/Packer.Packing.cs b/src/MsgPack/Packer.Packing.cs index 40b93d696..48e349c0b 100644 --- a/src/MsgPack/Packer.Packing.cs +++ b/src/MsgPack/Packer.Packing.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Linq; using System.Text; #if FEATURE_TAP diff --git a/src/MsgPack/Packer.Packing.tt b/src/MsgPack/Packer.Packing.tt index 08d007b16..3cec6697e 100644 --- a/src/MsgPack/Packer.Packing.tt +++ b/src/MsgPack/Packer.Packing.tt @@ -35,11 +35,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Linq; using System.Text; #if FEATURE_TAP diff --git a/src/MsgPack/Packer.cs b/src/MsgPack/Packer.cs index ba98e5c82..c1a766d04 100644 --- a/src/MsgPack/Packer.cs +++ b/src/MsgPack/Packer.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Globalization; using System.IO; #if FEATURE_TAP diff --git a/src/MsgPack/PackerUnpackerExtensions.cs b/src/MsgPack/PackerUnpackerExtensions.cs index 106ee989d..1646ddaa7 100644 --- a/src/MsgPack/PackerUnpackerExtensions.cs +++ b/src/MsgPack/PackerUnpackerExtensions.cs @@ -25,11 +25,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Linq; #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/PackerUnpackerExtensions.tt b/src/MsgPack/PackerUnpackerExtensions.tt index cee7965b2..25db3b99f 100644 --- a/src/MsgPack/PackerUnpackerExtensions.tt +++ b/src/MsgPack/PackerUnpackerExtensions.tt @@ -35,11 +35,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Linq; #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/ReflectionAbstractions.cs b/src/MsgPack/ReflectionAbstractions.cs index 27279f8d8..12e2308b2 100644 --- a/src/MsgPack/ReflectionAbstractions.cs +++ b/src/MsgPack/ReflectionAbstractions.cs @@ -25,11 +25,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/AbstractSerializers/ConstructorDefinition.cs b/src/MsgPack/Serialization/AbstractSerializers/ConstructorDefinition.cs index b68f3a0ff..0e98666b3 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/ConstructorDefinition.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/ConstructorDefinition.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs b/src/MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs index cb1d6197e..9e47a4e18 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/DynamicUnpackingContext.cs @@ -20,8 +20,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Reflection; #if FEATURE_TAP using System.Threading; #endif // FEATURE_TAP diff --git a/src/MsgPack/Serialization/AbstractSerializers/FieldDefinition.cs b/src/MsgPack/Serialization/AbstractSerializers/FieldDefinition.cs index 2548ceeb6..2ae3b2268 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/FieldDefinition.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/FieldDefinition.cs @@ -19,11 +19,11 @@ #endregion -- License Terms -- using System; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Reflection; diff --git a/src/MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerator.cs b/src/MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerator.cs index 47360258f..3d3cb7fbb 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerator.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/ISerializerCodeGenerator.cs @@ -19,7 +19,6 @@ #endregion -- License Terms -- using System; -using System.Collections.Generic; namespace MsgPack.Serialization.AbstractSerializers { diff --git a/src/MsgPack/Serialization/AbstractSerializers/MethodDefinition.cs b/src/MsgPack/Serialization/AbstractSerializers/MethodDefinition.cs index 735dc8207..768cfe888 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/MethodDefinition.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/MethodDefinition.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Collection.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Collection.cs index dca2dd6f1..ca7d4cc2e 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Collection.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Collection.cs @@ -23,11 +23,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Linq; using System.Reflection; #if FEATURE_TAP diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.CommonConstructs.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.CommonConstructs.cs index 7c0f35ed5..0e3ffaa23 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.CommonConstructs.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.CommonConstructs.cs @@ -24,11 +24,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Enum.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Enum.cs index 7e3424194..fadb5c9b5 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Enum.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Enum.cs @@ -19,11 +19,11 @@ #endregion -- License Terms -- using System; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 #if FEATURE_TAP using System.Threading; #endif // FEATURE_TAP diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs index 2a2933826..691ff5109 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Object.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs index 8ba8187f2..a217e673c 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.Tuple.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Linq; using System.Reflection; #if FEATURE_TAP diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.cs index e8244c7f6..cdc43d4ba 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerBuilder`2.cs @@ -19,11 +19,11 @@ #endregion -- License Terms -- using System; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using MsgPack.Serialization.CollectionSerializers; @@ -35,9 +35,9 @@ namespace MsgPack.Serialization.AbstractSerializers /// The type of the context which holds global information for generating serializer. /// The type of the construct which abstracts code constructs. internal abstract partial class SerializerBuilder : -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_3 ISerializerCodeGenerator, -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_3 ISerializerBuilder where TContext : SerializerGenerationContext where TConstruct : class, ICodeConstruct @@ -318,8 +318,8 @@ protected abstract Func CreateEnumS TContext codeGenerationContext ); +#if !NETSTANDARD1_3 -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 /// /// Builds the serializer code using specified code generation context. /// @@ -361,7 +361,7 @@ protected virtual void BuildSerializerCodeCore( ISerializerCodeGenerationContext throw new NotSupportedException(); } -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_3 internal class SerializerBuilderNilImplicationHandler : NilImplicationHandler diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerGenerationContext.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerGenerationContext.cs index 103252f1e..7f994bfad 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerGenerationContext.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerGenerationContext.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; diff --git a/src/MsgPack/Serialization/AbstractSerializers/SerializerSpecification.cs b/src/MsgPack/Serialization/AbstractSerializers/SerializerSpecification.cs index 1e4bcbc70..c0450fd5e 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/SerializerSpecification.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/SerializerSpecification.cs @@ -20,11 +20,11 @@ using System; #if DEBUG -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 #endif // DEBUG namespace MsgPack.Serialization.AbstractSerializers diff --git a/src/MsgPack/Serialization/AbstractSerializers/TypeDefinition.cs b/src/MsgPack/Serialization/AbstractSerializers/TypeDefinition.cs index 5a84773c3..bb3026219 100644 --- a/src/MsgPack/Serialization/AbstractSerializers/TypeDefinition.cs +++ b/src/MsgPack/Serialization/AbstractSerializers/TypeDefinition.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/CodeDomSerializers/CodeDomContext.cs b/src/MsgPack/Serialization/CodeDomSerializers/CodeDomContext.cs index 1f9345c23..7b9fdc43b 100644 --- a/src/MsgPack/Serialization/CodeDomSerializers/CodeDomContext.cs +++ b/src/MsgPack/Serialization/CodeDomSerializers/CodeDomContext.cs @@ -26,7 +26,11 @@ using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; +#if NETSTANDARD1_7 +using Contract = MsgPack.MPContract; +#else using System.Diagnostics.Contracts; +#endif // NETSTANDARD1_7 using System.Globalization; using System.IO; using System.Linq; @@ -637,7 +641,11 @@ public IEnumerable Generate() { Contract.Assert( this._declaringTypes != null, "_declaringTypes != null" ); +#if !NETSTANDARD1_7 using ( var provider = CodeDomProvider.CreateProvider( this._configuration.Language ) ) +#else + var provider = CodeDomProvider.CreateProvider( this._configuration.Language ); +#endif // NETSTANDARD1_7 { var options = new CodeGeneratorOptions diff --git a/src/MsgPack/Serialization/CodeDomSerializers/CodeDomSerializerBuilder.cs b/src/MsgPack/Serialization/CodeDomSerializers/CodeDomSerializerBuilder.cs index df038a512..e1bbfa5dd 100644 --- a/src/MsgPack/Serialization/CodeDomSerializers/CodeDomSerializerBuilder.cs +++ b/src/MsgPack/Serialization/CodeDomSerializers/CodeDomSerializerBuilder.cs @@ -22,7 +22,11 @@ using System.CodeDom; using System.Collections; using System.Collections.Generic; +#if NETSTANDARD1_7 +using Contract = MsgPack.MPContract; +#else using System.Diagnostics.Contracts; +#endif // NETSTANDARD1_7 using System.Globalization; using System.Linq; using System.Reflection; @@ -45,6 +49,9 @@ namespace MsgPack.Serialization.CodeDomSerializers /// [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "CodeDOM" )] internal class CodeDomSerializerBuilder : SerializerBuilder +#if NETSTANDARD1_7 + , ISerializerCodeGenerator +#endif // NETSTANDARD1_7 { private static readonly CodeTypeReference[] EmptyGenericArguments = new CodeTypeReference[ 0 ]; @@ -1140,7 +1147,25 @@ protected override CodeDomConstruct EmitNewPrivateMethodDelegateExpression( Code ); } - protected override void BuildSerializerCodeCore( ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema ) + +#if NETSTANDARD1_7 + public void BuildSerializerCode( ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema ) + { + if ( context == null ) + { + throw new ArgumentNullException( "context" ); + } + + this.BuildSerializerCodeCore( context, concreteType, itemSchema ); + } +#endif // NETSTANDARD1_7 + +#if !NETSTANDARD1_7 + protected override +#else + private +#endif // !NETSTANDARD1_7 + void BuildSerializerCodeCore( ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema ) { var asCodeDomContext = context as CodeDomContext; if ( asCodeDomContext == null ) diff --git a/src/MsgPack/Serialization/DataMemberContract.cs b/src/MsgPack/Serialization/DataMemberContract.cs index 75d610785..d1b3ed9e5 100644 --- a/src/MsgPack/Serialization/DataMemberContract.cs +++ b/src/MsgPack/Serialization/DataMemberContract.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 || NETSTANDARD1_1 using System.Globalization; using System.Reflection; using System.Runtime.Serialization; diff --git a/src/MsgPack/Serialization/DefaultSerializers/ArraySerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/ArraySerializer.cs index e8ae27b3d..0b41dbba7 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/ArraySerializer.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/ArraySerializer.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 namespace MsgPack.Serialization.DefaultSerializers { diff --git a/src/MsgPack/Serialization/DefaultSerializers/DateTimeOffsetMessagePackSerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/DateTimeOffsetMessagePackSerializer.cs index 837cca3f0..8ea917f24 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/DateTimeOffsetMessagePackSerializer.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/DateTimeOffsetMessagePackSerializer.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Runtime.Serialization; #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.cs b/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.cs index 10a3894e6..80e9dca2c 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.cs @@ -848,131 +848,6 @@ protected internal override async Task PackToAsyncCore( Packer packer, System.UI #endif // FEATURE_TAP } - -#if !SILVERLIGHT -#if !NETSTANDARD1_1 -#if !UNITY || MSGPACK_UNITY_FULL - internal sealed class System_Collections_Specialized_BitVector32MessagePackSerializer : MessagePackSerializer< System.Collections.Specialized.BitVector32 > - { - public System_Collections_Specialized_BitVector32MessagePackSerializer( SerializationContext ownerContext ) - : base( ownerContext, SerializerCapabilities.PackTo | SerializerCapabilities.UnpackFrom ) { } - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - protected internal override void PackToCore( Packer packer, System.Collections.Specialized.BitVector32 value ) - { - packer.Pack( value.Data ); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - protected internal override System.Collections.Specialized.BitVector32 UnpackFromCore( Unpacker unpacker ) - { - System.Int32 ctorArgument; - try - { - ctorArgument = unpacker.LastReadData.AsInt32(); - } - catch( InvalidOperationException ex ) - { - throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The unpacked value is not '{0}' type. {1}", typeof( System.Int32 ), ex.Message ) ); - } - - return new System.Collections.Specialized.BitVector32( ctorArgument ); - } - -#if FEATURE_TAP - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - protected internal override async Task PackToAsyncCore( Packer packer, System.Collections.Specialized.BitVector32 value, CancellationToken cancellationToken ) - { - await packer.PackAsync( value.Data, cancellationToken ).ConfigureAwait( false ); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Transfers all catched exceptions." )] - protected internal override Task UnpackFromAsyncCore( Unpacker unpacker, CancellationToken cancellationToken ) - { - var tcs = new TaskCompletionSource(); - try - { - tcs.SetResult( this.UnpackFromCore( unpacker ) ); - } - catch( Exception ex ) - { - tcs.SetException( ex ); - } - - return tcs.Task; - } - -#endif // FEATURE_TAP - - } -#endif // !NETSTANDARD1_1 -#endif // !SILVERLIGHT -#endif // !UNITY || MSGPACK_UNITY_FULL - -#if !WINDOWS_PHONE -#if !NETFX_35 && !UNITY -#if !UNITY || MSGPACK_UNITY_FULL - internal sealed class System_Numerics_BigIntegerMessagePackSerializer : MessagePackSerializer< System.Numerics.BigInteger > - { - public System_Numerics_BigIntegerMessagePackSerializer( SerializationContext ownerContext ) - : base( ownerContext, SerializerCapabilities.PackTo | SerializerCapabilities.UnpackFrom ) { } - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - protected internal override void PackToCore( Packer packer, System.Numerics.BigInteger value ) - { - packer.PackRaw( value.ToByteArray() ); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - protected internal override System.Numerics.BigInteger UnpackFromCore( Unpacker unpacker ) - { - try - { - return new System.Numerics.BigInteger( unpacker.LastReadData.AsBinary() ); - } - catch( ArgumentException ex ) - { - throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The unpacked value is not expected type. {0}", ex.Message ), ex ); - } - catch( InvalidOperationException ex ) - { - throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The unpacked value is not expected type. {0}", ex.Message ), ex ); - } - } - -#if FEATURE_TAP - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - protected internal override async Task PackToAsyncCore( Packer packer, System.Numerics.BigInteger value, CancellationToken cancellationToken ) - { - await packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false ); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] - [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Transfers all catched exceptions." )] - protected internal override Task UnpackFromAsyncCore( Unpacker unpacker, CancellationToken cancellationToken ) - { - var tcs = new TaskCompletionSource(); - try - { - tcs.SetResult( this.UnpackFromCore( unpacker ) ); - } - catch( Exception ex ) - { - tcs.SetException( ex ); - } - - return tcs.Task; - } - -#endif // FEATURE_TAP - - } -#endif // !NETFX_35 && !UNITY -#endif // !WINDOWS_PHONE -#endif // !UNITY || MSGPACK_UNITY_FULL // ReSharper restore RedundantCast // ReSharper restore RedundantNameQualifier // ReSharper restore InconsistentNaming diff --git a/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.tt b/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.tt index b6801783e..316162989 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.tt +++ b/src/MsgPack/Serialization/DefaultSerializers/DefaultSerializers.tt @@ -39,6 +39,7 @@ var excludes = typeof( System.ArraySegment<> ), typeof( System.Collections.DictionaryEntry ), typeof( System.Collections.Generic.KeyValuePair<,> ), + typeof( System.Collections.Specialized.BitVector32 ), // Special(manual) handlings on builtin serializer: typeof( System.DateTime ), // Special(manual) handlings on builtin serializer: @@ -144,8 +145,6 @@ var types = typeof( TraceListener ).Assembly.GetTypes().Where( type => type.IsValueType && type.IsPublic && !Attribute.IsDefined( type, typeof( ObsoleteAttribute ) ) ) ).Concat( typeof( Enumerable ).Assembly.GetTypes().Where( type => type.IsValueType && type.IsPublic && !Attribute.IsDefined( type, typeof( ObsoleteAttribute ) ) ) - ).Concat( - typeof( BigInteger ).Assembly.GetTypes().Where( type => type.IsValueType && type.IsPublic && !Attribute.IsDefined( type, typeof( ObsoleteAttribute ) ) ) ).Except( excludes ) .ToArray(); @@ -155,7 +154,6 @@ var workArounds = { typeof( char ), new WorkAround(){ PackCode = "packer.Pack( ( System.UInt16 )value );", UnpackCode = "return ( System.Char ) unpacker.LastReadData.AsUInt16(); " } }, { typeof( decimal ), new WorkAround(){ PackCode = "packer.PackString( value.ToString( \"G\", CultureInfo.InvariantCulture ) );", UnpackCode = "return System.Decimal.Parse( unpacker.LastReadData.AsString(), CultureInfo.InvariantCulture ); " } }, { typeof( Guid ), new WorkAround(){ PackCode = "packer.PackRaw( value.ToByteArray() );", UnpackCode = "return new System.Guid( unpacker.LastReadData.AsBinary() ); " } }, - { typeof( BigInteger ), new WorkAround(){ PackCode = "packer.PackRaw( value.ToByteArray() );", UnpackCode = "return new System.Numerics.BigInteger( unpacker.LastReadData.AsBinary() ); " } }, }; var asyncWorkArounds = @@ -164,33 +162,7 @@ var asyncWorkArounds = { typeof( char ), "packer.PackAsync( ( System.UInt16 )value, cancellationToken ).ConfigureAwait( false );" }, { typeof( decimal ), "packer.PackStringAsync( value.ToString( \"G\", CultureInfo.InvariantCulture ), cancellationToken ).ConfigureAwait( false );" }, { typeof( Guid ), "packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );" }, - { typeof( BigInteger ), "packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false );" }, - }; - -var notInSLs = - new HashSet() - { - typeof( System.Collections.Specialized.BitVector32 ), - }; - -var notInWP8SLs = - new HashSet() - { - typeof( System.Numerics.BigInteger ), - }; - -var notInNetStandard1_1 = - new HashSet() - { - typeof( System.Collections.Specialized.BitVector32 ), - }; - -var notInNetFX35 = - new HashSet() - { - typeof( System.Numerics.BigInteger ), }; - #> #region -- License Terms -- // @@ -251,34 +223,6 @@ foreach( Type type in types ) } var ctors = type.GetConstructors( BindingFlags.Public | BindingFlags.Instance ).Where( item => item.GetParameters().Length == 1 ).Where( item => IsMessagePackPrimitive( item.GetParameters()[ 0 ].ParameterType ) ).ToArray(); - - if ( notInSLs.Contains( type ) ) - { -#> -#if !SILVERLIGHT -<# - } - - if ( notInNetStandard1_1.Contains( type ) ) - { -#> -#if !NETSTANDARD1_1 -<# - } - - if ( notInWP8SLs.Contains( type ) ) - { -#> -#if !WINDOWS_PHONE -<# - } - - if ( notInNetFX35.Contains( type ) ) - { -#> -#if !NETFX_35 && !UNITY -<# - } var typeName = type.FullName.Replace( Type.Delimiter, '_' ).Replace( '`', '_' ) + "MessagePackSerializer"; @@ -519,33 +463,6 @@ foreach( var ctor in ctors ) } <# - if ( notInNetFX35.Contains( type ) ) - { -#> -#endif // !NETFX_35 && !UNITY -<# - } - - if ( notInWP8SLs.Contains( type ) ) - { -#> -#endif // !WINDOWS_PHONE -<# - } - - if ( notInNetStandard1_1.Contains( type ) ) - { -#> -#endif // !NETSTANDARD1_1 -<# - } - - if ( notInSLs.Contains( type ) ) - { -#> -#endif // !SILVERLIGHT -<# - } if ( type.Assembly.FullName != typeof( object ).Assembly.FullName ) { diff --git a/src/MsgPack/Serialization/DefaultSerializers/GenericSerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/GenericSerializer.cs index e52b027bd..a96ced41c 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/GenericSerializer.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/GenericSerializer.cs @@ -30,11 +30,11 @@ using System.Collections; #endif // !UNITY using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 namespace MsgPack.Serialization.DefaultSerializers { diff --git a/src/MsgPack/Serialization/DefaultSerializers/MultidimensionalArraySerializer`1.cs b/src/MsgPack/Serialization/DefaultSerializers/MultidimensionalArraySerializer`1.cs index 6b711e904..8e9db27fb 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/MultidimensionalArraySerializer`1.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/MultidimensionalArraySerializer`1.cs @@ -83,7 +83,7 @@ protected internal override void PackToCore( Packer packer, object objectTree ) [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Usage", "CA2202:DoNotDisposeObjectsMultipleTimes", Justification = "Avoided via ownsStream: false" )] private void PackArrayCore( Packer packer, Array array ) { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE var longLength = array.LongLength; if ( longLength > Int32.MaxValue ) { @@ -93,7 +93,7 @@ private void PackArrayCore( Packer packer, Array array ) var totalLength = unchecked( ( int )longLength ); #else var totalLength = array.Length; -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE int[] lowerBounds, lengths; GetArrayMetadata( array, out lengths, out lowerBounds ); @@ -326,7 +326,7 @@ protected internal override Task PackToAsyncCore( Packer packer, TArray objectTr [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Usage", "CA2202:DoNotDisposeObjectsMultipleTimes", Justification = "Avoided via ownsStream: false" )] private async Task PackArrayAsyncCore( Packer packer, Array array, CancellationToken cancellationToken ) { -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE var longLength = array.LongLength; if ( longLength > Int32.MaxValue ) { @@ -336,7 +336,7 @@ private async Task PackArrayAsyncCore( Packer packer, Array array, CancellationT var totalLength = unchecked( ( int )longLength ); #else var totalLength = array.Length; -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE int[] lowerBounds, lengths; GetArrayMetadata( array, out lengths, out lowerBounds ); diff --git a/src/MsgPack/Serialization/DefaultSerializers/NullableMessagePackSerializer`1.cs b/src/MsgPack/Serialization/DefaultSerializers/NullableMessagePackSerializer`1.cs index 6175fb484..94d413144 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/NullableMessagePackSerializer`1.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/NullableMessagePackSerializer`1.cs @@ -24,11 +24,11 @@ using System; #if DEBUG -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // DEBUG #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_BitVector32MessagePackSerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_BitVector32MessagePackSerializer.cs new file mode 100644 index 000000000..f6a7300ea --- /dev/null +++ b/src/MsgPack/Serialization/DefaultSerializers/System_Collections_Specialized_BitVector32MessagePackSerializer.cs @@ -0,0 +1,90 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2010-2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +using System; +using System.Collections.Specialized; +using System.Globalization; +using System.Runtime.Serialization; +#if FEATURE_TAP +using System.Threading; +using System.Threading.Tasks; +#endif // FEATURE_TAP + +using MsgPack.Serialization.CollectionSerializers; + +namespace MsgPack.Serialization.DefaultSerializers +{ + // ReSharper disable once InconsistentNaming + internal sealed class System_Collections_Specialized_BitVector32MessagePackSerializer : MessagePackSerializer + { + public System_Collections_Specialized_BitVector32MessagePackSerializer( SerializationContext ownerContext ) + : base( ownerContext, SerializerCapabilities.PackTo | SerializerCapabilities.UnpackFrom ) { } + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + protected internal override void PackToCore( Packer packer, System.Collections.Specialized.BitVector32 value ) + { + packer.Pack( value.Data ); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + protected internal override System.Collections.Specialized.BitVector32 UnpackFromCore( Unpacker unpacker ) + { + System.Int32 ctorArgument; + try + { + ctorArgument = unpacker.LastReadData.AsInt32(); + } + catch( InvalidOperationException ex ) + { + throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The unpacked value is not '{0}' type. {1}", typeof( System.Int32 ), ex.Message ) ); + } + + return new System.Collections.Specialized.BitVector32( ctorArgument ); + } + +#if FEATURE_TAP + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + protected internal override async Task PackToAsyncCore( Packer packer, System.Collections.Specialized.BitVector32 value, CancellationToken cancellationToken ) + { + await packer.PackAsync( value.Data, cancellationToken ).ConfigureAwait( false ); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Transfers all catched exceptions." )] + protected internal override Task UnpackFromAsyncCore( Unpacker unpacker, CancellationToken cancellationToken ) + { + var tcs = new TaskCompletionSource(); + try + { + tcs.SetResult( this.UnpackFromCore( unpacker ) ); + } + catch( Exception ex ) + { + tcs.SetException( ex ); + } + + return tcs.Task; + } + +#endif // FEATURE_TAP + + } +} \ No newline at end of file diff --git a/src/MsgPack/Serialization/DefaultSerializers/System_DBNullMessagePackSerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/System_DBNullMessagePackSerializer.cs index 40a310a9a..071aaa214 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/System_DBNullMessagePackSerializer.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/System_DBNullMessagePackSerializer.cs @@ -22,14 +22,12 @@ #define UNITY #endif -#if !NETSTANDARD1_1 - using System; -#if CORE_CLR || UNITY +#if CORE_CLR || UNITY || NETSTANDARD1_2 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY +#endif // CORE_CLR || UNITY || NETSTANDARD1_2 using System.Runtime.Serialization; #if FEATURE_TAP using System.Threading; @@ -83,4 +81,3 @@ protected internal override Task UnpackFromAsyncCore( Unpacker unpacker, } } -#endif // !NETSTANDARD1_1 \ No newline at end of file diff --git a/src/MsgPack/Serialization/DefaultSerializers/System_Globalization_CultureInfoMessagePackSerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/System_Globalization_CultureInfoMessagePackSerializer.cs index 1b037d9fd..e28148ffc 100644 --- a/src/MsgPack/Serialization/DefaultSerializers/System_Globalization_CultureInfoMessagePackSerializer.cs +++ b/src/MsgPack/Serialization/DefaultSerializers/System_Globalization_CultureInfoMessagePackSerializer.cs @@ -43,11 +43,11 @@ protected internal override void PackToCore( Packer packer, CultureInfo objectTr [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated internally" )] protected internal override CultureInfo UnpackFromCore( Unpacker unpacker ) { -#if SILVERLIGHT || NETSTANDARD1_1 || NETSTANDARD1_3 +#if SILVERLIGHT || NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE return new CultureInfo( unpacker.LastReadData.AsString() ); #else return CultureInfo.GetCultureInfo( unpacker.LastReadData.AsString() ); -#endif // SILVERLIGHT || NETSTANDARD1_1 || NETSTANDARD1_3 +#endif // SILVERLIGHT || NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE } #if FEATURE_TAP diff --git a/src/MsgPack/Serialization/DefaultSerializers/System_Numerics_BigIntegerMessagePackSerializer.cs b/src/MsgPack/Serialization/DefaultSerializers/System_Numerics_BigIntegerMessagePackSerializer.cs new file mode 100644 index 000000000..4ebf97240 --- /dev/null +++ b/src/MsgPack/Serialization/DefaultSerializers/System_Numerics_BigIntegerMessagePackSerializer.cs @@ -0,0 +1,98 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2010-2016 FUJIWARA, Yusuke +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +#if UNITY_5 || UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_WII || UNITY_IPHONE || UNITY_ANDROID || UNITY_PS3 || UNITY_XBOX360 || UNITY_FLASH || UNITY_BKACKBERRY || UNITY_WINRT +#define UNITY +#endif + +using System; +using System.Globalization; +using System.Runtime.Serialization; +#if FEATURE_TAP +using System.Threading; +using System.Threading.Tasks; +#endif // FEATURE_TAP + +namespace MsgPack.Serialization.DefaultSerializers +{ + // ReSharper disable InconsistentNaming + // ReSharper disable RedundantNameQualifier + // ReSharper disable RedundantCast + + internal sealed class System_Numerics_BigIntegerMessagePackSerializer : MessagePackSerializer + { + public System_Numerics_BigIntegerMessagePackSerializer( SerializationContext ownerContext ) + : base( ownerContext, SerializerCapabilities.PackTo | SerializerCapabilities.UnpackFrom ) { } + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + protected internal override void PackToCore( Packer packer, System.Numerics.BigInteger value ) + { + packer.PackRaw( value.ToByteArray() ); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + protected internal override System.Numerics.BigInteger UnpackFromCore( Unpacker unpacker ) + { + try + { + return new System.Numerics.BigInteger( unpacker.LastReadData.AsBinary() ); + } + catch( ArgumentException ex ) + { + throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The unpacked value is not expected type. {0}", ex.Message ), ex ); + } + catch( InvalidOperationException ex ) + { + throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The unpacked value is not expected type. {0}", ex.Message ), ex ); + } + } + +#if FEATURE_TAP + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + protected internal override async Task PackToAsyncCore( Packer packer, System.Numerics.BigInteger value, CancellationToken cancellationToken ) + { + await packer.PackRawAsync( value.ToByteArray(), cancellationToken ).ConfigureAwait( false ); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods", MessageId = "0", Justification = "Validated by caller in base class" )] + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Transfers all catched exceptions." )] + protected internal override Task UnpackFromAsyncCore( Unpacker unpacker, CancellationToken cancellationToken ) + { + var tcs = new TaskCompletionSource(); + try + { + tcs.SetResult( this.UnpackFromCore( unpacker ) ); + } + catch( Exception ex ) + { + tcs.SetException( ex ); + } + + return tcs.Task; + } + +#endif // FEATURE_TAP + + } + // ReSharper restore RedundantCast + // ReSharper restore RedundantNameQualifier + // ReSharper restore InconsistentNaming +} diff --git a/src/MsgPack/Serialization/EmitterFlavor.cs b/src/MsgPack/Serialization/EmitterFlavor.cs index 4fc4aab41..510aaee59 100644 --- a/src/MsgPack/Serialization/EmitterFlavor.cs +++ b/src/MsgPack/Serialization/EmitterFlavor.cs @@ -27,21 +27,17 @@ namespace MsgPack.Serialization /// internal enum EmitterFlavor { -#if !SILVERLIGHT /// /// Caches serializers for the members (de)serialization. /// It is default. /// FieldBased, -#endif // SILVERLIGHT -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !SILVERLIGHT /// /// Uses code DOM code generation to (de)serialization. /// It requires a long time but prevents runtime code generation at all. /// CodeDomBased, -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !SILVERLIGHT /// /// Uses reflection to (de)serialization. diff --git a/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderEmittingContext.cs b/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderEmittingContext.cs index 91bb32605..a7d37f891 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderEmittingContext.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderEmittingContext.cs @@ -23,11 +23,11 @@ using System; using System.Collections.Generic; -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderSerializerBuilder.cs b/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderSerializerBuilder.cs index 81750510f..7cb195ba0 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderSerializerBuilder.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/AssemblyBuilderSerializerBuilder.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/EmittingSerializers/SerializationMethodGeneratorManager.cs b/src/MsgPack/Serialization/EmittingSerializers/SerializationMethodGeneratorManager.cs index 96cbb9022..11cd1f334 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/SerializationMethodGeneratorManager.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/SerializationMethodGeneratorManager.cs @@ -20,11 +20,11 @@ using System; using System.Diagnostics; -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Reflection; using System.Reflection.Emit; using System.Security; diff --git a/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.cs b/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.cs index bb61732d7..29537829c 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.enum.cs b/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.enum.cs index fe24dce73..68d343edf 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.enum.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.enum.cs @@ -19,11 +19,11 @@ #endregion -- License Terms -- using System; -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Reflection; using System.Reflection.Emit; diff --git a/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.object.cs b/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.object.cs index 83c82e9f2..9815de28e 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.object.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/SerializerEmitter.object.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Linq; using System.Reflection; using System.Reflection.Emit; diff --git a/src/MsgPack/Serialization/EmittingSerializers/VariableILConstruct.cs b/src/MsgPack/Serialization/EmittingSerializers/VariableILConstruct.cs index 655bb85e2..e522bd96b 100644 --- a/src/MsgPack/Serialization/EmittingSerializers/VariableILConstruct.cs +++ b/src/MsgPack/Serialization/EmittingSerializers/VariableILConstruct.cs @@ -19,11 +19,11 @@ #endregion -- License Terms -- using System; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Globalization; using MsgPack.Serialization.AbstractSerializers; diff --git a/src/MsgPack/Serialization/EnumMessagePackSerializerHelpers.cs b/src/MsgPack/Serialization/EnumMessagePackSerializerHelpers.cs index 375d296da..ec853d27f 100644 --- a/src/MsgPack/Serialization/EnumMessagePackSerializerHelpers.cs +++ b/src/MsgPack/Serialization/EnumMessagePackSerializerHelpers.cs @@ -26,9 +26,9 @@ #if !UNITY || MSGPACK_UNITY_FULL using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL -#if NETSTANDARD1_1 || NETSTANDARD1_3 +#if NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE using System.Reflection; -#endif // NETSTANDARD1_1 || NETSTANDARD1_3 +#endif // NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE namespace MsgPack.Serialization { @@ -84,7 +84,7 @@ EnumMemberSerializationMethod enumMemberSerializationMethod } default: { -#if NETSTANDARD1_1 || NETSTANDARD1_3 +#if NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE var messagePackEnumAttribute = enumType.GetTypeInfo().GetCustomAttribute(); if ( messagePackEnumAttribute != null) @@ -97,7 +97,7 @@ EnumMemberSerializationMethod enumMemberSerializationMethod { // ReSharper disable once PossibleNullReferenceException method = ( messagePackEnumAttributes[ 0 ] as MessagePackEnumAttribute ).SerializationMethod; -#endif // NETSTANDARD1_1 || NETSTANDARD1_3 +#endif // NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE } break; diff --git a/src/MsgPack/Serialization/EnumSerializationOptions.cs b/src/MsgPack/Serialization/EnumSerializationOptions.cs index df5f5491e..adb6b945b 100644 --- a/src/MsgPack/Serialization/EnumSerializationOptions.cs +++ b/src/MsgPack/Serialization/EnumSerializationOptions.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Threading; namespace MsgPack.Serialization diff --git a/src/MsgPack/Serialization/ExtTypeCodeMapping.cs b/src/MsgPack/Serialization/ExtTypeCodeMapping.cs index 89b45c447..3e9b49478 100644 --- a/src/MsgPack/Serialization/ExtTypeCodeMapping.cs +++ b/src/MsgPack/Serialization/ExtTypeCodeMapping.cs @@ -27,11 +27,11 @@ #endif // !NETFX_40 && !NETFX_35 && !UNITY && !SILVERLIGHT using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; using System.Linq; #if NETFX_45 diff --git a/src/MsgPack/Serialization/MessagePackMemberAttribute.cs b/src/MsgPack/Serialization/MessagePackMemberAttribute.cs index a744bc229..48eaa2266 100644 --- a/src/MsgPack/Serialization/MessagePackMemberAttribute.cs +++ b/src/MsgPack/Serialization/MessagePackMemberAttribute.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 namespace MsgPack.Serialization { diff --git a/src/MsgPack/Serialization/MessagePackSerializer.Builder.cs b/src/MsgPack/Serialization/MessagePackSerializer.Builder.cs new file mode 100644 index 000000000..6a707bd9a --- /dev/null +++ b/src/MsgPack/Serialization/MessagePackSerializer.Builder.cs @@ -0,0 +1,112 @@ +#region -- License Terms -- +// +// MessagePack for CLI +// +// Copyright (C) 2016 FUJIWARA, Yusuke and contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#endregion -- License Terms -- + +#if !AOT +using System; +using System.Collections.Generic; +#if NETSTANDARD1_1 +using Contract = MsgPack.MPContract; +using System.IO; +using System.Reflection; +#endif // NETSTANDARD1_1 + +using MsgPack.Serialization.AbstractSerializers; +#if !NETSTANDARD1_1 +using MsgPack.Serialization.CodeDomSerializers; +using MsgPack.Serialization.EmittingSerializers; +#endif // !NETSTANDARD1_1 + +namespace MsgPack.Serialization +{ + partial class MessagePackSerializer + { + private static readonly IDictionary> _builderFactories = + InitializeBuilderFactories(); + + private static IDictionary> InitializeBuilderFactories() + { + // Static (non-customizable) naive plugin loader. + + var result = new Dictionary>(2); +#if !NETSTANDARD1_1 + result.Add( EmitterFlavor.FieldBased, ( t, c ) => new AssemblyBuilderSerializerBuilder( t, c ) ); + result.Add( EmitterFlavor.CodeDomBased, ( t, c ) => new CodeDomSerializerBuilder( t, c ) ); +#else + result.Add( EmitterFlavor.FieldBased, CreateFactory( LoadBuilderType( "MsgPack.RuntimeGeneration", "MsgPack.Sereialization.EmittingSerializers.AssemblyBuilderSerializerBuilder" ) ) ); + result.Add( EmitterFlavor.CodeDomBased, CreateFactory( LoadBuilderType( "MsgPack.CodeGeneration", "MsgPack.Sereialization.CodeDomSerializers.CodeDomSerializerBuilder" ) ) ); +#endif // NETSTANDARD1_1 + return result; + } + +#if NETSTANDARD1_1 + private static readonly AssemblyName BaseAssemblyName = typeof(MessagePackSerializer).GetAssembly().GetName(); + + private static Type LoadBuilderType( string name, string typeName ) + { + var assemblyName = + new AssemblyName( BaseAssemblyName.FullName ) + { + Name = name + }; + + try + { + return Assembly.Load( assemblyName ).GetType( typeName ); + } + catch ( IOException ) + { + return null; + } + catch ( BadImageFormatException ) + { + return null; + } + } + + private static readonly Type[] SerializerBuilderConstractorParameterTypes = + new[] { typeof( Type ), typeof( CollectionTraits ) }; + + private static Func CreateFactory( Type builderType ) + { + if ( builderType == null ) + { + return null; + } + + var ctor = builderType.GetRuntimeConstructor( SerializerBuilderConstractorParameterTypes ); + Contract.Assert( ctor != null ); + return ctor.CreateConstructorDelegate>(); + } + +#endif // NETSTANDARD1_1 + + private static ISerializerBuilder GetSerializerBuilder( Type targetType, SerializationContext context, CollectionTraits collectionTraits ) + { + Func builderFactory; + if ( !_builderFactories.TryGetValue( context.SerializerOptions.EmitterFlavor, out builderFactory ) || builderFactory == null ) + { + return null; + } + + return builderFactory( targetType, collectionTraits ); + } + } +} +#endif // !AOT \ No newline at end of file diff --git a/src/MsgPack/Serialization/MessagePackSerializer.Factories.cs b/src/MsgPack/Serialization/MessagePackSerializer.Factories.cs index 2ba87ab4a..3a6a373fd 100644 --- a/src/MsgPack/Serialization/MessagePackSerializer.Factories.cs +++ b/src/MsgPack/Serialization/MessagePackSerializer.Factories.cs @@ -26,9 +26,9 @@ #define AOT #endif -#if !AOT && !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !AOT && !SILVERLIGHT #define FEATURE_EMIT -#endif // !AOT && !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !AOT && !SILVERLIGHT using System; using System.IO; @@ -42,15 +42,13 @@ #else // !SILVERLIGHT && !NETFX_35 && !UNITY using System.Collections.Generic; #endif // !SILVERLIGHT && !NETFX_35 && !UNITY -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #if FEATURE_EMIT using MsgPack.Serialization.AbstractSerializers; -using MsgPack.Serialization.CodeDomSerializers; -using MsgPack.Serialization.EmittingSerializers; #endif // FEATURE_EMIT namespace MsgPack.Serialization @@ -205,7 +203,6 @@ public static MessagePackSerializer Get( SerializationContext context, obj internal static MessagePackSerializer CreateInternal( SerializationContext context, PolymorphismSchema schema ) { - #if DEBUG Contract.Ensures( Contract.Result>() != null ); #endif // DEBUG @@ -249,45 +246,37 @@ internal static MessagePackSerializer CreateInternal( SerializationContext } #if FEATURE_EMIT - ISerializerBuilder builder; - switch ( context.SerializerOptions.EmitterFlavor ) + ISerializerBuilder builder = null; + if ( !context.SerializerOptions.DisableRuntimeCodeGeneration ) { - case EmitterFlavor.CodeDomBased: - { #if DEBUG - if ( !SerializerDebugging.OnTheFlyCodeGenerationEnabled ) - { - throw new NotSupportedException( - String.Format( - CultureInfo.CurrentCulture, - "Flavor '{0:G}'({0:D}) is not supported for serializer instance creation.", - context.SerializerOptions.EmitterFlavor - ) - ); - } - - builder = new CodeDomSerializerBuilder( typeof( T ), collectionTraits ); - break; -#else - throw new NotSupportedException(); -#endif - } - case EmitterFlavor.FieldBased: + if ( context.SerializerOptions.EmitterFlavor == EmitterFlavor.CodeDomBased && !SerializerDebugging.OnTheFlyCodeGenerationEnabled ) { - builder = new AssemblyBuilderSerializerBuilder( typeof( T ), collectionTraits ); - break; +#endif + throw new NotSupportedException( + String.Format( + CultureInfo.CurrentCulture, + "Flavor '{0:G}'({0:D}) is not supported for serializer instance creation.", + context.SerializerOptions.EmitterFlavor + ) + ); +#if DEBUG } - default: // EmitterFlavor.ReflectionBased - { +#endif + builder = GetSerializerBuilder( typeof( T ), context, collectionTraits ); + } + + if ( builder == null ) + { #endif // FEATURE_EMIT - return - GenericSerializer.TryCreateAbstractCollectionSerializer( context, typeof( T ), concreteType, schema ) as MessagePackSerializer - ?? CreateReflectionInternal( context, concreteType ?? typeof( T ), schema ); + + return + GenericSerializer.TryCreateAbstractCollectionSerializer( context, typeof( T ), concreteType, schema ) as MessagePackSerializer + ?? CreateReflectionInternal( context, concreteType ?? typeof( T ), schema ); #if FEATURE_EMIT - } } - return ( MessagePackSerializer ) builder.BuildSerializerInstance( context, concreteType, schema == null ? null : schema.FilterSelf() ); + return ( MessagePackSerializer )builder.BuildSerializerInstance( context, concreteType, schema == null ? null : schema.FilterSelf() ); #endif // FEATURE_EMIT } @@ -556,7 +545,7 @@ internal static MessagePackSerializer CreateInternal( SerializationContext conte } #endif // AOT - internal static MessagePackSerializer CreateReflectionInternal( SerializationContext context, Type concreteType, PolymorphismSchema schema ) + private static MessagePackSerializer CreateReflectionInternal( SerializationContext context, Type concreteType, PolymorphismSchema schema ) { if ( concreteType.GetIsAbstract() || concreteType.GetIsInterface() ) { @@ -585,7 +574,7 @@ internal static MessagePackSerializer CreateReflectionInternal( Serializat case CollectionKind.Array: case CollectionKind.Map: { - return + return #if !UNITY ReflectionSerializerHelper.CreateCollectionSerializer( context, concreteType, traits, ( schema ?? PolymorphismSchema.Default ) ); #else diff --git a/src/MsgPack/Serialization/Metadata/_IEnumreator.cs b/src/MsgPack/Serialization/Metadata/_IEnumreator.cs index d6e88037a..7c13a9d59 100644 --- a/src/MsgPack/Serialization/Metadata/_IEnumreator.cs +++ b/src/MsgPack/Serialization/Metadata/_IEnumreator.cs @@ -22,11 +22,11 @@ using System.Collections; using System.Collections.Generic; #if DEBUG -#if NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // NETSTANDARD1_1 +#endif // NETSTANDARD1_3 #endif // DEBUG using System.Reflection; diff --git a/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.cs b/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.cs index 9c0985215..0717fef3c 100644 --- a/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.cs +++ b/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.cs @@ -20,11 +20,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || NETSTANDARD1_1 +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || NETSTANDARD1_1 +#endif // NETSTANDARD1_3 using System.Reflection; namespace MsgPack.Serialization.Metadata diff --git a/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.tt b/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.tt index f904b55e4..522d94d13 100644 --- a/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.tt +++ b/src/MsgPack/Serialization/Metadata/_UnpackHelpers.direct.tt @@ -40,11 +40,11 @@ Type[] _valueTypes = using System; using System.Collections.Generic; -#if CORE_CLR +#if NETSTANDARD1_3 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR +#endif // NETSTANDARD1_3 using System.Reflection; namespace MsgPack.Serialization.Metadata diff --git a/src/MsgPack/Serialization/PackHelpers.cs b/src/MsgPack/Serialization/PackHelpers.cs index ebf4996b3..a11f5d28b 100644 --- a/src/MsgPack/Serialization/PackHelpers.cs +++ b/src/MsgPack/Serialization/PackHelpers.cs @@ -32,11 +32,11 @@ #if !UNITY || MSGPACK_UNITY_FULL using System.ComponentModel; #endif //!UNITY || MSGPACK_UNITY_FULL -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #if FEATURE_TAP using System.Threading; using System.Threading.Tasks; diff --git a/src/MsgPack/Serialization/Polymorphic/RuntimeTypeVerifier.cs b/src/MsgPack/Serialization/Polymorphic/RuntimeTypeVerifier.cs index 3eeec3dc5..004f34d13 100644 --- a/src/MsgPack/Serialization/Polymorphic/RuntimeTypeVerifier.cs +++ b/src/MsgPack/Serialization/Polymorphic/RuntimeTypeVerifier.cs @@ -29,11 +29,11 @@ using System; using System.Collections.Generic; #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT using System.Globalization; using System.Reflection; diff --git a/src/MsgPack/Serialization/Polymorphic/TypeInfoEncoder.cs b/src/MsgPack/Serialization/Polymorphic/TypeInfoEncoder.cs index 24dcee2bd..95fbab4dc 100644 --- a/src/MsgPack/Serialization/Polymorphic/TypeInfoEncoder.cs +++ b/src/MsgPack/Serialization/Polymorphic/TypeInfoEncoder.cs @@ -340,7 +340,7 @@ private static void ThrowEncodedTypeDoesNotHaveValidArrayItems() private static AssemblyName BuildAssemblyName( string assemblySimpleName, byte[] version, string culture, byte[] publicKeyToken ) { -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE var assemblyName = new AssemblyName { @@ -380,7 +380,7 @@ private static AssemblyName BuildAssemblyName( string assemblySimpleName, byte[] ( publicKeyToken == null || publicKeyToken.Length == 0 ) ? "null" : Binary.ToHexString( publicKeyToken, false ) ) ); -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE } private static string DecompressTypeName( string assemblySimpleName, string compressedTypeName ) @@ -401,9 +401,9 @@ private static Type LoadDecodedType( AssemblyName assemblyName, string typeFullN #endif // SILVERLIGHT ).GetType( typeFullName -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE , throwOnError: true -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE ); } diff --git a/src/MsgPack/Serialization/PolymorphicTypeVerificationContext.cs b/src/MsgPack/Serialization/PolymorphicTypeVerificationContext.cs index 0a18e361b..635b9281e 100644 --- a/src/MsgPack/Serialization/PolymorphicTypeVerificationContext.cs +++ b/src/MsgPack/Serialization/PolymorphicTypeVerificationContext.cs @@ -28,11 +28,11 @@ using System; #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT using System.Reflection; diff --git a/src/MsgPack/Serialization/PolymorphismSchema.Internals.cs b/src/MsgPack/Serialization/PolymorphismSchema.Internals.cs index 24165b3f4..ecda780d8 100644 --- a/src/MsgPack/Serialization/PolymorphismSchema.Internals.cs +++ b/src/MsgPack/Serialization/PolymorphismSchema.Internals.cs @@ -26,11 +26,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; using System.Linq; using System.Reflection; diff --git a/src/MsgPack/Serialization/PolymorphismSchema.cs b/src/MsgPack/Serialization/PolymorphismSchema.cs index 6368c64e4..58984223b 100644 --- a/src/MsgPack/Serialization/PolymorphismSchema.cs +++ b/src/MsgPack/Serialization/PolymorphismSchema.cs @@ -174,7 +174,7 @@ private PolymorphismSchema TryGetKeySchema() } } -#if NETFX_35 || NETFX_40 || SILVERLIGHT || UNITY || CORE_CLR || NETSTANDARD1_1 +#if NETFX_35 || NETFX_40 || SILVERLIGHT || UNITY || NETFX_CORE || NETSTANDARD1_1 private sealed class ReadOnlyDictionary : IDictionary { private readonly IDictionary _underlying; @@ -268,6 +268,6 @@ bool ICollection>.Remove( KeyValuePair throw new NotSupportedException(); } } -#endif // NETFX_35 || NETFX_40 || SILVERLIGHT || UNITY +#endif // NETFX_35 || NETFX_40 || SILVERLIGHT || UNITY || NETFX_CORE || NETSTANDARD1_1 } } \ No newline at end of file diff --git a/src/MsgPack/Serialization/Reflection/GenericTypeExtensions.cs b/src/MsgPack/Serialization/Reflection/GenericTypeExtensions.cs index ed108316b..8beea5e0d 100644 --- a/src/MsgPack/Serialization/Reflection/GenericTypeExtensions.cs +++ b/src/MsgPack/Serialization/Reflection/GenericTypeExtensions.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Linq; #if NETFX_CORE using System.Reflection; diff --git a/src/MsgPack/Serialization/Reflection/ReflectionExtensions.cs b/src/MsgPack/Serialization/Reflection/ReflectionExtensions.cs index d7347d31c..6ba934ca5 100644 --- a/src/MsgPack/Serialization/Reflection/ReflectionExtensions.cs +++ b/src/MsgPack/Serialization/Reflection/ReflectionExtensions.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Reflection; using System.Text; diff --git a/src/MsgPack/Serialization/Reflection/TracingILGenerator.conveniences.cs b/src/MsgPack/Serialization/Reflection/TracingILGenerator.conveniences.cs index 879486341..fbf84cc6d 100644 --- a/src/MsgPack/Serialization/Reflection/TracingILGenerator.conveniences.cs +++ b/src/MsgPack/Serialization/Reflection/TracingILGenerator.conveniences.cs @@ -18,6 +18,8 @@ // #endregion -- License Terms -- +#if !AOT + using System; #if NETSTANDARD1_1 using Contract = MsgPack.MPContract; @@ -1023,3 +1025,4 @@ public void EmitThrowNewExceptionWithInnerException( Type exceptionType ) #endif // DEBUG } } +#endif // !AOT diff --git a/src/MsgPack/Serialization/Reflection/TracingILGenerator.cs b/src/MsgPack/Serialization/Reflection/TracingILGenerator.cs index 4d5da4114..e32f08ed4 100644 --- a/src/MsgPack/Serialization/Reflection/TracingILGenerator.cs +++ b/src/MsgPack/Serialization/Reflection/TracingILGenerator.cs @@ -21,6 +21,8 @@ // #endregion -- License Terms -- +#if !AOT + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -1443,3 +1445,5 @@ private void Unindent() #endregion } } + +#endif // !AOT diff --git a/src/MsgPack/Serialization/Reflection/TracingILGenerator.emits.cs b/src/MsgPack/Serialization/Reflection/TracingILGenerator.emits.cs index c7f9c205c..2515a25db 100644 --- a/src/MsgPack/Serialization/Reflection/TracingILGenerator.emits.cs +++ b/src/MsgPack/Serialization/Reflection/TracingILGenerator.emits.cs @@ -18,6 +18,7 @@ // #endregion -- License Terms -- +#if !AOT // This code is generated from T4Template TracingILGenerator.emits.tt. // Do not modify this source code directly. @@ -3603,3 +3604,4 @@ public void EmitRefanytype() #endif // DEBUG } } +#endif // !AOT \ No newline at end of file diff --git a/src/MsgPack/Serialization/ReflectionExtensions.CollectionTraits.cs b/src/MsgPack/Serialization/ReflectionExtensions.CollectionTraits.cs index 5ff9378f4..8ec825558 100644 --- a/src/MsgPack/Serialization/ReflectionExtensions.CollectionTraits.cs +++ b/src/MsgPack/Serialization/ReflectionExtensions.CollectionTraits.cs @@ -28,11 +28,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Linq; using System.Reflection; @@ -775,17 +775,17 @@ public static bool GetIsPublic( this MemberInfo source ) PropertyInfo asProperty; FieldInfo asField; MethodBase asMethod; -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE Type asType; -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE if ( ( asProperty = source as PropertyInfo ) != null ) { -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE return asProperty.GetAccessors( true ).Where( a => a.ReturnType != typeof( void ) ).All( a => a.IsPublic ); #else return ( asProperty.GetMethod == null || asProperty.GetMethod.IsPublic ); -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE } else if ( ( asField = source as FieldInfo ) != null ) { @@ -795,12 +795,12 @@ public static bool GetIsPublic( this MemberInfo source ) { return asMethod.IsPublic; } -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE else if ( ( asType = source as Type ) != null ) { return asType.IsPublic; } -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE else { throw new NotSupportedException( source.GetType() + " is not supported." ); diff --git a/src/MsgPack/Serialization/ReflectionExtensions.ConstructorDelegate.cs b/src/MsgPack/Serialization/ReflectionExtensions.ConstructorDelegate.cs index edb877716..be01047c8 100644 --- a/src/MsgPack/Serialization/ReflectionExtensions.ConstructorDelegate.cs +++ b/src/MsgPack/Serialization/ReflectionExtensions.ConstructorDelegate.cs @@ -18,6 +18,13 @@ // #endregion -- License Terms -- +#if UNITY_5 || UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_WII || UNITY_IPHONE || UNITY_ANDROID || UNITY_PS3 || UNITY_XBOX360 || UNITY_FLASH || UNITY_BKACKBERRY || UNITY_WINRT +#define UNITY +#define AOT +#endif + +#if !AOT + using System; using System.Reflection; using System.Reflection.Emit; @@ -64,4 +71,5 @@ private static object CreateDelegate( Type delegateType, Type targetType, Constr return dynamicMethod.CreateDelegate( delegateType ); } } -} \ No newline at end of file +} +#endif // !AOT diff --git a/src/MsgPack/Serialization/ReflectionExtensions.cs b/src/MsgPack/Serialization/ReflectionExtensions.cs index e6e5dec74..81a59e1b9 100644 --- a/src/MsgPack/Serialization/ReflectionExtensions.cs +++ b/src/MsgPack/Serialization/ReflectionExtensions.cs @@ -26,11 +26,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; using System.Reflection; diff --git a/src/MsgPack/Serialization/ReflectionHelpers.cs b/src/MsgPack/Serialization/ReflectionHelpers.cs index bd456bdfe..567db0599 100644 --- a/src/MsgPack/Serialization/ReflectionHelpers.cs +++ b/src/MsgPack/Serialization/ReflectionHelpers.cs @@ -28,11 +28,11 @@ using System; using System.Linq; -#if UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #if !UNITY || MSGPACK_UNITY_FULL using System.ComponentModel; #endif //!UNITY || MSGPACK_UNITY_FULL diff --git a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs index f035a9cb6..e8cf17fe6 100644 --- a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs +++ b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs @@ -28,11 +28,11 @@ using System; using System.Collections; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Linq; using System.Reflection; #if FEATURE_TAP diff --git a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionSerializerHelper.cs b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionSerializerHelper.cs index 869d76251..383446588 100644 --- a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionSerializerHelper.cs +++ b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionSerializerHelper.cs @@ -30,11 +30,11 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Reflection; using System.Runtime.Serialization; diff --git a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionTupleMessagePackSerializer`1.cs b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionTupleMessagePackSerializer`1.cs index 1332720f1..251997c94 100644 --- a/src/MsgPack/Serialization/ReflectionSerializers/ReflectionTupleMessagePackSerializer`1.cs +++ b/src/MsgPack/Serialization/ReflectionSerializers/ReflectionTupleMessagePackSerializer`1.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Linq; using System.Reflection; #if FEATURE_TAP diff --git a/src/MsgPack/Serialization/ResolveSerializerEventArgs.cs b/src/MsgPack/Serialization/ResolveSerializerEventArgs.cs index 69c6e0f13..850f87dc8 100644 --- a/src/MsgPack/Serialization/ResolveSerializerEventArgs.cs +++ b/src/MsgPack/Serialization/ResolveSerializerEventArgs.cs @@ -24,11 +24,11 @@ using System; #if DEBUG -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // DEBUG using System.Globalization; diff --git a/src/MsgPack/Serialization/SerializationContext.cs b/src/MsgPack/Serialization/SerializationContext.cs index cc7065c85..6bd1811e1 100644 --- a/src/MsgPack/Serialization/SerializationContext.cs +++ b/src/MsgPack/Serialization/SerializationContext.cs @@ -32,11 +32,11 @@ #else // !FEATURE_CONCURRENT using System.Collections.Generic; #endif // !SILVERLIGHT && !NETFX_35 && !UNITY -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #if UNITY || NETSTANDARD1_1 || NETSTANDARD1_3 using System.Linq; #endif // UNITY || NETSTANDARD1_1 || NETSTANDARD1_3 @@ -654,23 +654,11 @@ public MessagePackSerializer GetSerializer( object providerParameter ) if ( serializer == null ) { -#if !AOT - if ( this._serializerGeneratorOptions.DisableRuntimeCodeGeneration ) - { -#endif // AOT - // On debugging, or AOT only envs, use reflection based aproach. - serializer = - this.GetSerializerWithoutGeneration( schema ) - ?? this.OnResolveSerializer( schema ) - ?? MessagePackSerializer.CreateReflectionInternal( this, this.EnsureConcreteTypeRegistered( typeof( T ) ), schema ); -#if !AOT - } - else - { - // This thread creating new type serializer. - serializer = this.OnResolveSerializer( schema ) ?? MessagePackSerializer.CreateInternal( this, schema ); - } -#endif // !AOT + // This thread creating new type serializer. + serializer = + this.GetSerializerWithoutGeneration( schema ) + ?? this.OnResolveSerializer( schema ) + ?? MessagePackSerializer.CreateInternal( this, schema ); } } else @@ -929,7 +917,7 @@ public MessagePackSerializer Get( SerializationContext context, Type targetType, #endif // !FEATURE_CONCURRENT if ( !this._cache.TryGetValue( targetType.TypeHandle, out func ) || func == null ) { -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE func = Delegate.CreateDelegate( typeof( Func ), @@ -940,7 +928,7 @@ public MessagePackSerializer Get( SerializationContext context, Type targetType, typeof( SerializerGetter<> ).MakeGenericType( targetType ).GetMethod( "Get" ).CreateDelegate( typeof( Func ) ) as Func; -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE Contract.Assert( func != null, "func != null" ); @@ -959,7 +947,7 @@ public MessagePackSerializer Get( SerializationContext context, Type targetType, private static class SerializerGetter { private static readonly Func> _func = -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !WINDOWS_PHONE && !UNITY && !XAMARIN +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !WINDOWS_PHONE && !UNITY && !XAMARIN && !NETFX_CORE Delegate.CreateDelegate( typeof( Func> ), Metadata._SerializationContext.GetSerializer1_Parameter_Method.MakeGenericMethod( typeof( T ) ) @@ -973,7 +961,7 @@ private static class SerializerGetter .MakeGenericMethod( typeof( T ) ).CreateDelegate( typeof( Func> ) ) as Func>; -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !WINDOWS_PHONE && !UNITY && !XAMARIN +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !WINDOWS_PHONE && !UNITY && !XAMARIN && !NETFX_CORE // ReSharper disable UnusedMember.Local // This method is invoked via Reflection on SerializerGetter.Get(). diff --git a/src/MsgPack/Serialization/SerializationExceptions.cs b/src/MsgPack/Serialization/SerializationExceptions.cs index 3576bad95..bae5bd935 100644 --- a/src/MsgPack/Serialization/SerializationExceptions.cs +++ b/src/MsgPack/Serialization/SerializationExceptions.cs @@ -27,11 +27,11 @@ #if !UNITY || MSGPACK_UNITY_FULL using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; #if !UNITY using System.Reflection; diff --git a/src/MsgPack/Serialization/SerializationTarget.cs b/src/MsgPack/Serialization/SerializationTarget.cs index dd7fcb8ca..522940c78 100644 --- a/src/MsgPack/Serialization/SerializationTarget.cs +++ b/src/MsgPack/Serialization/SerializationTarget.cs @@ -31,11 +31,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; using System.Linq; using System.Reflection; @@ -238,7 +238,7 @@ private static MemberInfo[] GetDistinctMembers( Type type ) while ( type != typeof( object ) && type != null ) { var members = -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE type.FindMembers( MemberTypes.Field | MemberTypes.Property, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly, @@ -248,7 +248,7 @@ private static MemberInfo[] GetDistinctMembers( Type type ) #else type.GetTypeInfo().DeclaredFields.Where( f => !f.IsStatic ).OfType() .Concat( type.GetTypeInfo().DeclaredProperties.Where( p => p.GetMethod != null && !p.GetMethod.IsStatic ) ); -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE foreach ( var memberInfo in members ) { if ( returningMemberNamesSet.Add( memberInfo.Name ) ) //HashSet returns true is new key was added @@ -712,12 +712,12 @@ public static string GetTupleItemNameFromIndex( int i ) } #endif // !NETFX_35 -#if !SILVERLIGHT && !AOT && !NETSTANDARD1_1 && !NETSTANDARD1_3 - public static bool BuiltInSerializerExists( ISerializerGeneratorConfiguration configuration, Type type, CollectionTraits traits ) +#if !SILVERLIGHT && !AOT + public static bool BuiltInSerializerExists( Type type, CollectionTraits traits, bool preferReflectionBasedSerializer ) { - return GenericSerializer.IsSupported( type, traits, configuration.PreferReflectionBasedSerializer ) || SerializerRepository.InternalDefault.ContainsFor( type ); + return GenericSerializer.IsSupported( type, traits, preferReflectionBasedSerializer ) || SerializerRepository.InternalDefault.ContainsFor( type ); } -#endif // !SILVERLIGHT && !AOT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !AOT private sealed class MemberConstructorParameterEqualityComparer : EqualityComparer> { diff --git a/src/MsgPack/Serialization/SerializerCodeInformation.cs b/src/MsgPack/Serialization/SerializerCodeInformation.cs index 8d053888e..ddb02ce14 100644 --- a/src/MsgPack/Serialization/SerializerCodeInformation.cs +++ b/src/MsgPack/Serialization/SerializerCodeInformation.cs @@ -102,7 +102,7 @@ internal SerializerCodeInformation( string typeFullName, string directory, strin /// public void SetFileWriter( string path ) { - this.TextWriter = new StreamWriter( path, false, Encoding.UTF8 ); + this.TextWriter = File.CreateText( path ); this.FilePath = Path.GetFullPath( path ); } diff --git a/src/MsgPack/Serialization/SerializerDebugging.cs b/src/MsgPack/Serialization/SerializerDebugging.cs index ad49a6d9b..bcbdbb0f5 100644 --- a/src/MsgPack/Serialization/SerializerDebugging.cs +++ b/src/MsgPack/Serialization/SerializerDebugging.cs @@ -26,17 +26,19 @@ #define AOT #endif +#warning This class should exist in DEBUG build only, and should be public and then RuntimeGeneration and CodeGeneration should not depend InternalsVisibleTo + using System; #if !NETFX_35 && !UNITY && !WINDOWS_PHONE using System.Collections.Concurrent; #endif // !NETFX_35 && !UNITY && !WINDOWS_PHONE using System.Collections.Generic; using System.Diagnostics; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; using System.IO; using System.Linq; @@ -240,6 +242,8 @@ public static void PrepareDump() _assemblyBuilder.DefineDynamicModule( "ExpressionTreeSerializerLogics", "ExpressionTreeSerializerLogics.dll", true ); } +#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 + #if !FERATURE_CONCURRENT private static volatile DependentAssemblyManager _dependentAssemblyManager = DependentAssemblyManager.Default; @@ -313,6 +317,8 @@ public static bool OnTheFlyCodeGenerationEnabled set { _onTheFlyCodeDomEnabled = value; } } +#if !NETSTANDARD1_1 && !NETSTANDARD1_3 + /// /// Creates the new type builder for the serializer. /// @@ -416,7 +422,6 @@ internal static void EnsureNaiveAsyncAllowed( object source, [CallerMemberName]s #endif // DEBUG && FEATURE_TAP -#if !NETSTANDARD1_1 && !NETSTANDARD1_3 [ThreadStatic] private static StringWriter _codeWriter; @@ -460,7 +465,6 @@ public static void SetCodeCompiler( CodeCompiler codeCompiler ) } public delegate void CodeCompiler( string code, bool isDebug, out Assembly compiledAssembly, out IList errors, out IList warnings ); -#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3 #endif // DEBUG } } \ No newline at end of file diff --git a/src/MsgPack/Serialization/SerializerGenerator.cs b/src/MsgPack/Serialization/SerializerGenerator.cs index d998dc793..36f38cd17 100644 --- a/src/MsgPack/Serialization/SerializerGenerator.cs +++ b/src/MsgPack/Serialization/SerializerGenerator.cs @@ -24,7 +24,11 @@ using System; using System.CodeDom; using System.Collections.Generic; +#if NETSTANDARD1_7 +using Contract = MsgPack.MPContract; +#else using System.Diagnostics.Contracts; +#endif // NETSTANDARD1_7 using System.Globalization; using System.IO; using System.Linq; @@ -59,6 +63,8 @@ namespace MsgPack.Serialization /// public class SerializerGenerator { +#if !NETSTANDARD1_7 + /// /// Gets the type of the root object which will be serialized/deserialized. /// @@ -285,6 +291,9 @@ public static IEnumerable GenerateSerializerCode { return new SerializerAssemblyGenerationLogic().Generate( targetTypes, configuration ); } + +#endif // !NETSTANDARD1_7 + /// /// Generates source codes which implement auto-generated serializer types for specified types with default configuration. /// @@ -444,7 +453,9 @@ public IEnumerable Generate( IEnumerable t #if !NETFX_35 WithAsync = configuration.WithAsync, #endif // !NETFX_35 +#if !NETSTANDARD1_7 GeneratorOption = SerializationMethodGeneratorOption.CanDump, +#endif // !NETSTANDARD1_7 EmitterFlavor = this.EmitterFlavor }, EnumSerializationOptions = @@ -471,7 +482,7 @@ public IEnumerable Generate( IEnumerable t { realTargetTypes = targetTypes - .Where( t => !SerializationTarget.BuiltInSerializerExists( configuration, t, t.GetCollectionTraits( CollectionTraitOptions.None, context.CompatibilityOptions.AllowNonCollectionEnumerableTypes ) ) ); + .Where( t => !SerializationTarget.BuiltInSerializerExists( t, t.GetCollectionTraits( CollectionTraitOptions.None, context.CompatibilityOptions.AllowNonCollectionEnumerableTypes ), configuration.PreferReflectionBasedSerializer ) ); } var generationContext = this.CreateGenerationContext( context, configuration ); @@ -497,7 +508,7 @@ public IEnumerable Generate( IEnumerable t private static IEnumerable ExtractElementTypes( SerializationContext context, ISerializerGeneratorConfiguration configuration, Type type ) { - if ( !SerializationTarget.BuiltInSerializerExists( configuration, type, type.GetCollectionTraits( CollectionTraitOptions.None, context.CompatibilityOptions.AllowNonCollectionEnumerableTypes ) ) ) + if ( !SerializationTarget.BuiltInSerializerExists( type, type.GetCollectionTraits( CollectionTraitOptions.None, context.CompatibilityOptions.AllowNonCollectionEnumerableTypes ), configuration.PreferReflectionBasedSerializer ) ) { yield return type; @@ -518,7 +529,7 @@ var dependentType in if ( type.IsArray ) { var elementType = type.GetElementType(); - if ( !SerializationTarget.BuiltInSerializerExists( configuration, elementType, elementType.GetCollectionTraits( CollectionTraitOptions.None, allowNonCollectionEnumerableTypes: false ) ) ) + if ( !SerializationTarget.BuiltInSerializerExists( elementType, elementType.GetCollectionTraits( CollectionTraitOptions.None, allowNonCollectionEnumerableTypes: false ), configuration.PreferReflectionBasedSerializer ) ) { foreach ( var descendant in ExtractElementTypes( context, configuration, elementType ) ) { @@ -552,6 +563,7 @@ var dependentType in protected abstract Func CreateGeneratorFactory( SerializationContext context ); } +#if !NETSTANDARD1_7 private sealed class SerializerAssemblyGenerationLogic : SerializerGenerationLogic { protected override EmitterFlavor EmitterFlavor @@ -581,6 +593,7 @@ protected override Func CreateGeneratorFactory( return type => new AssemblyBuilderSerializerBuilder( type, type.GetCollectionTraits( CollectionTraitOptions.Full, context.CompatibilityOptions.AllowNonCollectionEnumerableTypes ) ); } } +#endif // !NETSTANDARD1_7 private sealed class SerializerCodesGenerationLogic : SerializerGenerationLogic { diff --git a/src/MsgPack/Serialization/SerializerOptions.cs b/src/MsgPack/Serialization/SerializerOptions.cs index c8f3200c5..aad30a9e8 100644 --- a/src/MsgPack/Serialization/SerializerOptions.cs +++ b/src/MsgPack/Serialization/SerializerOptions.cs @@ -25,11 +25,11 @@ using System; using System.Threading; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 namespace MsgPack.Serialization { diff --git a/src/MsgPack/Serialization/SerializerTypeKeyRepository.cs b/src/MsgPack/Serialization/SerializerTypeKeyRepository.cs index 2700efe67..71c36950c 100644 --- a/src/MsgPack/Serialization/SerializerTypeKeyRepository.cs +++ b/src/MsgPack/Serialization/SerializerTypeKeyRepository.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #if !NETFX_35 && !UNITY using System.Security; #endif // !NETFX_35 && !UNITY diff --git a/src/MsgPack/Serialization/SerializingMember.cs b/src/MsgPack/Serialization/SerializingMember.cs index 50a8b955e..c0c916c96 100644 --- a/src/MsgPack/Serialization/SerializingMember.cs +++ b/src/MsgPack/Serialization/SerializingMember.cs @@ -24,11 +24,11 @@ using System; using System.Globalization; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using MPContract = MsgPack.MPContract; #else using MPContract = System.Diagnostics.Contracts.Contract; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Reflection; namespace MsgPack.Serialization @@ -80,7 +80,7 @@ public SerializingMember( string name ) public EnumMemberSerializationMethod GetEnumMemberSerializationMethod() { -#if NETSTANDARD1_1 || NETSTANDARD1_3 +#if NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE var messagePackEnumMemberAttribute = this.Member.GetCustomAttribute(); if ( messagePackEnumMemberAttribute != null) @@ -94,7 +94,7 @@ public EnumMemberSerializationMethod GetEnumMemberSerializationMethod() return // ReSharper disable once PossibleNullReferenceException ( messagePackEnumMemberAttributes[ 0 ] as MessagePackEnumMemberAttribute ).SerializationMethod; -#endif // NETSTANDARD1_1 || NETSTANDARD1_3 +#endif // NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE } return EnumMemberSerializationMethod.Default; @@ -102,7 +102,7 @@ public EnumMemberSerializationMethod GetEnumMemberSerializationMethod() public DateTimeMemberConversionMethod GetDateTimeMemberConversionMethod() { -#if NETSTANDARD1_1 || NETSTANDARD1_3 +#if NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE var messagePackDateTimeMemberAttribute = this.Member.GetCustomAttribute(); if ( messagePackDateTimeMemberAttribute != null) @@ -116,7 +116,7 @@ public DateTimeMemberConversionMethod GetDateTimeMemberConversionMethod() return // ReSharper disable once PossibleNullReferenceException ( messagePackDateTimeMemberAttribute[ 0 ] as MessagePackDateTimeMemberAttribute ).DateTimeConversionMethod; -#endif // NETSTANDARD1_1 || NETSTANDARD1_3 +#endif // NETSTANDARD1_1 || NETSTANDARD1_3 || NETFX_CORE } return DateTimeMemberConversionMethod.Default; diff --git a/src/MsgPack/Serialization/Tracer.cs b/src/MsgPack/Serialization/Tracer.cs index 191930bd5..bad58fcda 100644 --- a/src/MsgPack/Serialization/Tracer.cs +++ b/src/MsgPack/Serialization/Tracer.cs @@ -18,6 +18,8 @@ // #endregion -- License Terms -- +#if !AOT + using System; using System.Diagnostics; #if NETSTANDARD1_1 || NETSTANDARD1_3 @@ -89,3 +91,4 @@ public void TraceData( TraceEventType eventType, int id, object data ) } #endif // NETSTANDARD1_1 || NETSTANDARD1_3 } +#endif // !AOT diff --git a/src/MsgPack/Serialization/TypeKeyRepository.cs b/src/MsgPack/Serialization/TypeKeyRepository.cs index 70d0c6f8a..62b1a660e 100644 --- a/src/MsgPack/Serialization/TypeKeyRepository.cs +++ b/src/MsgPack/Serialization/TypeKeyRepository.cs @@ -25,11 +25,11 @@ using System; using System.Collections.Generic; using System.Linq; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #if NETFX_CORE using System.Reflection; #endif @@ -83,12 +83,12 @@ public TypeKeyRepository( Dictionary table ) private Dictionary GetClonedTable() { bool holdsReadLock = false; -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); #endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 try { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); #endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 try { } @@ -122,14 +122,14 @@ public bool Get( Type type, out object matched, out object genericDefinitionMatc private bool GetCore( Type type, out object matched, out object genericDefinitionMatched ) { bool holdsReadLock = false; -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { } finally { @@ -187,14 +187,14 @@ private bool RegisterCore( Type key, object value, Type nullableType, object nul if ( allowOverwrite || !this.ContainsType( key, nullableType ) ) { bool holdsWriteLock = false; -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { } finally { @@ -254,14 +254,14 @@ private bool UnregisterCore( Type key ) if ( this._table.ContainsKey( key.TypeHandle ) ) { bool holdsWriteLock = false; -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { } finally { @@ -288,14 +288,14 @@ private bool UnregisterCore( Type key ) internal bool Contains( Type type ) { bool holdsReadLock = false; -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { } finally { @@ -319,14 +319,14 @@ internal bool Contains( Type type ) internal IEnumerable> GetEntries() { bool holdsReadLock = false; -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { -#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#if !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE RuntimeHelpers.PrepareConstrainedRegions(); -#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 +#endif // !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE try { } finally { diff --git a/src/MsgPack/Serialization/UnpackHelpers.cs b/src/MsgPack/Serialization/UnpackHelpers.cs index a130720c5..cc35fc6af 100644 --- a/src/MsgPack/Serialization/UnpackHelpers.cs +++ b/src/MsgPack/Serialization/UnpackHelpers.cs @@ -26,9 +26,9 @@ #define ASSERT #endif // DEBUG -#if DEBUG && !NETFX_CORE +#if DEBUG && !NETFX_CORE && !AOT #define TRACING -#endif // DEBUG && !NETFX_CORE +#endif // DEBUG && !NETFX_CORE && !AOT using System; using System.Collections; @@ -38,11 +38,11 @@ #endif //!UNITY || MSGPACK_UNITY_FULL using System.Diagnostics; #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT using System.Reflection; using System.Runtime.CompilerServices; @@ -1041,9 +1041,9 @@ private static void Trace( UnpackerTraceContext context, string label, Unpacker [Conditional( "TRACING" )] private static void TraceCore( string format, params object[] args ) { -#if !UNITY && !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !XAMARIN +#if !UNITY && !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !AOT Tracer.Tracing.TraceEvent( Tracer.EventType.Trace, Tracer.EventId.Trace, format, args ); -#endif // !UNITY && !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !XAMARIN +#endif // !UNITY && !SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !AOT } private sealed class UnpackerTraceContext diff --git a/src/MsgPack/Serialization/UnpackHelpers.direct.cs b/src/MsgPack/Serialization/UnpackHelpers.direct.cs index 467a217c2..07e464594 100644 --- a/src/MsgPack/Serialization/UnpackHelpers.direct.cs +++ b/src/MsgPack/Serialization/UnpackHelpers.direct.cs @@ -31,11 +31,11 @@ using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/Serialization/UnpackHelpers.direct.tt b/src/MsgPack/Serialization/UnpackHelpers.direct.tt index 12f7fe02c..d368099e0 100644 --- a/src/MsgPack/Serialization/UnpackHelpers.direct.tt +++ b/src/MsgPack/Serialization/UnpackHelpers.direct.tt @@ -41,11 +41,11 @@ using System; using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/Serialization/UnpackHelpers.facade.cs b/src/MsgPack/Serialization/UnpackHelpers.facade.cs index 0d14bdf5f..9849cd674 100644 --- a/src/MsgPack/Serialization/UnpackHelpers.facade.cs +++ b/src/MsgPack/Serialization/UnpackHelpers.facade.cs @@ -33,11 +33,11 @@ using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/Serialization/UnpackHelpers.facade.tt b/src/MsgPack/Serialization/UnpackHelpers.facade.tt index abab4d828..7f381f112 100644 --- a/src/MsgPack/Serialization/UnpackHelpers.facade.tt +++ b/src/MsgPack/Serialization/UnpackHelpers.facade.tt @@ -42,11 +42,11 @@ using System.Collections.Generic; using System.ComponentModel; #endif // !UNITY || MSGPACK_UNITY_FULL #if ASSERT -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 #endif // ASSERT #if FEATURE_TAP using System.Threading; diff --git a/src/MsgPack/SetOperation.cs b/src/MsgPack/SetOperation.cs index 67d2f0f34..0979b042b 100644 --- a/src/MsgPack/SetOperation.cs +++ b/src/MsgPack/SetOperation.cs @@ -25,11 +25,11 @@ #if !UNITY using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Linq; diff --git a/src/MsgPack/SubtreeUnpacker.cs b/src/MsgPack/SubtreeUnpacker.cs index 3e65bee47..fa4439ca0 100644 --- a/src/MsgPack/SubtreeUnpacker.cs +++ b/src/MsgPack/SubtreeUnpacker.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 #if FEATURE_TAP using System.Threading; using System.Threading.Tasks; diff --git a/src/MsgPack/TupleItems.cs b/src/MsgPack/TupleItems.cs index 616804a27..26cb84675 100644 --- a/src/MsgPack/TupleItems.cs +++ b/src/MsgPack/TupleItems.cs @@ -25,11 +25,11 @@ #if !UNITY using System; using System.Collections.Generic; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Linq; #if NETFX_CORE using System.Reflection; diff --git a/src/MsgPack/Unpacking.Numerics.cs b/src/MsgPack/Unpacking.Numerics.cs index e617c644c..eae7da1cd 100644 --- a/src/MsgPack/Unpacking.Numerics.cs +++ b/src/MsgPack/Unpacking.Numerics.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.IO; namespace MsgPack diff --git a/src/MsgPack/Unpacking.Numerics.tt b/src/MsgPack/Unpacking.Numerics.tt index 43b3f2a54..47cfa7637 100644 --- a/src/MsgPack/Unpacking.Numerics.tt +++ b/src/MsgPack/Unpacking.Numerics.tt @@ -70,11 +70,11 @@ Func __isClsCompliant = #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.IO; namespace MsgPack diff --git a/src/MsgPack/Unpacking.Others.cs b/src/MsgPack/Unpacking.Others.cs index 37a6ad4d6..1487b1fa2 100644 --- a/src/MsgPack/Unpacking.Others.cs +++ b/src/MsgPack/Unpacking.Others.cs @@ -25,11 +25,11 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.IO; namespace MsgPack diff --git a/src/MsgPack/Unpacking.Others.tt b/src/MsgPack/Unpacking.Others.tt index 2e46145e6..3cf42cea1 100644 --- a/src/MsgPack/Unpacking.Others.tt +++ b/src/MsgPack/Unpacking.Others.tt @@ -70,11 +70,11 @@ var __methods = new [] using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.IO; namespace MsgPack diff --git a/src/MsgPack/Unpacking.Streaming.cs b/src/MsgPack/Unpacking.Streaming.cs index ffa345acb..08f61efed 100644 --- a/src/MsgPack/Unpacking.Streaming.cs +++ b/src/MsgPack/Unpacking.Streaming.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.IO; using System.Text; diff --git a/src/MsgPack/Unpacking.String.cs b/src/MsgPack/Unpacking.String.cs index f95d78471..b829b8e63 100644 --- a/src/MsgPack/Unpacking.String.cs +++ b/src/MsgPack/Unpacking.String.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.Globalization; using System.IO; using System.Text; diff --git a/src/MsgPack/UnpackingStream.cs b/src/MsgPack/UnpackingStream.cs index a1c9d5876..cec548a35 100644 --- a/src/MsgPack/UnpackingStream.cs +++ b/src/MsgPack/UnpackingStream.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // UNITY || NETSTANDARD1_1 using System.IO; namespace MsgPack diff --git a/src/MsgPack/Validation.cs b/src/MsgPack/Validation.cs index c887c97b0..7679c5185 100644 --- a/src/MsgPack/Validation.cs +++ b/src/MsgPack/Validation.cs @@ -23,11 +23,11 @@ #endif using System; -#if CORE_CLR || UNITY || NETSTANDARD1_1 +#if NETFX_CORE || UNITY || NETSTANDARD1_1 using Contract = MsgPack.MPContract; #else using System.Diagnostics.Contracts; -#endif // CORE_CLR || UNITY || NETSTANDARD1_1 +#endif // NETFX_CORE || UNITY || NETSTANDARD1_1 using System.Globalization; using System.Text.RegularExpressions;