Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/aspnet/MessagePack-CSharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Mikhisor <40904997+MaximMikhisor@users.noreply.github.com>2022-06-28 04:08:56 +0300
committerGitHub <noreply@github.com>2022-06-28 04:08:56 +0300
commit8ef5aec97ec309b0cda153d6735961542f034e4e (patch)
tree59fec9a4c92c7549a3a6625db1e93e03a23f4ecc
parent7a4a9ef9fbe1d8eb2b9139afa10e6d8f691ff976 (diff)
parent64ee45cdba4f8c06828107f3eca7ee919972c4ce (diff)
Merge pull request #1 from neuecc/master
Merging
-rw-r--r--Directory.Build.props8
-rw-r--r--README.md90
-rw-r--r--azure-pipelines.yml10
-rw-r--r--azure-pipelines/build_nonWindows.yml6
-rw-r--r--benchmark/SerializerBenchmark/SerializerBenchmark.csproj2
-rw-r--r--global.json2
-rw-r--r--sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj5
-rw-r--r--sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj4
-rw-r--r--sandbox/PerfNetFramework/PerfNetFramework.csproj4
-rw-r--r--sandbox/Sandbox/Generated.cs479
-rw-r--r--sandbox/Sandbox/Sandbox.csproj2
-rw-r--r--sandbox/Sandbox/codegen.ps12
-rw-r--r--sandbox/TestData2/A.cs15
-rw-r--r--sandbox/TestData2/B.cs17
-rw-r--r--sandbox/TestData2/C.cs16
-rw-r--r--sandbox/TestData2/Generated.cs102
-rw-r--r--sandbox/TestData2/TestData2.csproj6
-rw-r--r--sandbox/TestData2/codegen.ps12
-rw-r--r--src/MessagePack.Generator/MessagePack.Generator.csproj9
-rw-r--r--src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs14
-rw-r--r--src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs7
-rw-r--r--src/MessagePack.GeneratorCore/CodeGenerator.cs72
-rw-r--r--src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs26
-rw-r--r--src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt12
-rw-r--r--src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs15
-rw-r--r--src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt10
-rw-r--r--src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs17
-rw-r--r--src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt15
-rw-r--r--src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs28
-rw-r--r--src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt20
-rw-r--r--src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs41
-rw-r--r--src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt26
-rw-r--r--src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj5
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs46
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs61
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs.meta11
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/Sequence`1.cs120
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef3
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs2
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs38
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs68
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs6
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json2
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackSerializerOptionsTests.cs42
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackWriterTests.cs3
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StandardClassLibraryFormatterTests.cs57
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs107
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs.meta11
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/TestUtilities.cs2
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/Tests/Shims/XUnit.cs5
-rw-r--r--src/MessagePack.UnityClient/copy_assets.bat1
-rwxr-xr-xsrc/MessagePack.UnityClient/copy_assets.sh1
-rw-r--r--src/MessagePack/MessagePack.csproj17
-rw-r--r--src/MessagePack/net5.0/PublicAPI.Unshipped.txt6
-rw-r--r--src/MessagePack/net6.0/PublicAPI.Shipped.txt (renamed from src/MessagePack/netcoreapp2.1/PublicAPI.Shipped.txt)10
-rw-r--r--src/MessagePack/net6.0/PublicAPI.Unshipped.txt16
-rw-r--r--src/MessagePack/netcoreapp2.1/PublicAPI.Unshipped.txt0
-rw-r--r--src/MessagePack/netcoreapp3.1/PublicAPI.Unshipped.txt8
-rw-r--r--src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt8
-rw-r--r--tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj2
-rw-r--r--tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj2
-rw-r--r--tests/MessagePack.Tests/MessagePack.Tests.csproj6
-rwxr-xr-xtools/Install-DotNetSdk.ps125
-rw-r--r--version.json2
64 files changed, 1228 insertions, 549 deletions
diff --git a/Directory.Build.props b/Directory.Build.props
index 99d92e03..fc7c5f0f 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -28,10 +28,10 @@
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Visible="false" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
- <PackageReference Include="Nerdbank.GitVersioning" Version="3.2.7-beta" PrivateAssets="all" />
- <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.5.124-alpha" PrivateAssets="All" />
- <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
+ <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
+ <PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.0.64" PrivateAssets="All" />
+ <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.261" PrivateAssets="all" />
</ItemGroup>
diff --git a/README.md b/README.md
index 35ce5fd3..27af11f5 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@ MessagePack has a compact binary size and a full set of general purpose expressi
- [Security](#security)
- [Performance](#performance)
- [Deserialization Performance for different options](#deserialization-performance-for-different-options)
+ - [String interning](#string-interning)
- [LZ4 Compression](#lz4-compression)
- [Attributions](#attributions)
- [Comparison with protobuf, JSON, ZeroFormatter](#comparison-with-protobuf-json-zeroformatter)
@@ -699,7 +700,7 @@ Benchmarks comparing MessagePack For C# to other serializers were run on `Window
* Avoid string key decoding for lookup maps (string key and use automata based name lookup with inlined IL code generation, see: [AutomataDictionary](https://github.com/neuecc/MessagePack-CSharp/blob/bcedbce3fd98cb294210d6b4a22bdc4c75ccd916/src/MessagePack/Internal/AutomataDictionary.cs)
* To encode string keys, use pre-generated member name bytes and fixed sized byte array copies in IL, see: [UnsafeMemory.cs](https://github.com/neuecc/MessagePack-CSharp/blob/f17ddc5d107d3a2f66f60398b214ef87919ff892/src/MessagePack/Internal/UnsafeMemory.cs)
-Before creating this library, I implemented a fast fast serializer with [ZeroFormatter#Performance](https://github.com/neuecc/ZeroFormatter#performance). This is a further evolved implementation. MessagePack for C# is always fast and optimized for all types (primitive, small struct, large object, any collections).
+Before creating this library, I implemented a fast serializer with [ZeroFormatter#Performance](https://github.com/neuecc/ZeroFormatter#performance). This is a further evolved implementation. MessagePack for C# is always fast and optimized for all types (primitive, small struct, large object, any collections).
### <a name="deserialize-performance"></a>Deserialization Performance for different options
@@ -758,6 +759,49 @@ Extra note, this is serialization benchmark result.
Of course, `IntKey` is fastest but `StringKey` also performs reasonably well.
+### <a name="string-interning"></a>String interning
+
+The msgpack format does not provide for reusing strings in the data stream.
+This naturally leads the deserializer to create a new `string` object for every string encountered,
+even if it is equal to another string previously encountered.
+
+When deserializing data that may contain the same strings repeatedly it can be worthwhile
+to have the deserializer take a little extra time to check whether it has seen a given string before
+and reuse it if it has.
+
+To enable string interning on *all* string values, use a resolver that specifies `StringInterningFormatter`
+before any of the standard ones, like this:
+
+```cs
+var options = MessagePackSerializerOptions.Standard.WithResolver(
+ CompositeResolver.Create(
+ new IMessagePackFormatter[] { new StringInterningFormatter() },
+ new IFormatterResolver[] { StandardResolver.Instance }));
+
+MessagePackSerializer.Deserialize<ClassOfStrings>(data, options);
+```
+
+If you know which fields of a particular type are likely to contain duplicate strings,
+you can apply the string interning formatter to just those fields so the deserializer only pays
+for the interned string check where it matters most.
+Note that this technique requires a `[MessagePackObject]` or `[DataContract]` class.
+
+```cs
+[MessagePackObject]
+public class ClassOfStrings
+{
+ [Key(0)]
+ [MessagePackFormatter(typeof(StringInterningFormatter))]
+ public string InternedString { get; set; }
+
+ [Key(1)]
+ public string OrdinaryString { get; set; }
+}
+```
+
+If you are writing your own formatter for some type that contains strings,
+you can call on the `StringInterningFormatter` directly from your formatter as well for the strings.
+
## LZ4 Compression
MessagePack is a fast and *compact* format but it is not compression. [LZ4](https://github.com/lz4/lz4) is an extremely fast compression algorithm, and using it MessagePack for C# can achieve extremely fast performance as well as extremely compact binary sizes!
@@ -1452,24 +1496,36 @@ var resolver = MessagePack.Resolvers.CompositeResolver.Create(
## Reserved Extension Types
-MessagePack for C# already used some MessagePack extension type codes, be careful to use same ext code.
+MessagePack for C# already used some MessagePack extension type codes, be careful to avoid using the same ext code for other purposes.
+
+Range | Reserved for
+--|--
+\[-128, -1\] | Reserved by the msgpack spec for predefined types
+\[30, 120) | Reserved for this library's use to support common types in .NET
+
+This leaves the following ranges for your use:
+
+- \[0, 30)
+- \[120, 127]
+
+Within the *reserved* ranges, this library defines or implements extensions that use these type codes:
| Code | Type | Use by |
-| --- | --- | --- |
-| -1 | DateTime | MessagePack-spec reserved for timestamp |
-| 30 | Vector2[] | for Unity, UnsafeBlitFormatter |
-| 31 | Vector3[] | for Unity, UnsafeBlitFormatter |
-| 32 | Vector4[] | for Unity, UnsafeBlitFormatter |
-| 33 | Quaternion[] | for Unity, UnsafeBlitFormatter |
-| 34 | Color[] | for Unity, UnsafeBlitFormatter |
-| 35 | Bounds[] | for Unity, UnsafeBlitFormatter |
-| 36 | Rect[] | for Unity, UnsafeBlitFormatter |
-| 37 | Int[] | for Unity, UnsafeBlitFormatter |
-| 38 | Float[] | for Unity, UnsafeBlitFormatter |
-| 39 | Double[] | for Unity, UnsafeBlitFormatter |
-| 98 | All | MessagePackCompression.Lz4BlockArray |
-| 99 | All | MessagePackCompression.Lz4Block |
-| 100 | object | TypelessFormatter |
+| ---- | ---- | --- |
+| -1 | DateTime | MessagePack-spec reserved for timestamp |
+| 30 | Vector2[] | for Unity, UnsafeBlitFormatter |
+| 31 | Vector3[] | for Unity, UnsafeBlitFormatter |
+| 32 | Vector4[] | for Unity, UnsafeBlitFormatter |
+| 33 | Quaternion[] | for Unity, UnsafeBlitFormatter |
+| 34 | Color[] | for Unity, UnsafeBlitFormatter |
+| 35 | Bounds[] | for Unity, UnsafeBlitFormatter |
+| 36 | Rect[] | for Unity, UnsafeBlitFormatter |
+| 37 | Int[] | for Unity, UnsafeBlitFormatter |
+| 38 | Float[] | for Unity, UnsafeBlitFormatter |
+| 39 | Double[] | for Unity, UnsafeBlitFormatter |
+| 98 | All | MessagePackCompression.Lz4BlockArray |
+| 99 | All | MessagePackCompression.Lz4Block |
+| 100 | object | TypelessFormatter |
## Unity support
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 2c179114..d18997c3 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -19,7 +19,7 @@ stages:
jobs:
- job: Windows
pool:
- vmImage: windows-2019
+ vmImage: windows-2022
steps:
- checkout: self
clean: true
@@ -44,7 +44,7 @@ stages:
- job: Linux
pool:
- vmImage: Ubuntu 18.04
+ vmImage: ubuntu-20.04
steps:
- checkout: self
clean: true
@@ -53,7 +53,7 @@ stages:
- job: macOS
pool:
- vmImage: macOS-10.15
+ vmImage: macOS-11
steps:
- checkout: self
clean: true
@@ -64,7 +64,7 @@ stages:
# It also helps exercise mpc so bugs don't go unnoticed.
- job: codegen_diff
pool:
- vmImage: ubuntu-latest
+ vmImage: ubuntu-20.04
steps:
- checkout: self
clean: true
@@ -84,7 +84,7 @@ stages:
jobs:
- job: push
pool:
- vmImage: ubuntu-latest
+ vmImage: ubuntu-20.04
steps:
- download: current
artifact: nuget
diff --git a/azure-pipelines/build_nonWindows.yml b/azure-pipelines/build_nonWindows.yml
index 6b5ac10a..cf3f51d7 100644
--- a/azure-pipelines/build_nonWindows.yml
+++ b/azure-pipelines/build_nonWindows.yml
@@ -14,12 +14,12 @@ steps:
testRunTitle: netcoreapp3.1-$(Agent.JobName)
- task: DotNetCoreCLI@2
- displayName: Run MessagePack.Tests (net5.0)
+ displayName: Run MessagePack.Tests (net6.0)
inputs:
command: test
projects: tests/MessagePack.Tests/MessagePack.Tests.csproj
- arguments: --no-build -c $(BuildConfiguration) -f net5.0 -v n --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
- testRunTitle: net5.0-$(Agent.JobName)
+ arguments: --no-build -c $(BuildConfiguration) -f net6.0 -v n --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
+ testRunTitle: net6.0-$(Agent.JobName)
- bash: mono ~/.nuget/packages/xunit.runner.console/2.4.1/tools/net472/xunit.console.exe bin/MessagePack.Tests/$(BuildConfiguration)/net472/MessagePack.Tests.dll -html $(BUILD.ARTIFACTSTAGINGDIRECTORY)/build_logs/mono_testrun.html
displayName: Run MessagePack.Tests (mono)
diff --git a/benchmark/SerializerBenchmark/SerializerBenchmark.csproj b/benchmark/SerializerBenchmark/SerializerBenchmark.csproj
index 78d2ad21..b6be2ea0 100644
--- a/benchmark/SerializerBenchmark/SerializerBenchmark.csproj
+++ b/benchmark/SerializerBenchmark/SerializerBenchmark.csproj
@@ -20,7 +20,7 @@
<PackageReference Include="SpanJson" Version="3.0.1" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
<PackageReference Include="Utf8Json" Version="1.3.7" />
- <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
</ItemGroup>
diff --git a/global.json b/global.json
index 3057bb45..954a92e7 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "5.0.401",
+ "version": "6.0.300",
"rollForward": "patch",
"allowPrerelease": false
}
diff --git a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj
index f7f443f0..0daf9da4 100644
--- a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj
+++ b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj
@@ -143,8 +143,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Nerdbank.Streams" Version="2.4.48" />
- <PackageReference Include="System.Memory" Version="4.5.3" />
- <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
+ <PackageReference Include="Nerdbank.Streams" Version="2.8.57" />
+ <PackageReference Include="Microsoft.NET.StringTools" Version="1.0.0" />
</ItemGroup>
</Project>
diff --git a/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj b/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj
index 36fe6baf..6804253d 100644
--- a/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj
+++ b/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFrameworks>net472;net5.0</TargetFrameworks>
+ <TargetFrameworks>net472;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
@@ -19,7 +19,7 @@
<PackageReference Include="Jil" version="2.15.4" />
<PackageReference Include="MessagePack" version="1.4.3" />
<PackageReference Include="MsgPack.Cli" version="0.9.0-rc1" />
- <PackageReference Include="Nerdbank.Streams" Version="2.4.48" />
+ <PackageReference Include="Nerdbank.Streams" Version="2.8.57" />
<PackageReference Include="Newtonsoft.Json" version="10.0.3" />
<PackageReference Include="protobuf-net" version="2.3.2" />
<PackageReference Include="RandomFixtureKit" Version="1.0.0" />
diff --git a/sandbox/PerfNetFramework/PerfNetFramework.csproj b/sandbox/PerfNetFramework/PerfNetFramework.csproj
index 080b4fb7..57cbfd36 100644
--- a/sandbox/PerfNetFramework/PerfNetFramework.csproj
+++ b/sandbox/PerfNetFramework/PerfNetFramework.csproj
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFrameworks>net472;net5.0</TargetFrameworks>
+ <TargetFrameworks>net472;net6.0</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MsgPack.Cli" version="0.9.0-beta2" />
- <PackageReference Include="Nerdbank.Streams" Version="2.4.48" />
+ <PackageReference Include="Nerdbank.Streams" Version="2.8.57" />
<PackageReference Include="Newtonsoft.Json" version="10.0.3" />
<PackageReference Include="protobuf-net" version="2.1.0" />
<PackageReference Include="ZeroFormatter" version="1.6.4" />
diff --git a/sandbox/Sandbox/Generated.cs b/sandbox/Sandbox/Generated.cs
index 64f68f84..bc3bcd7a 100644
--- a/sandbox/Sandbox/Generated.cs
+++ b/sandbox/Sandbox/Generated.cs
@@ -6,15 +6,13 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Resolvers
{
- using System;
-
public class GeneratedResolver : global::MessagePack.IFormatterResolver
{
public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver();
@@ -45,11 +43,11 @@ namespace MessagePack.Resolvers
internal static class GeneratedResolverGetFormatterHelper
{
- private static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup;
+ private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> lookup;
static GeneratedResolverGetFormatterHelper()
{
- lookup = new global::System.Collections.Generic.Dictionary<Type, int>(72)
+ lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(72)
{
{ typeof(global::GlobalMyEnum[,]), 0 },
{ typeof(global::GlobalMyEnum[]), 1 },
@@ -126,7 +124,7 @@ namespace MessagePack.Resolvers
};
}
- internal static object GetFormatter(Type t)
+ internal static object GetFormatter(global::System.Type t)
{
int key;
if (!lookup.TryGetValue(t, out key))
@@ -220,7 +218,6 @@ namespace MessagePack.Resolvers
#pragma warning restore 612
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1649 // File name should match first type name
@@ -232,25 +229,22 @@ namespace MessagePack.Resolvers
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Formatters
{
- using System;
- using System.Buffers;
- using MessagePack;
public sealed class GlobalMyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::GlobalMyEnum>
{
- public void Serialize(ref MessagePackWriter writer, global::GlobalMyEnum value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::GlobalMyEnum value, global::MessagePack.MessagePackSerializerOptions options)
{
- writer.Write((Int32)value);
+ writer.Write((global::System.Int32)value);
}
- public global::GlobalMyEnum Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::GlobalMyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
return (global::GlobalMyEnum)reader.ReadInt32();
}
@@ -262,7 +256,6 @@ namespace MessagePack.Formatters
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
@@ -274,25 +267,22 @@ namespace MessagePack.Formatters
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Formatters.SharedData
{
- using System;
- using System.Buffers;
- using MessagePack;
public sealed class ByteEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.ByteEnum>
{
- public void Serialize(ref MessagePackWriter writer, global::SharedData.ByteEnum value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.ByteEnum value, global::MessagePack.MessagePackSerializerOptions options)
{
- writer.Write((Byte)value);
+ writer.Write((global::System.Byte)value);
}
- public global::SharedData.ByteEnum Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::SharedData.ByteEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
return (global::SharedData.ByteEnum)reader.ReadByte();
}
@@ -304,7 +294,6 @@ namespace MessagePack.Formatters.SharedData
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
@@ -317,32 +306,27 @@ namespace MessagePack.Formatters.SharedData
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Formatters
{
- using System;
- using System.Buffers;
- using System.Collections.Generic;
- using MessagePack;
-
public sealed class IMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::IMessageBody>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public IMessageBodyFormatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(3, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(3, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
- { typeof(global::TextMessageBody).TypeHandle, new KeyValuePair<int, int>(10, 0) },
- { typeof(global::StampMessageBody).TypeHandle, new KeyValuePair<int, int>(14, 1) },
- { typeof(global::QuestMessageBody).TypeHandle, new KeyValuePair<int, int>(25, 2) },
+ { typeof(global::TextMessageBody).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(10, 0) },
+ { typeof(global::StampMessageBody).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(14, 1) },
+ { typeof(global::QuestMessageBody).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(25, 2) },
};
- this.keyToJumpMap = new Dictionary<int, int>(3)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(3)
{
{ 10, 0 },
{ 14, 1 },
@@ -350,9 +334,9 @@ namespace MessagePack.Formatters
};
}
- public void Serialize(ref MessagePackWriter writer, global::IMessageBody value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::IMessageBody value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -378,7 +362,7 @@ namespace MessagePack.Formatters
writer.WriteNil();
}
- public global::IMessageBody Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::IMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -387,7 +371,7 @@ namespace MessagePack.Formatters
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:global::IMessageBody");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::IMessageBody");
}
options.Security.DepthStep(ref reader);
@@ -428,7 +412,6 @@ namespace MessagePack.Formatters
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
@@ -440,38 +423,33 @@ namespace MessagePack.Formatters
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Formatters.SharedData
{
- using System;
- using System.Buffers;
- using System.Collections.Generic;
- using MessagePack;
-
public sealed class IIVersioningUnionFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.IIVersioningUnion>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public IIVersioningUnionFormatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(1, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(1, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
- { typeof(global::SharedData.MySubUnion1).TypeHandle, new KeyValuePair<int, int>(0, 0) },
+ { typeof(global::SharedData.MySubUnion1).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(0, 0) },
};
- this.keyToJumpMap = new Dictionary<int, int>(1)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(1)
{
{ 0, 0 },
};
}
- public void Serialize(ref MessagePackWriter writer, global::SharedData.IIVersioningUnion value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IIVersioningUnion value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -491,7 +469,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteNil();
}
- public global::SharedData.IIVersioningUnion Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::SharedData.IIVersioningUnion Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -500,7 +478,7 @@ namespace MessagePack.Formatters.SharedData
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IIVersioningUnion");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IIVersioningUnion");
}
options.Security.DepthStep(ref reader);
@@ -529,19 +507,19 @@ namespace MessagePack.Formatters.SharedData
public sealed class IUnionCheckerFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.IUnionChecker>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public IUnionCheckerFormatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
- { typeof(global::SharedData.MySubUnion1).TypeHandle, new KeyValuePair<int, int>(0, 0) },
- { typeof(global::SharedData.MySubUnion2).TypeHandle, new KeyValuePair<int, int>(1, 1) },
- { typeof(global::SharedData.MySubUnion3).TypeHandle, new KeyValuePair<int, int>(2, 2) },
- { typeof(global::SharedData.MySubUnion4).TypeHandle, new KeyValuePair<int, int>(3, 3) },
+ { typeof(global::SharedData.MySubUnion1).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(0, 0) },
+ { typeof(global::SharedData.MySubUnion2).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(1, 1) },
+ { typeof(global::SharedData.MySubUnion3).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(2, 2) },
+ { typeof(global::SharedData.MySubUnion4).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(3, 3) },
};
- this.keyToJumpMap = new Dictionary<int, int>(4)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(4)
{
{ 0, 0 },
{ 1, 1 },
@@ -550,9 +528,9 @@ namespace MessagePack.Formatters.SharedData
};
}
- public void Serialize(ref MessagePackWriter writer, global::SharedData.IUnionChecker value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IUnionChecker value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -581,7 +559,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteNil();
}
- public global::SharedData.IUnionChecker Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::SharedData.IUnionChecker Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -590,7 +568,7 @@ namespace MessagePack.Formatters.SharedData
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker");
}
options.Security.DepthStep(ref reader);
@@ -628,19 +606,19 @@ namespace MessagePack.Formatters.SharedData
public sealed class IUnionChecker2Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.IUnionChecker2>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public IUnionChecker2Formatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
- { typeof(global::SharedData.MySubUnion2).TypeHandle, new KeyValuePair<int, int>(31, 0) },
- { typeof(global::SharedData.MySubUnion3).TypeHandle, new KeyValuePair<int, int>(42, 1) },
- { typeof(global::SharedData.MySubUnion4).TypeHandle, new KeyValuePair<int, int>(63, 2) },
- { typeof(global::SharedData.MySubUnion1).TypeHandle, new KeyValuePair<int, int>(120, 3) },
+ { typeof(global::SharedData.MySubUnion2).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(31, 0) },
+ { typeof(global::SharedData.MySubUnion3).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(42, 1) },
+ { typeof(global::SharedData.MySubUnion4).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(63, 2) },
+ { typeof(global::SharedData.MySubUnion1).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(120, 3) },
};
- this.keyToJumpMap = new Dictionary<int, int>(4)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(4)
{
{ 31, 0 },
{ 42, 1 },
@@ -649,9 +627,9 @@ namespace MessagePack.Formatters.SharedData
};
}
- public void Serialize(ref MessagePackWriter writer, global::SharedData.IUnionChecker2 value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IUnionChecker2 value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -680,7 +658,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteNil();
}
- public global::SharedData.IUnionChecker2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::SharedData.IUnionChecker2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -689,7 +667,7 @@ namespace MessagePack.Formatters.SharedData
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker2");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker2");
}
options.Security.DepthStep(ref reader);
@@ -727,26 +705,26 @@ namespace MessagePack.Formatters.SharedData
public sealed class IUnionSampleFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.IUnionSample>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public IUnionSampleFormatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
- { typeof(global::SharedData.FooClass).TypeHandle, new KeyValuePair<int, int>(0, 0) },
- { typeof(global::SharedData.BarClass).TypeHandle, new KeyValuePair<int, int>(100, 1) },
+ { typeof(global::SharedData.FooClass).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(0, 0) },
+ { typeof(global::SharedData.BarClass).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(100, 1) },
};
- this.keyToJumpMap = new Dictionary<int, int>(2)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(2)
{
{ 0, 0 },
{ 100, 1 },
};
}
- public void Serialize(ref MessagePackWriter writer, global::SharedData.IUnionSample value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IUnionSample value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -769,7 +747,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteNil();
}
- public global::SharedData.IUnionSample Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::SharedData.IUnionSample Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -778,7 +756,7 @@ namespace MessagePack.Formatters.SharedData
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionSample");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionSample");
}
options.Security.DepthStep(ref reader);
@@ -810,26 +788,26 @@ namespace MessagePack.Formatters.SharedData
public sealed class RootUnionTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.RootUnionType>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public RootUnionTypeFormatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
- { typeof(global::SharedData.SubUnionType1).TypeHandle, new KeyValuePair<int, int>(0, 0) },
- { typeof(global::SharedData.SubUnionType2).TypeHandle, new KeyValuePair<int, int>(1, 1) },
+ { typeof(global::SharedData.SubUnionType1).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(0, 0) },
+ { typeof(global::SharedData.SubUnionType2).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(1, 1) },
};
- this.keyToJumpMap = new Dictionary<int, int>(2)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(2)
{
{ 0, 0 },
{ 1, 1 },
};
}
- public void Serialize(ref MessagePackWriter writer, global::SharedData.RootUnionType value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.RootUnionType value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -852,7 +830,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteNil();
}
- public global::SharedData.RootUnionType Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::SharedData.RootUnionType Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -861,7 +839,7 @@ namespace MessagePack.Formatters.SharedData
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.RootUnionType");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.RootUnionType");
}
options.Security.DepthStep(ref reader);
@@ -899,7 +877,6 @@ namespace MessagePack.Formatters.SharedData
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
@@ -912,9 +889,9 @@ namespace MessagePack.Formatters.SharedData
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -922,9 +899,6 @@ namespace MessagePack.Formatters.SharedData
namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class TnonodsfarnoiuAtatqagaFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga>
{
@@ -968,6 +942,7 @@ namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad
return ____result;
}
}
+
}
#pragma warning restore 168
@@ -976,7 +951,6 @@ namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad
#pragma warning restore 612
#pragma warning restore SA1129 // Do not use default value type constructor
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1309 // Field names should not begin with underscore
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1403 // File may only contain a single namespace
@@ -990,9 +964,9 @@ namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -1000,9 +974,6 @@ namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad
namespace MessagePack.Formatters
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class ArrayTestTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::ArrayTestTest>
{
@@ -1016,13 +987,13 @@ namespace MessagePack.Formatters
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(7);
- formatterResolver.GetFormatterWithVerify<int[]>().Serialize(ref writer, value.MyProperty0, options);
- formatterResolver.GetFormatterWithVerify<int[,]>().Serialize(ref writer, value.MyProperty1, options);
- formatterResolver.GetFormatterWithVerify<global::GlobalMyEnum[,]>().Serialize(ref writer, value.MyProperty2, options);
- formatterResolver.GetFormatterWithVerify<int[,,]>().Serialize(ref writer, value.MyProperty3, options);
- formatterResolver.GetFormatterWithVerify<int[,,,]>().Serialize(ref writer, value.MyProperty4, options);
- formatterResolver.GetFormatterWithVerify<global::GlobalMyEnum[]>().Serialize(ref writer, value.MyProperty5, options);
- formatterResolver.GetFormatterWithVerify<global::QuestMessageBody[]>().Serialize(ref writer, value.MyProperty6, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[]>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[,]>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::GlobalMyEnum[,]>(formatterResolver).Serialize(ref writer, value.MyProperty2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[,,]>(formatterResolver).Serialize(ref writer, value.MyProperty3, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[,,,]>(formatterResolver).Serialize(ref writer, value.MyProperty4, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::GlobalMyEnum[]>(formatterResolver).Serialize(ref writer, value.MyProperty5, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::QuestMessageBody[]>(formatterResolver).Serialize(ref writer, value.MyProperty6, options);
}
public global::ArrayTestTest Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -1042,25 +1013,25 @@ namespace MessagePack.Formatters
switch (i)
{
case 0:
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<int[]>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<int[,]>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[,]>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
- ____result.MyProperty2 = formatterResolver.GetFormatterWithVerify<global::GlobalMyEnum[,]>().Deserialize(ref reader, options);
+ ____result.MyProperty2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::GlobalMyEnum[,]>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
- ____result.MyProperty3 = formatterResolver.GetFormatterWithVerify<int[,,]>().Deserialize(ref reader, options);
+ ____result.MyProperty3 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[,,]>(formatterResolver).Deserialize(ref reader, options);
break;
case 4:
- ____result.MyProperty4 = formatterResolver.GetFormatterWithVerify<int[,,,]>().Deserialize(ref reader, options);
+ ____result.MyProperty4 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[,,,]>(formatterResolver).Deserialize(ref reader, options);
break;
case 5:
- ____result.MyProperty5 = formatterResolver.GetFormatterWithVerify<global::GlobalMyEnum[]>().Deserialize(ref reader, options);
+ ____result.MyProperty5 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::GlobalMyEnum[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 6:
- ____result.MyProperty6 = formatterResolver.GetFormatterWithVerify<global::QuestMessageBody[]>().Deserialize(ref reader, options);
+ ____result.MyProperty6 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::QuestMessageBody[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -1132,8 +1103,8 @@ namespace MessagePack.Formatters
writer.WriteArrayHeader(4);
writer.Write(value.UserId);
writer.Write(value.RoomId);
- formatterResolver.GetFormatterWithVerify<global::System.DateTime>().Serialize(ref writer, value.PostTime, options);
- formatterResolver.GetFormatterWithVerify<global::IMessageBody>().Serialize(ref writer, value.Body, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTime>(formatterResolver).Serialize(ref writer, value.PostTime, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::IMessageBody>(formatterResolver).Serialize(ref writer, value.Body, options);
}
public global::Message Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -1159,10 +1130,10 @@ namespace MessagePack.Formatters
____result.RoomId = reader.ReadInt32();
break;
case 2:
- ____result.PostTime = formatterResolver.GetFormatterWithVerify<global::System.DateTime>().Deserialize(ref reader, options);
+ ____result.PostTime = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTime>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
- ____result.Body = formatterResolver.GetFormatterWithVerify<global::IMessageBody>().Deserialize(ref reader, options);
+ ____result.Body = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::IMessageBody>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -1234,7 +1205,7 @@ namespace MessagePack.Formatters
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
writer.Write(value.QuestId);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Text, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Text, options);
}
public global::QuestMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -1257,7 +1228,7 @@ namespace MessagePack.Formatters
____result.QuestId = reader.ReadInt32();
break;
case 1:
- ____result.Text = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Text = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -1327,7 +1298,7 @@ namespace MessagePack.Formatters
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(1);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Text, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Text, options);
}
public global::TextMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -1347,7 +1318,7 @@ namespace MessagePack.Formatters
switch (i)
{
case 0:
- ____result.Text = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Text = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -1359,6 +1330,7 @@ namespace MessagePack.Formatters
return ____result;
}
}
+
}
#pragma warning restore 168
@@ -1367,7 +1339,6 @@ namespace MessagePack.Formatters
#pragma warning restore 612
#pragma warning restore SA1129 // Do not use default value type constructor
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1309 // Field names should not begin with underscore
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1403 // File may only contain a single namespace
@@ -1381,9 +1352,9 @@ namespace MessagePack.Formatters
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -1391,9 +1362,6 @@ namespace MessagePack.Formatters
namespace MessagePack.Formatters
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class ComplexModelFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::ComplexModel>
{
// AdditionalProperty
@@ -1420,17 +1388,17 @@ namespace MessagePack.Formatters
var formatterResolver = options.Resolver;
writer.WriteMapHeader(6);
writer.WriteRaw(GetSpan_AdditionalProperty());
- formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.IDictionary<string, string>>().Serialize(ref writer, value.AdditionalProperty, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Collections.Generic.IDictionary<string, string>>(formatterResolver).Serialize(ref writer, value.AdditionalProperty, options);
writer.WriteRaw(GetSpan_CreatedOn());
- formatterResolver.GetFormatterWithVerify<global::System.DateTimeOffset>().Serialize(ref writer, value.CreatedOn, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTimeOffset>(formatterResolver).Serialize(ref writer, value.CreatedOn, options);
writer.WriteRaw(GetSpan_Id());
- formatterResolver.GetFormatterWithVerify<global::System.Guid>().Serialize(ref writer, value.Id, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Guid>(formatterResolver).Serialize(ref writer, value.Id, options);
writer.WriteRaw(GetSpan_Name());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Name, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Name, options);
writer.WriteRaw(GetSpan_UpdatedOn());
- formatterResolver.GetFormatterWithVerify<global::System.DateTimeOffset>().Serialize(ref writer, value.UpdatedOn, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTimeOffset>(formatterResolver).Serialize(ref writer, value.UpdatedOn, options);
writer.WriteRaw(GetSpan_SimpleModels());
- formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.IList<global::SimpleModel>>().Serialize(ref writer, value.SimpleModels, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Collections.Generic.IList<global::SimpleModel>>(formatterResolver).Serialize(ref writer, value.SimpleModels, options);
}
public global::ComplexModel Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -1466,25 +1434,25 @@ namespace MessagePack.Formatters
case 5720808977192022595UL:
if (stringKey[0] != 110) { goto FAIL; }
- ____result.CreatedOn = formatterResolver.GetFormatterWithVerify<global::System.DateTimeOffset>().Deserialize(ref reader, options);
+ ____result.CreatedOn = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTimeOffset>(formatterResolver).Deserialize(ref reader, options);
continue;
case 5720808977191956565UL:
if (stringKey[0] != 110) { goto FAIL; }
- ____result.UpdatedOn = formatterResolver.GetFormatterWithVerify<global::System.DateTimeOffset>().Deserialize(ref reader, options);
+ ____result.UpdatedOn = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTimeOffset>(formatterResolver).Deserialize(ref reader, options);
continue;
}
case 2:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 25673UL) { goto FAIL; }
- ____result.Id = formatterResolver.GetFormatterWithVerify<global::System.Guid>().Deserialize(ref reader, options);
+ ____result.Id = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Guid>(formatterResolver).Deserialize(ref reader, options);
continue;
case 4:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 1701667150UL) { goto FAIL; }
- ____result.Name = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Name = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
case 12:
if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_SimpleModels().Slice(1))) { goto FAIL; }
@@ -1528,13 +1496,13 @@ namespace MessagePack.Formatters
writer.WriteRaw(GetSpan_Id());
writer.Write(value.Id);
writer.WriteRaw(GetSpan_Name());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Name, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Name, options);
writer.WriteRaw(GetSpan_CreatedOn());
- formatterResolver.GetFormatterWithVerify<global::System.DateTime>().Serialize(ref writer, value.CreatedOn, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTime>(formatterResolver).Serialize(ref writer, value.CreatedOn, options);
writer.WriteRaw(GetSpan_Precision());
writer.Write(value.Precision);
writer.WriteRaw(GetSpan_Money());
- formatterResolver.GetFormatterWithVerify<decimal>().Serialize(ref writer, value.Money, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<decimal>(formatterResolver).Serialize(ref writer, value.Money, options);
writer.WriteRaw(GetSpan_Amount());
writer.Write(value.Amount);
}
@@ -1568,7 +1536,7 @@ namespace MessagePack.Formatters
case 4:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 1701667150UL) { goto FAIL; }
- ____result.Name = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Name = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
case 9:
switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey))
@@ -1577,7 +1545,7 @@ namespace MessagePack.Formatters
case 5720808977192022595UL:
if (stringKey[0] != 110) { goto FAIL; }
- ____result.CreatedOn = formatterResolver.GetFormatterWithVerify<global::System.DateTime>().Deserialize(ref reader, options);
+ ____result.CreatedOn = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.DateTime>(formatterResolver).Deserialize(ref reader, options);
continue;
case 8028074707240972880UL:
@@ -1590,7 +1558,7 @@ namespace MessagePack.Formatters
case 5:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 521392779085UL) { goto FAIL; }
- ____result.Money = formatterResolver.GetFormatterWithVerify<decimal>().Deserialize(ref reader, options);
+ ____result.Money = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<decimal>(formatterResolver).Deserialize(ref reader, options);
continue;
case 6:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 128017765461313UL) { goto FAIL; }
@@ -1605,8 +1573,20 @@ namespace MessagePack.Formatters
return ____result;
}
}
+
}
+#pragma warning restore 168
+#pragma warning restore 414
+#pragma warning restore 618
+#pragma warning restore 612
+
+#pragma warning restore SA1129 // Do not use default value type constructor
+#pragma warning restore SA1309 // Field names should not begin with underscore
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+#pragma warning restore SA1403 // File may only contain a single namespace
+#pragma warning restore SA1649 // File name should match first type name
+
// <auto-generated>
// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT.
// </auto-generated>
@@ -1615,9 +1595,9 @@ namespace MessagePack.Formatters
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -1625,9 +1605,6 @@ namespace MessagePack.Formatters
namespace MessagePack.Formatters.PerfBenchmarkDotNet
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class StringKeySerializerTargetFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::PerfBenchmarkDotNet.StringKeySerializerTarget>
{
// MyProperty1
@@ -1744,8 +1721,20 @@ namespace MessagePack.Formatters.PerfBenchmarkDotNet
return ____result;
}
}
+
}
+#pragma warning restore 168
+#pragma warning restore 414
+#pragma warning restore 618
+#pragma warning restore 612
+
+#pragma warning restore SA1129 // Do not use default value type constructor
+#pragma warning restore SA1309 // Field names should not begin with underscore
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+#pragma warning restore SA1403 // File may only contain a single namespace
+#pragma warning restore SA1649 // File name should match first type name
+
// <auto-generated>
// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT.
// </auto-generated>
@@ -1754,9 +1743,9 @@ namespace MessagePack.Formatters.PerfBenchmarkDotNet
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -1764,9 +1753,6 @@ namespace MessagePack.Formatters.PerfBenchmarkDotNet
namespace MessagePack.Formatters.SharedData
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class ArrayOptimizeClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.ArrayOptimizeClass>
{
@@ -1884,7 +1870,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(1);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.OPQ, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.OPQ, options);
}
public global::SharedData.BarClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -1904,7 +1890,7 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.OPQ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.OPQ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2026,8 +2012,8 @@ namespace MessagePack.Formatters.SharedData
writer.WriteArrayHeader(4);
writer.Write(value.Prop1);
writer.Write(value.Prop2);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Prop3, options);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Prop4, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Prop3, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Prop4, options);
}
public global::SharedData.DefaultValueIntKeyClassWithExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -2056,10 +2042,10 @@ namespace MessagePack.Formatters.SharedData
__Prop2__ = reader.ReadInt32();
break;
case 2:
- __Prop3__ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ __Prop3__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
- __Prop4__ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ __Prop4__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2200,15 +2186,15 @@ namespace MessagePack.Formatters.SharedData
{
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(9);
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.Item1, options);
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.Item2, options);
- formatterResolver.GetFormatterWithVerify<T3>().Serialize(ref writer, value.Item3, options);
- formatterResolver.GetFormatterWithVerify<T4>().Serialize(ref writer, value.Item4, options);
- formatterResolver.GetFormatterWithVerify<T5>().Serialize(ref writer, value.Item5, options);
- formatterResolver.GetFormatterWithVerify<T6>().Serialize(ref writer, value.Item6, options);
- formatterResolver.GetFormatterWithVerify<T7>().Serialize(ref writer, value.Item7, options);
- formatterResolver.GetFormatterWithVerify<T8>().Serialize(ref writer, value.Item8, options);
- formatterResolver.GetFormatterWithVerify<T9>().Serialize(ref writer, value.Item9, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.Item1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.Item2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T3>(formatterResolver).Serialize(ref writer, value.Item3, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T4>(formatterResolver).Serialize(ref writer, value.Item4, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T5>(formatterResolver).Serialize(ref writer, value.Item5, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T6>(formatterResolver).Serialize(ref writer, value.Item6, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T7>(formatterResolver).Serialize(ref writer, value.Item7, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T8>(formatterResolver).Serialize(ref writer, value.Item8, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T9>(formatterResolver).Serialize(ref writer, value.Item9, options);
}
public global::SharedData.DynamicArgumentTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -2236,31 +2222,31 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- __Item1__ = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ __Item1__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
- __Item2__ = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ __Item2__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
- __Item3__ = formatterResolver.GetFormatterWithVerify<T3>().Deserialize(ref reader, options);
+ __Item3__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T3>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
- __Item4__ = formatterResolver.GetFormatterWithVerify<T4>().Deserialize(ref reader, options);
+ __Item4__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T4>(formatterResolver).Deserialize(ref reader, options);
break;
case 4:
- __Item5__ = formatterResolver.GetFormatterWithVerify<T5>().Deserialize(ref reader, options);
+ __Item5__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T5>(formatterResolver).Deserialize(ref reader, options);
break;
case 5:
- __Item6__ = formatterResolver.GetFormatterWithVerify<T6>().Deserialize(ref reader, options);
+ __Item6__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T6>(formatterResolver).Deserialize(ref reader, options);
break;
case 6:
- __Item7__ = formatterResolver.GetFormatterWithVerify<T7>().Deserialize(ref reader, options);
+ __Item7__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T7>(formatterResolver).Deserialize(ref reader, options);
break;
case 7:
- __Item8__ = formatterResolver.GetFormatterWithVerify<T8>().Deserialize(ref reader, options);
+ __Item8__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T8>(formatterResolver).Deserialize(ref reader, options);
break;
case 8:
- __Item9__ = formatterResolver.GetFormatterWithVerify<T9>().Deserialize(ref reader, options);
+ __Item9__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T9>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2360,7 +2346,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
writer.Write(value.Prop1);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Prop2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Prop2, options);
writer.Write(value.Prop3);
}
@@ -2384,7 +2370,7 @@ namespace MessagePack.Formatters.SharedData
____result.Prop1 = reader.ReadInt32();
break;
case 1:
- ____result.Prop2 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Prop2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.Prop3 = reader.ReadInt32();
@@ -2457,8 +2443,8 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.MyProperty0, options);
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
}
public global::SharedData.GenericClass<T1, T2> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -2478,10 +2464,10 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2509,8 +2495,8 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.MyProperty0, options);
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.Comparer, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.Comparer, options);
}
public global::SharedData.GenericConstrainedClassIntKey<T1, T2> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -2530,10 +2516,10 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
- ____result.Comparer = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2555,8 +2541,8 @@ namespace MessagePack.Formatters.SharedData
{
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.MyProperty0, options);
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.Comparer, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.Comparer, options);
}
public global::SharedData.GenericConstrainedStructIntKey<T1, T2> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -2576,10 +2562,10 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
- ____result.Comparer = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2599,8 +2585,8 @@ namespace MessagePack.Formatters.SharedData
{
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.MyProperty0, options);
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
}
public global::SharedData.GenericStruct<T1, T2> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -2620,10 +2606,10 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -2649,7 +2635,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<global::SharedData.Version0>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.Version0>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
writer.Write(value.After);
}
@@ -2670,7 +2656,7 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<global::SharedData.Version0>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.Version0>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.After = reader.ReadInt32();
@@ -2699,7 +2685,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<global::SharedData.Version1>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.Version1>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
writer.Write(value.After);
}
@@ -2720,7 +2706,7 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<global::SharedData.Version1>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.Version1>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.After = reader.ReadInt32();
@@ -2749,7 +2735,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
- formatterResolver.GetFormatterWithVerify<global::SharedData.Version2>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.Version2>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
writer.Write(value.After);
}
@@ -2770,7 +2756,7 @@ namespace MessagePack.Formatters.SharedData
switch (i)
{
case 0:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<global::SharedData.Version2>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.Version2>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.After = reader.ReadInt32();
@@ -3121,11 +3107,11 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(7);
writer.Write(value.Prop1);
- formatterResolver.GetFormatterWithVerify<global::SharedData.ByteEnum>().Serialize(ref writer, value.Prop2, options);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Prop3, options);
- formatterResolver.GetFormatterWithVerify<global::SharedData.SimpleStringKeyData>().Serialize(ref writer, value.Prop4, options);
- formatterResolver.GetFormatterWithVerify<global::SharedData.SimpleStructIntKeyData>().Serialize(ref writer, value.Prop5, options);
- formatterResolver.GetFormatterWithVerify<global::SharedData.SimpleStructStringKeyData>().Serialize(ref writer, value.Prop6, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.ByteEnum>(formatterResolver).Serialize(ref writer, value.Prop2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Prop3, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.SimpleStringKeyData>(formatterResolver).Serialize(ref writer, value.Prop4, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.SimpleStructIntKeyData>(formatterResolver).Serialize(ref writer, value.Prop5, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.SimpleStructStringKeyData>(formatterResolver).Serialize(ref writer, value.Prop6, options);
writer.Write(value.BytesSpecial);
}
@@ -3149,22 +3135,22 @@ namespace MessagePack.Formatters.SharedData
____result.Prop1 = reader.ReadInt32();
break;
case 1:
- ____result.Prop2 = formatterResolver.GetFormatterWithVerify<global::SharedData.ByteEnum>().Deserialize(ref reader, options);
+ ____result.Prop2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.ByteEnum>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
- ____result.Prop3 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Prop3 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
- ____result.Prop4 = formatterResolver.GetFormatterWithVerify<global::SharedData.SimpleStringKeyData>().Deserialize(ref reader, options);
+ ____result.Prop4 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.SimpleStringKeyData>(formatterResolver).Deserialize(ref reader, options);
break;
case 4:
- ____result.Prop5 = formatterResolver.GetFormatterWithVerify<global::SharedData.SimpleStructIntKeyData>().Deserialize(ref reader, options);
+ ____result.Prop5 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.SimpleStructIntKeyData>(formatterResolver).Deserialize(ref reader, options);
break;
case 5:
- ____result.Prop6 = formatterResolver.GetFormatterWithVerify<global::SharedData.SimpleStructStringKeyData>().Deserialize(ref reader, options);
+ ____result.Prop6 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.SimpleStructStringKeyData>(formatterResolver).Deserialize(ref reader, options);
break;
case 6:
- ____result.BytesSpecial = reader.ReadBytes()?.ToArray();
+ ____result.BytesSpecial = global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes());
break;
default:
reader.Skip();
@@ -3210,7 +3196,7 @@ namespace MessagePack.Formatters.SharedData
____result.Y = reader.ReadInt32();
break;
case 2:
- ____result.BytesSpecial = reader.ReadBytes()?.ToArray();
+ ____result.BytesSpecial = global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes());
break;
default:
reader.Skip();
@@ -3681,7 +3667,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
writer.Write(value.MyProperty);
- formatterResolver.GetFormatterWithVerify<global::SharedData.MyClass>().Serialize(ref writer, value.UnknownBlock, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.MyClass>(formatterResolver).Serialize(ref writer, value.UnknownBlock, options);
writer.Write(value.MyProperty2);
}
@@ -3705,7 +3691,7 @@ namespace MessagePack.Formatters.SharedData
____result.MyProperty = reader.ReadInt32();
break;
case 1:
- ____result.UnknownBlock = formatterResolver.GetFormatterWithVerify<global::SharedData.MyClass>().Deserialize(ref reader, options);
+ ____result.UnknownBlock = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.MyClass>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.MyProperty2 = reader.ReadInt32();
@@ -3786,7 +3772,7 @@ namespace MessagePack.Formatters.SharedData
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
writer.Write(value.Data1);
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Data2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.Data2, options);
}
public global::SharedData.WithIndexer Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -3809,7 +3795,7 @@ namespace MessagePack.Formatters.SharedData
____result.Data1 = reader.ReadInt32();
break;
case 1:
- ____result.Data2 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.Data2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -3821,6 +3807,7 @@ namespace MessagePack.Formatters.SharedData
return ____result;
}
}
+
}
#pragma warning restore 168
@@ -3829,7 +3816,6 @@ namespace MessagePack.Formatters.SharedData
#pragma warning restore 612
#pragma warning restore SA1129 // Do not use default value type constructor
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1309 // Field names should not begin with underscore
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1403 // File may only contain a single namespace
@@ -3843,9 +3829,9 @@ namespace MessagePack.Formatters.SharedData
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -3853,9 +3839,6 @@ namespace MessagePack.Formatters.SharedData
namespace MessagePack.Formatters.SharedData
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class Callback2Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::SharedData.Callback2>
{
// X
@@ -4198,9 +4181,9 @@ namespace MessagePack.Formatters.SharedData
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_MyProperty0());
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
writer.WriteRaw(GetSpan_Comparer());
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.Comparer, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.Comparer, options);
}
public global::SharedData.GenericConstrainedClassStringKey<T1, T2> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -4227,12 +4210,12 @@ namespace MessagePack.Formatters.SharedData
case 11:
if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_MyProperty0().Slice(1))) { goto FAIL; }
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
continue;
case 8:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 8243120455795175235UL) { goto FAIL; }
- ____result.Comparer = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -4257,9 +4240,9 @@ namespace MessagePack.Formatters.SharedData
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_MyProperty0());
- formatterResolver.GetFormatterWithVerify<T1>().Serialize(ref writer, value.MyProperty0, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Serialize(ref writer, value.MyProperty0, options);
writer.WriteRaw(GetSpan_Comparer());
- formatterResolver.GetFormatterWithVerify<T2>().Serialize(ref writer, value.Comparer, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Serialize(ref writer, value.Comparer, options);
}
public global::SharedData.GenericConstrainedStructStringKey<T1, T2> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -4286,12 +4269,12 @@ namespace MessagePack.Formatters.SharedData
case 11:
if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_MyProperty0().Slice(1))) { goto FAIL; }
- ____result.MyProperty0 = formatterResolver.GetFormatterWithVerify<T1>().Deserialize(ref reader, options);
+ ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T1>(formatterResolver).Deserialize(ref reader, options);
continue;
case 8:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 8243120455795175235UL) { goto FAIL; }
- ____result.Comparer = formatterResolver.GetFormatterWithVerify<T2>().Deserialize(ref reader, options);
+ ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<T2>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -4376,7 +4359,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteRaw(GetSpan_Prop1());
writer.Write(value.Prop1);
writer.WriteRaw(GetSpan_Prop2());
- formatterResolver.GetFormatterWithVerify<global::SharedData.ByteEnum>().Serialize(ref writer, value.Prop2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.ByteEnum>(formatterResolver).Serialize(ref writer, value.Prop2, options);
writer.WriteRaw(GetSpan_Prop3());
writer.Write(value.Prop3);
}
@@ -4410,7 +4393,7 @@ namespace MessagePack.Formatters.SharedData
____result.Prop1 = reader.ReadInt32();
continue;
case 216634716752UL:
- ____result.Prop2 = formatterResolver.GetFormatterWithVerify<global::SharedData.ByteEnum>().Deserialize(ref reader, options);
+ ____result.Prop2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::SharedData.ByteEnum>(formatterResolver).Deserialize(ref reader, options);
continue;
case 220929684048UL:
____result.Prop3 = reader.ReadInt32();
@@ -4439,7 +4422,7 @@ namespace MessagePack.Formatters.SharedData
writer.WriteRaw(GetSpan_X());
writer.Write(value.X);
writer.WriteRaw(GetSpan_Y());
- formatterResolver.GetFormatterWithVerify<int[]>().Serialize(ref writer, value.Y, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[]>(formatterResolver).Serialize(ref writer, value.Y, options);
}
public global::SharedData.SimpleStructStringKeyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -4471,7 +4454,7 @@ namespace MessagePack.Formatters.SharedData
____result.X = reader.ReadInt32();
continue;
case 383015019883UL:
- ____result.Y = formatterResolver.GetFormatterWithVerify<int[]>().Deserialize(ref reader, options);
+ ____result.Y = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[]>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -4482,5 +4465,17 @@ namespace MessagePack.Formatters.SharedData
return ____result;
}
}
+
}
+#pragma warning restore 168
+#pragma warning restore 414
+#pragma warning restore 618
+#pragma warning restore 612
+
+#pragma warning restore SA1129 // Do not use default value type constructor
+#pragma warning restore SA1309 // Field names should not begin with underscore
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+#pragma warning restore SA1403 // File may only contain a single namespace
+#pragma warning restore SA1649 // File name should match first type name
+
diff --git a/sandbox/Sandbox/Sandbox.csproj b/sandbox/Sandbox/Sandbox.csproj
index a1561709..17da2db3 100644
--- a/sandbox/Sandbox/Sandbox.csproj
+++ b/sandbox/Sandbox/Sandbox.csproj
@@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
<PackageReference Include="MsgPack.Cli" Version="0.7.1" />
- <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="protobuf-net" Version="2.1.0" />
<PackageReference Include="ZeroFormatter" Version="1.6.4" />
</ItemGroup>
diff --git a/sandbox/Sandbox/codegen.ps1 b/sandbox/Sandbox/codegen.ps1
index 2a595dee..279718f6 100644
--- a/sandbox/Sandbox/codegen.ps1
+++ b/sandbox/Sandbox/codegen.ps1
@@ -1 +1 @@
-dotnet run -f "net5.0" -p "$PSScriptRoot/../../src/MessagePack.Generator/MessagePack.Generator.csproj" -- -i "$PSScriptRoot/../SharedData/SharedData.csproj" -o "$PSScriptRoot/Generated.cs"
+dotnet run -f "net6.0" --project "$PSScriptRoot/../../src/MessagePack.Generator/MessagePack.Generator.csproj" -- -i "$PSScriptRoot/../SharedData/SharedData.csproj" -o "$PSScriptRoot/Generated.cs"
diff --git a/sandbox/TestData2/A.cs b/sandbox/TestData2/A.cs
index 44b0a47f..a7eeef9d 100644
--- a/sandbox/TestData2/A.cs
+++ b/sandbox/TestData2/A.cs
@@ -1,17 +1,14 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System.Collections.Generic;
-using MessagePack;
-
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
#pragma warning disable SA1401 // Fields should be private
+#nullable enable
+
+namespace TestData2;
-namespace TestData2
+[MessagePackObject(true)]
+public class A
{
- [MessagePackObject(true)]
- public class A
- {
- public int a; public List<B> bs; public C c;
- }
+ public int a; public List<B?>? bs; public C? c;
}
diff --git a/sandbox/TestData2/B.cs b/sandbox/TestData2/B.cs
index 769c0e1c..d9c4029e 100644
--- a/sandbox/TestData2/B.cs
+++ b/sandbox/TestData2/B.cs
@@ -1,17 +1,14 @@
-// Copyright (c) All contributors. All rights reserved.
+// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System.Collections.Generic;
-using MessagePack;
-
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
#pragma warning disable SA1401 // Fields should be private
+#nullable enable
+
+namespace TestData2;
-namespace TestData2
+[MessagePackObject(true)]
+public class B
{
- [MessagePackObject(true)]
- public class B
- {
- public List<A> ass; public C c; public int a;
- }
+ public List<A?>? ass; public C? c; public int a;
}
diff --git a/sandbox/TestData2/C.cs b/sandbox/TestData2/C.cs
index 079c171e..741517ff 100644
--- a/sandbox/TestData2/C.cs
+++ b/sandbox/TestData2/C.cs
@@ -1,16 +1,14 @@
-// Copyright (c) All contributors. All rights reserved.
+// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using MessagePack;
-
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
#pragma warning disable SA1401 // Fields should be private
+#nullable enable
+
+namespace TestData2;
-namespace TestData2
+[MessagePackObject(true)]
+public class C
{
- [MessagePackObject(true)]
- public class C
- {
- public B b; public int a;
- }
+ public B? b; public int a;
}
diff --git a/sandbox/TestData2/Generated.cs b/sandbox/TestData2/Generated.cs
index 606e2dca..1e65486d 100644
--- a/sandbox/TestData2/Generated.cs
+++ b/sandbox/TestData2/Generated.cs
@@ -6,15 +6,13 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Resolvers
{
- using System;
-
public class GeneratedResolver : global::MessagePack.IFormatterResolver
{
public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver();
@@ -45,11 +43,11 @@ namespace MessagePack.Resolvers
internal static class GeneratedResolverGetFormatterHelper
{
- private static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup;
+ private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> lookup;
static GeneratedResolverGetFormatterHelper()
{
- lookup = new global::System.Collections.Generic.Dictionary<Type, int>(14)
+ lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(14)
{
{ typeof(global::System.Collections.Generic.List<global::TestData2.A>), 0 },
{ typeof(global::System.Collections.Generic.List<global::TestData2.B>), 1 },
@@ -68,7 +66,7 @@ namespace MessagePack.Resolvers
};
}
- internal static object GetFormatter(Type t)
+ internal static object GetFormatter(global::System.Type t)
{
int key;
if (!lookup.TryGetValue(t, out key))
@@ -104,7 +102,6 @@ namespace MessagePack.Resolvers
#pragma warning restore 612
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1649 // File name should match first type name
@@ -116,25 +113,22 @@ namespace MessagePack.Resolvers
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Formatters.TestData2
{
- using System;
- using System.Buffers;
- using MessagePack;
public sealed class Nest1_IdFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::TestData2.Nest1.Id>
{
- public void Serialize(ref MessagePackWriter writer, global::TestData2.Nest1.Id value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest1.Id value, global::MessagePack.MessagePackSerializerOptions options)
{
- writer.Write((Int32)value);
+ writer.Write((global::System.Int32)value);
}
- public global::TestData2.Nest1.Id Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::TestData2.Nest1.Id Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
return (global::TestData2.Nest1.Id)reader.ReadInt32();
}
@@ -142,12 +136,12 @@ namespace MessagePack.Formatters.TestData2
public sealed class Nest2_IdFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::TestData2.Nest2.Id>
{
- public void Serialize(ref MessagePackWriter writer, global::TestData2.Nest2.Id value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest2.Id value, global::MessagePack.MessagePackSerializerOptions options)
{
- writer.Write((Int32)value);
+ writer.Write((global::System.Int32)value);
}
- public global::TestData2.Nest2.Id Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public global::TestData2.Nest2.Id Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
return (global::TestData2.Nest2.Id)reader.ReadInt32();
}
@@ -159,7 +153,6 @@ namespace MessagePack.Formatters.TestData2
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
@@ -173,9 +166,9 @@ namespace MessagePack.Formatters.TestData2
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -183,9 +176,6 @@ namespace MessagePack.Formatters.TestData2
namespace MessagePack.Formatters.TestData2
{
- using global::System.Buffers;
- using global::MessagePack;
-
public sealed class AFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::TestData2.A>
{
// a
@@ -208,9 +198,9 @@ namespace MessagePack.Formatters.TestData2
writer.WriteRaw(GetSpan_a());
writer.Write(value.a);
writer.WriteRaw(GetSpan_bs());
- formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.B>>().Serialize(ref writer, value.bs, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.B>>(formatterResolver).Serialize(ref writer, value.bs, options);
writer.WriteRaw(GetSpan_c());
- formatterResolver.GetFormatterWithVerify<global::TestData2.C>().Serialize(ref writer, value.c, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.C>(formatterResolver).Serialize(ref writer, value.c, options);
}
public global::TestData2.A Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -242,13 +232,13 @@ namespace MessagePack.Formatters.TestData2
____result.a = reader.ReadInt32();
continue;
case 99UL:
- ____result.c = formatterResolver.GetFormatterWithVerify<global::TestData2.C>().Deserialize(ref reader, options);
+ ____result.c = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.C>(formatterResolver).Deserialize(ref reader, options);
continue;
}
case 2:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 29538UL) { goto FAIL; }
- ____result.bs = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.B>>().Deserialize(ref reader, options);
+ ____result.bs = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.B>>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -279,9 +269,9 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(3);
writer.WriteRaw(GetSpan_ass());
- formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.A>>().Serialize(ref writer, value.ass, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.A>>(formatterResolver).Serialize(ref writer, value.ass, options);
writer.WriteRaw(GetSpan_c());
- formatterResolver.GetFormatterWithVerify<global::TestData2.C>().Serialize(ref writer, value.c, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.C>(formatterResolver).Serialize(ref writer, value.c, options);
writer.WriteRaw(GetSpan_a());
writer.Write(value.a);
}
@@ -310,14 +300,14 @@ namespace MessagePack.Formatters.TestData2
case 3:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 7566177UL) { goto FAIL; }
- ____result.ass = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.A>>().Deserialize(ref reader, options);
+ ____result.ass = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::System.Collections.Generic.List<global::TestData2.A>>(formatterResolver).Deserialize(ref reader, options);
continue;
case 1:
switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey))
{
default: goto FAIL;
case 99UL:
- ____result.c = formatterResolver.GetFormatterWithVerify<global::TestData2.C>().Deserialize(ref reader, options);
+ ____result.c = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.C>(formatterResolver).Deserialize(ref reader, options);
continue;
case 97UL:
____result.a = reader.ReadInt32();
@@ -350,7 +340,7 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_b());
- formatterResolver.GetFormatterWithVerify<global::TestData2.B>().Serialize(ref writer, value.b, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.B>(formatterResolver).Serialize(ref writer, value.b, options);
writer.WriteRaw(GetSpan_a());
writer.Write(value.a);
}
@@ -381,7 +371,7 @@ namespace MessagePack.Formatters.TestData2
{
default: goto FAIL;
case 98UL:
- ____result.b = formatterResolver.GetFormatterWithVerify<global::TestData2.B>().Deserialize(ref reader, options);
+ ____result.b = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.B>(formatterResolver).Deserialize(ref reader, options);
continue;
case 97UL:
____result.a = reader.ReadInt32();
@@ -414,9 +404,9 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_EnumId());
- formatterResolver.GetFormatterWithVerify<global::TestData2.Nest1.Id>().Serialize(ref writer, value.EnumId, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest1.Id>(formatterResolver).Serialize(ref writer, value.EnumId, options);
writer.WriteRaw(GetSpan_ClassId());
- formatterResolver.GetFormatterWithVerify<global::TestData2.Nest1.IdType>().Serialize(ref writer, value.ClassId, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest1.IdType>(formatterResolver).Serialize(ref writer, value.ClassId, options);
}
public global::TestData2.Nest1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -443,12 +433,12 @@ namespace MessagePack.Formatters.TestData2
case 6:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 110266531802693UL) { goto FAIL; }
- ____result.EnumId = formatterResolver.GetFormatterWithVerify<global::TestData2.Nest1.Id>().Deserialize(ref reader, options);
+ ____result.EnumId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest1.Id>(formatterResolver).Deserialize(ref reader, options);
continue;
case 7:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 28228257876896835UL) { goto FAIL; }
- ____result.ClassId = formatterResolver.GetFormatterWithVerify<global::TestData2.Nest1.IdType>().Deserialize(ref reader, options);
+ ____result.ClassId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest1.IdType>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -503,9 +493,9 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_EnumId());
- formatterResolver.GetFormatterWithVerify<global::TestData2.Nest2.Id>().Serialize(ref writer, value.EnumId, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest2.Id>(formatterResolver).Serialize(ref writer, value.EnumId, options);
writer.WriteRaw(GetSpan_ClassId());
- formatterResolver.GetFormatterWithVerify<global::TestData2.Nest2.IdType>().Serialize(ref writer, value.ClassId, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest2.IdType>(formatterResolver).Serialize(ref writer, value.ClassId, options);
}
public global::TestData2.Nest2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -532,12 +522,12 @@ namespace MessagePack.Formatters.TestData2
case 6:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 110266531802693UL) { goto FAIL; }
- ____result.EnumId = formatterResolver.GetFormatterWithVerify<global::TestData2.Nest2.Id>().Deserialize(ref reader, options);
+ ____result.EnumId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest2.Id>(formatterResolver).Deserialize(ref reader, options);
continue;
case 7:
if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 28228257876896835UL) { goto FAIL; }
- ____result.ClassId = formatterResolver.GetFormatterWithVerify<global::TestData2.Nest2.IdType>().Deserialize(ref reader, options);
+ ____result.ClassId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::TestData2.Nest2.IdType>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -592,9 +582,9 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_MyProperty1());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
writer.WriteRaw(GetSpan_MyProperty2());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.MyProperty2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.MyProperty2, options);
}
public global::TestData2.PropNameCheck1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -627,10 +617,10 @@ namespace MessagePack.Formatters.TestData2
{
default: goto FAIL;
case 3242356UL:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
case 3307892UL:
- ____result.MyProperty2 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.MyProperty2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -662,9 +652,9 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(2);
writer.WriteRaw(GetSpan_MyProperty1());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.MyProperty1, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.MyProperty1, options);
writer.WriteRaw(GetSpan_MyProperty2());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.MyProperty2, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.MyProperty2, options);
}
public global::TestData2.PropNameCheck2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -697,10 +687,10 @@ namespace MessagePack.Formatters.TestData2
{
default: goto FAIL;
case 3242356UL:
- ____result.MyProperty1 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
case 3307892UL:
- ____result.MyProperty2 = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ ____result.MyProperty2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -730,7 +720,7 @@ namespace MessagePack.Formatters.TestData2
var formatterResolver = options.Resolver;
writer.WriteMapHeader(1);
writer.WriteRaw(GetSpan_SomeProperty());
- formatterResolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.SomeProperty, options);
+ global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.SomeProperty, options);
}
public global::TestData2.Record Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
@@ -757,7 +747,7 @@ namespace MessagePack.Formatters.TestData2
case 12:
if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_SomeProperty().Slice(1))) { goto FAIL; }
- __SomeProperty__ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options);
+ __SomeProperty__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
continue;
}
@@ -768,5 +758,17 @@ namespace MessagePack.Formatters.TestData2
return ____result;
}
}
+
}
+#pragma warning restore 168
+#pragma warning restore 414
+#pragma warning restore 618
+#pragma warning restore 612
+
+#pragma warning restore SA1129 // Do not use default value type constructor
+#pragma warning restore SA1309 // Field names should not begin with underscore
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+#pragma warning restore SA1403 // File may only contain a single namespace
+#pragma warning restore SA1649 // File name should match first type name
+
diff --git a/sandbox/TestData2/TestData2.csproj b/sandbox/TestData2/TestData2.csproj
index 241bef29..a7313049 100644
--- a/sandbox/TestData2/TestData2.csproj
+++ b/sandbox/TestData2/TestData2.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
- <LangVersion>9</LangVersion>
+ <LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.1.90" />
@@ -9,4 +9,8 @@
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
+ <ItemGroup>
+ <Using Include="System.Collections.Generic" />
+ <Using Include="MessagePack" />
+ </ItemGroup>
</Project>
diff --git a/sandbox/TestData2/codegen.ps1 b/sandbox/TestData2/codegen.ps1
index d3af9269..6781688e 100644
--- a/sandbox/TestData2/codegen.ps1
+++ b/sandbox/TestData2/codegen.ps1
@@ -1 +1 @@
-dotnet run -f "net5.0" -p "$PSScriptRoot/../../src/MessagePack.Generator/MessagePack.Generator.csproj" -- -i "$PSScriptRoot/TestData2.csproj" -o "$PSScriptRoot/Generated.cs"
+dotnet run -f "net6.0" --project "$PSScriptRoot/../../src/MessagePack.Generator/MessagePack.Generator.csproj" -- -i "$PSScriptRoot/TestData2.csproj" -o "$PSScriptRoot/Generated.cs"
diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj
index b684a5b8..42b02f30 100644
--- a/src/MessagePack.Generator/MessagePack.Generator.csproj
+++ b/src/MessagePack.Generator/MessagePack.Generator.csproj
@@ -3,12 +3,13 @@
<PropertyGroup>
<AssemblyName>mpc</AssemblyName>
<OutputType>Exe</OutputType>
- <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
- <LangVersion>9</LangVersion>
+ <TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
+ <LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>
<ToolCommandName>mpc</ToolCommandName>
+ <RollForward>Major</RollForward>
<!-- NuGet Info -->
<PackageId>MessagePack.Generator</PackageId>
@@ -18,11 +19,11 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="ConsoleAppFramework" Version="2.0.0" />
+ <PackageReference Include="ConsoleAppFramework" Version="3.3.2" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
<PackageReference Include="Microsoft.Build.Framework" Version="16.5.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.5.0" ExcludeAssets="runtime" />
- <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="3.10.0" />
+ <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs
index 532cdc71..30aaedb9 100644
--- a/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs
+++ b/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs
@@ -170,7 +170,7 @@ namespace MessagePackCompiler.CodeAnalysis
}
else
{
- return $"formatterResolver.GetFormatterWithVerify<{this.Type}>().Serialize(ref writer, value.{this.Name}, options)";
+ return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)";
}
}
@@ -182,12 +182,18 @@ namespace MessagePackCompiler.CodeAnalysis
}
else if (this.primitiveTypes.Contains(this.Type))
{
- string suffix = this.Type == "byte[]" ? "?.ToArray()" : string.Empty;
- return $"reader.Read{this.ShortTypeName!.Replace("[]", "s")}()" + suffix;
+ if (this.Type == "byte[]")
+ {
+ return "global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())";
+ }
+ else
+ {
+ return $"reader.Read{this.ShortTypeName!.Replace("[]", "s")}()";
+ }
}
else
{
- return $"formatterResolver.GetFormatterWithVerify<{this.Type}>().Deserialize(ref reader, options)";
+ return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)";
}
}
}
diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs
index d2537dcd..935ceb87 100644
--- a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs
+++ b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs
@@ -971,10 +971,11 @@ namespace MessagePackCompiler.CodeAnalysis
{
var name = type.ContainingType is object ? GetMinimallyQualifiedClassName(type.ContainingType) + "_" : string.Empty;
name += type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
- name = name.Replace(".", "_");
- name = name.Replace("<", "_");
- name = name.Replace(">", "_");
+ name = name.Replace('.', '_');
+ name = name.Replace('<', '_');
+ name = name.Replace('>', '_');
name = Regex.Replace(name, @"\[([,])*\]", match => $"Array{match.Length - 1}");
+ name = name.Replace("?", string.Empty);
return name;
}
diff --git a/src/MessagePack.GeneratorCore/CodeGenerator.cs b/src/MessagePack.GeneratorCore/CodeGenerator.cs
index f9654693..1f48973e 100644
--- a/src/MessagePack.GeneratorCore/CodeGenerator.cs
+++ b/src/MessagePack.GeneratorCore/CodeGenerator.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -16,6 +17,8 @@ namespace MessagePackCompiler
{
public class CodeGenerator
{
+ private static readonly HashSet<char> InvalidFileCharSet = new(Path.GetInvalidFileNameChars());
+
private static readonly Encoding NoBomUtf8 = new UTF8Encoding(false);
private readonly Action<string> logger;
@@ -212,15 +215,76 @@ namespace MessagePackCompiler
private Task OutputToDirAsync(string dir, string ns, string name, string multipleOutSymbol, string text)
{
- if (multipleOutSymbol == string.Empty)
+ var builder = new StringBuilder();
+ void AppendDir(string dir)
+ {
+ if (dir.Length != 0)
+ {
+ builder.Append(dir);
+ if (dir[dir.Length - 1] != Path.DirectorySeparatorChar && dir[dir.Length - 1] != Path.AltDirectorySeparatorChar)
+ {
+ builder.Append(Path.DirectorySeparatorChar);
+ }
+ }
+ }
+
+ void AppendChar(char c)
+ {
+ if (c == '.' || InvalidFileCharSet.Contains(c))
+ {
+ builder.Append('_');
+ }
+ else
+ {
+ builder.Append(c);
+ }
+ }
+
+ void Append(string text)
{
- return OutputAsync(Path.Combine(dir, $"{ns}_{name}".Replace(".", "_").Replace("global::", string.Empty) + ".cs"), text);
+ var span = text.AsSpan();
+ while (!span.IsEmpty)
+ {
+ var index = span.IndexOf("global::".AsSpan());
+ if (index == -1)
+ {
+ foreach (var c in span)
+ {
+ AppendChar(c);
+ }
+
+ break;
+ }
+
+ if (index == 0)
+ {
+ span = span.Slice("global::".Length);
+ continue;
+ }
+
+ foreach (var c in span.Slice(0, index))
+ {
+ AppendChar(c);
+ }
+
+ span = span.Slice(index + "global::".Length);
+ }
}
- else
+
+ AppendDir(dir);
+
+ if (!string.IsNullOrWhiteSpace(multipleOutSymbol))
{
text = $"#if {multipleOutSymbol}" + Environment.NewLine + text + Environment.NewLine + "#endif";
- return OutputAsync(Path.Combine(dir, MultiSymbolToSafeFilePath(multipleOutSymbol), $"{ns}_{name}".Replace(".", "_").Replace("global::", string.Empty) + ".cs"), text);
+ AppendDir(MultiSymbolToSafeFilePath(multipleOutSymbol));
}
+
+ Append(ns);
+ builder.Append('_');
+ Append(name);
+ builder.Append(".cs");
+
+ return OutputAsync(builder.ToString(), text);
}
private Task OutputAsync(string path, string text)
diff --git a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs b/src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs
index b64b4912..382112a3 100644
--- a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs
+++ b/src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs
@@ -1,10 +1,10 @@
// ------------------------------------------------------------------------------
// <auto-generated>
-// このコードはツールによって生成されました。
-// ランタイム バージョン: 16.0.0.0
+// This code was generated by a tool.
+// Runtime Version: 17.0.0.0
//
-// このファイルへの変更は、正しくない動作の原因になる可能性があり、
-// コードが再生成されると失われます。
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace MessagePackCompiler.Generator
@@ -17,7 +17,7 @@ namespace MessagePackCompiler.Generator
/// <summary>
/// Class to produce the template output
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class EnumTemplate : EnumTemplateBase
{
/// <summary>
@@ -33,28 +33,29 @@ namespace MessagePackCompiler.Generator
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace ");
this.Write(this.ToStringHelper.ToStringWithCulture(Namespace));
- this.Write("\r\n{\r\n using System;\r\n using System.Buffers;\r\n using MessagePack;\r\n");
+ this.Write("\r\n{\r\n");
foreach(var info in EnumSerializationInfos) {
this.Write("\r\n public sealed class ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.Name));
this.Write("Formatter : global::MessagePack.Formatters.IMessagePackFormatter<");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
- this.Write(">\r\n {\r\n public void Serialize(ref MessagePackWriter writer, ");
+ this.Write(">\r\n {\r\n public void Serialize(ref global::MessagePack.MessagePackWriter" +
+ " writer, ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n {\r\n " +
- " writer.Write((");
+ " writer.Write((global::System.");
this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType));
this.Write(")value);\r\n }\r\n\r\n public ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
- this.Write(" Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSeriali" +
- "zerOptions options)\r\n {\r\n return (");
+ this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" +
+ "k.MessagePackSerializerOptions options)\r\n {\r\n return (");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
this.Write(")reader.Read");
this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType));
@@ -67,7 +68,6 @@ namespace ");
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
");
@@ -78,7 +78,7 @@ namespace ");
/// <summary>
/// Base class for this transformation
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public class EnumTemplateBase
{
#region Fields
diff --git a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt b/src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt
index 28d34550..74214c6c 100644
--- a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt
+++ b/src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt
@@ -11,26 +11,23 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace <#= Namespace #>
{
- using System;
- using System.Buffers;
- using MessagePack;
<# foreach(var info in EnumSerializationInfos) { #>
public sealed class <#= info.Name #>Formatter : global::MessagePack.Formatters.IMessagePackFormatter<<#= info.FullName #>>
{
- public void Serialize(ref MessagePackWriter writer, <#= info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options)
{
- writer.Write((<#= info.UnderlyingType #>)value);
+ writer.Write((global::System.<#= info.UnderlyingType #>)value);
}
- public <#= info.FullName #> Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public <#= info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
return (<#= info.FullName #>)reader.Read<#= info.UnderlyingType #>();
}
@@ -43,6 +40,5 @@ namespace <#= Namespace #>
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
diff --git a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs b/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs
index e153d5eb..396d6a52 100644
--- a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs
+++ b/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version: 16.0.0.0
+// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -17,7 +17,7 @@ namespace MessagePackCompiler.Generator
/// <summary>
/// Class to produce the template output
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class FormatterTemplate : FormatterTemplateBase
{
/// <summary>
@@ -33,9 +33,9 @@ namespace MessagePackCompiler.Generator
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -43,10 +43,10 @@ namespace MessagePackCompiler.Generator
namespace ");
this.Write(this.ToStringHelper.ToStringWithCulture(Namespace));
- this.Write("\r\n{\r\n using global::System.Buffers;\r\n using global::MessagePack;\r\n");
+ this.Write("\r\n{\r\n");
foreach (var objInfo in ObjectSerializationInfos) {
bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members);
- this.Write("\r\n public sealed class ");
+ this.Write(" public sealed class ");
this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FormatterNameWithoutNameSpace));
this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<");
this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName));
@@ -205,7 +205,7 @@ namespace ");
}
this.Write(" reader.Depth--;\r\n return ____result;\r\n");
}
- this.Write(" }\r\n }\r\n");
+ this.Write(" }\r\n }\r\n\r\n");
}
this.Write(@"}
@@ -215,7 +215,6 @@ namespace ");
#pragma warning restore 612
#pragma warning restore SA1129 // Do not use default value type constructor
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1309 // Field names should not begin with underscore
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1403 // File may only contain a single namespace
@@ -228,7 +227,7 @@ namespace ");
/// <summary>
/// Base class for this transformation
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public class FormatterTemplateBase
{
#region Fields
diff --git a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt b/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt
index 631dc9f1..240b107f 100644
--- a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt
+++ b/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt
@@ -11,9 +11,9 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -21,11 +21,8 @@
namespace <#= Namespace #>
{
- using global::System.Buffers;
- using global::MessagePack;
<# foreach (var objInfo in ObjectSerializationInfos) {
bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members);#>
-
public sealed class <#= objInfo.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= objInfo.FullName #>>
<# foreach (var typeArg in objInfo.GenericTypeParameters.Where(x => x.HasConstraints)) { #>
where <#= typeArg.Name #> : <#= typeArg.Constraints #>
@@ -155,8 +152,8 @@ namespace <#= Namespace #>
<# } #>
}
}
-<# } #>
-}
+
+<# } #>}
#pragma warning restore 168
#pragma warning restore 414
@@ -164,7 +161,6 @@ namespace <#= Namespace #>
#pragma warning restore 612
#pragma warning restore SA1129 // Do not use default value type constructor
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1309 // Field names should not begin with underscore
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1403 // File may only contain a single namespace
diff --git a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs b/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs
index 48e4df6b..58f20711 100644
--- a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs
+++ b/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version: 16.0.0.0
+// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -17,7 +17,7 @@ namespace MessagePackCompiler.Generator
/// <summary>
/// Class to produce the template output
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class ResolverTemplate : ResolverTemplateBase
{
/// <summary>
@@ -33,14 +33,14 @@ namespace MessagePackCompiler.Generator
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1649 // File name should match first type name
namespace ");
this.Write(this.ToStringHelper.ToStringWithCulture(Namespace));
- this.Write("\r\n{\r\n using System;\r\n\r\n public class ");
+ this.Write("\r\n{\r\n public class ");
this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName));
this.Write(" : global::MessagePack.IFormatterResolver\r\n {\r\n public static readonly " +
"global::MessagePack.IFormatterResolver Instance = new ");
@@ -76,10 +76,10 @@ namespace ");
internal static class ");
this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName));
this.Write("GetFormatterHelper\r\n {\r\n private static readonly global::System.Collect" +
- "ions.Generic.Dictionary<Type, int> lookup;\r\n\r\n static ");
+ "ions.Generic.Dictionary<global::System.Type, int> lookup;\r\n\r\n static ");
this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName));
this.Write("GetFormatterHelper()\r\n {\r\n lookup = new global::System.Collecti" +
- "ons.Generic.Dictionary<Type, int>(");
+ "ons.Generic.Dictionary<global::System.Type, int>(");
this.Write(this.ToStringHelper.ToStringWithCulture(RegisterInfos.Length));
this.Write(")\r\n {\r\n");
for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i];
@@ -92,7 +92,7 @@ namespace ");
this.Write(@" };
}
- internal static object GetFormatter(Type t)
+ internal static object GetFormatter(global::System.Type t)
{
int key;
if (!lookup.TryGetValue(t, out key))
@@ -122,7 +122,6 @@ namespace ");
#pragma warning restore 612
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1649 // File name should match first type name
");
return this.GenerationEnvironment.ToString();
@@ -132,7 +131,7 @@ namespace ");
/// <summary>
/// Base class for this transformation
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public class ResolverTemplateBase
{
#region Fields
diff --git a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt b/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt
index e61688a1..6837185d 100644
--- a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt
+++ b/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt
@@ -11,17 +11,13 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1649 // File name should match first type name
namespace <#= Namespace #>
{
- using System;
- using System.Buffers;
- using MessagePack;
-
public class <#= ResolverName #> : global::MessagePack.IFormatterResolver
{
public static readonly global::MessagePack.IFormatterResolver Instance = new <#= ResolverName #>();
@@ -52,11 +48,11 @@ namespace <#= Namespace #>
internal static class <#= ResolverName #>GetFormatterHelper
{
- private static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup;
+ private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> lookup;
static <#= ResolverName #>GetFormatterHelper()
{
- lookup = new global::System.Collections.Generic.Dictionary<Type, int>(<#= RegisterInfos.Length #>)
+ lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(<#= RegisterInfos.Length #>)
{
<# for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i]; #>
{ typeof(<#= x.FullName #>), <#= i #> },
@@ -64,7 +60,7 @@ namespace <#= Namespace #>
};
}
- internal static object GetFormatter(Type t)
+ internal static object GetFormatter(global::System.Type t)
{
int key;
if (!lookup.TryGetValue(t, out key))
@@ -75,7 +71,7 @@ namespace <#= Namespace #>
switch (key)
{
<# for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i]; #>
- case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName: (!string.IsNullOrEmpty(FormatterNamespace) ? FormatterNamespace + "." : FormatterNamespace) + x.FormatterName#>();
+ case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName: (!string.IsNullOrEmpty(FormatterNamespace) ? FormatterNamespace + "." : FormatterNamespace) + x.FormatterName #>();
<# } #>
default: return null;
}
@@ -89,5 +85,4 @@ namespace <#= Namespace #>
#pragma warning restore 612
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1649 // File name should match first type name
diff --git a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs
index a3df9f44..abc89f78 100644
--- a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs
+++ b/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version: 16.0.0.0
+// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -17,7 +17,7 @@ namespace MessagePackCompiler.Generator
/// <summary>
/// Class to produce the template output
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class StringKeyFormatterTemplate : StringKeyFormatterTemplateBase
{
/// <summary>
@@ -33,9 +33,9 @@ namespace MessagePackCompiler.Generator
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -43,7 +43,7 @@ namespace MessagePackCompiler.Generator
namespace ");
this.Write(this.ToStringHelper.ToStringWithCulture(Namespace));
- this.Write("\r\n{\r\n using global::System.Buffers;\r\n using global::MessagePack;\r\n");
+ this.Write("\r\n{\r\n");
var list = new List<ValueTuple<MemberSerializationInfo, byte[]>>();
foreach (var objInfo in ObjectSerializationInfos) {
list.Clear();
@@ -53,7 +53,7 @@ foreach (var objInfo in ObjectSerializationInfos) {
}
bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members);
- this.Write("\r\n public sealed class ");
+ this.Write(" public sealed class ");
this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FormatterNameWithoutNameSpace));
this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<");
this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName));
@@ -191,9 +191,21 @@ foreach (var objInfo in ObjectSerializationInfos) {
if (objInfo.Members.Length != 0) {
this.Write(" reader.Depth--;\r\n");
}
- this.Write(" return ____result;\r\n }\r\n }\r\n");
+ this.Write(" return ____result;\r\n }\r\n }\r\n\r\n");
}
- this.Write("}\r\n");
+ this.Write(@"}
+
+#pragma warning restore 168
+#pragma warning restore 414
+#pragma warning restore 618
+#pragma warning restore 612
+
+#pragma warning restore SA1129 // Do not use default value type constructor
+#pragma warning restore SA1309 // Field names should not begin with underscore
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+#pragma warning restore SA1403 // File may only contain a single namespace
+#pragma warning restore SA1649 // File name should match first type name
+");
return this.GenerationEnvironment.ToString();
}
}
@@ -201,7 +213,7 @@ foreach (var objInfo in ObjectSerializationInfos) {
/// <summary>
/// Base class for this transformation
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public class StringKeyFormatterTemplateBase
{
#region Fields
diff --git a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt
index 9bc3e4d8..9f0dac87 100644
--- a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt
+++ b/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt
@@ -12,9 +12,9 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -22,8 +22,6 @@
namespace <#= Namespace #>
{
- using global::System.Buffers;
- using global::MessagePack;
<# var list = new List<ValueTuple<MemberSerializationInfo, byte[]>>();
foreach (var objInfo in ObjectSerializationInfos) {
list.Clear();
@@ -33,7 +31,6 @@ foreach (var objInfo in ObjectSerializationInfos) {
}
bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members); #>
-
public sealed class <#= objInfo.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= objInfo.FullName #>>
<# foreach (var typeArg in objInfo.GenericTypeParameters.Where(x => x.HasConstraints)) {#>
where <#= typeArg.Name #> : <#= typeArg.Constraints #>
@@ -147,5 +144,16 @@ foreach (var objInfo in ObjectSerializationInfos) {
return ____result;
}
}
-<# } #>
-}
+
+<# } #>}
+
+#pragma warning restore 168
+#pragma warning restore 414
+#pragma warning restore 618
+#pragma warning restore 612
+
+#pragma warning restore SA1129 // Do not use default value type constructor
+#pragma warning restore SA1309 // Field names should not begin with underscore
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+#pragma warning restore SA1403 // File may only contain a single namespace
+#pragma warning restore SA1649 // File name should match first type name
diff --git a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs b/src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs
index 1106f1cb..b7a639bf 100644
--- a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs
+++ b/src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version: 16.0.0.0
+// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -17,7 +17,7 @@ namespace MessagePackCompiler.Generator
/// <summary>
/// Class to produce the template output
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class UnionTemplate : UnionTemplateBase
{
/// <summary>
@@ -33,39 +33,43 @@ namespace MessagePackCompiler.Generator
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace ");
this.Write(this.ToStringHelper.ToStringWithCulture(Namespace));
- this.Write("\r\n{\r\n using System;\r\n using System.Buffers;\r\n using System.Collections.G" +
- "eneric;\r\n using MessagePack;\r\n\r\n");
+ this.Write("\r\n{\r\n");
foreach(var info in UnionSerializationInfos) {
this.Write(" public sealed class ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.Name));
this.Write("Formatter : global::MessagePack.Formatters.IMessagePackFormatter<");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
- this.Write(">\r\n {\r\n private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int" +
- ", int>> typeToKeyAndJumpMap;\r\n private readonly Dictionary<int, int> keyT" +
- "oJumpMap;\r\n\r\n public ");
+ this.Write(@">
+ {
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
+
+ public ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.Name));
- this.Write("Formatter()\r\n {\r\n this.typeToKeyAndJumpMap = new Dictionary<Run" +
- "timeTypeHandle, KeyValuePair<int, int>>(");
+ this.Write("Formatter()\r\n {\r\n this.typeToKeyAndJumpMap = new global::System" +
+ ".Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System" +
+ ".Collections.Generic.KeyValuePair<int, int>>(");
this.Write(this.ToStringHelper.ToStringWithCulture(info.SubTypes.Length));
this.Write(", global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n " +
" {\r\n");
for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i];
this.Write(" { typeof(");
this.Write(this.ToStringHelper.ToStringWithCulture(item.Type));
- this.Write(").TypeHandle, new KeyValuePair<int, int>(");
+ this.Write(").TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(");
this.Write(this.ToStringHelper.ToStringWithCulture(item.Key));
this.Write(", ");
this.Write(this.ToStringHelper.ToStringWithCulture(i));
this.Write(") },\r\n");
}
- this.Write(" };\r\n this.keyToJumpMap = new Dictionary<int, int>(");
+ this.Write(" };\r\n this.keyToJumpMap = new global::System.Collections.Ge" +
+ "neric.Dictionary<int, int>(");
this.Write(this.ToStringHelper.ToStringWithCulture(info.SubTypes.Length));
this.Write(")\r\n {\r\n");
for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i];
@@ -75,12 +79,12 @@ namespace ");
this.Write(this.ToStringHelper.ToStringWithCulture(i));
this.Write(" },\r\n");
}
- this.Write(" };\r\n }\r\n\r\n public void Serialize(ref MessagePackWriter " +
- "writer, ");
+ this.Write(" };\r\n }\r\n\r\n public void Serialize(ref global::MessagePac" +
+ "k.MessagePackWriter writer, ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
this.Write(@" value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -101,7 +105,7 @@ namespace ");
"\r\n return;\r\n }\r\n\r\n writer.WriteNil();\r\n " +
" }\r\n\r\n public ");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
- this.Write(@" Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ this.Write(@" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -110,7 +114,7 @@ namespace ");
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException(""Invalid Union data was detected. Type:");
+ throw new global::System.InvalidOperationException(""Invalid Union data was detected. Type:");
this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName));
this.Write("\");\r\n }\r\n\r\n options.Security.DepthStep(ref reader);\r\n " +
" var key = reader.ReadInt32();\r\n\r\n if (!this.keyToJumpMap.TryGet" +
@@ -139,7 +143,6 @@ namespace ");
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
");
@@ -150,7 +153,7 @@ namespace ");
/// <summary>
/// Base class for this transformation
/// </summary>
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public class UnionTemplateBase
{
#region Fields
diff --git a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt b/src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt
index 216cf3c3..eb9272d0 100644
--- a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt
+++ b/src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt
@@ -11,33 +11,28 @@
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
+#pragma warning disable CS1591 // document public APIs
-#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace <#= Namespace #>
{
- using System;
- using System.Buffers;
- using System.Collections.Generic;
- using MessagePack;
-
<# foreach(var info in UnionSerializationInfos) { #>
public sealed class <#= info.Name #>Formatter : global::MessagePack.Formatters.IMessagePackFormatter<<#= info.FullName #>>
{
- private readonly Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>> typeToKeyAndJumpMap;
- private readonly Dictionary<int, int> keyToJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>> typeToKeyAndJumpMap;
+ private readonly global::System.Collections.Generic.Dictionary<int, int> keyToJumpMap;
public <#= info.Name #>Formatter()
{
- this.typeToKeyAndJumpMap = new Dictionary<RuntimeTypeHandle, KeyValuePair<int, int>>(<#= info.SubTypes.Length #>, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
+ this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary<global::System.RuntimeTypeHandle, global::System.Collections.Generic.KeyValuePair<int, int>>(<#= info.SubTypes.Length #>, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)
{
<# for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; #>
- { typeof(<#= item.Type #>).TypeHandle, new KeyValuePair<int, int>(<#= item.Key #>, <#= i #>) },
+ { typeof(<#= item.Type #>).TypeHandle, new global::System.Collections.Generic.KeyValuePair<int, int>(<#= item.Key #>, <#= i #>) },
<# } #>
};
- this.keyToJumpMap = new Dictionary<int, int>(<#= info.SubTypes.Length #>)
+ this.keyToJumpMap = new global::System.Collections.Generic.Dictionary<int, int>(<#= info.SubTypes.Length #>)
{
<# for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; #>
{ <#= item.Key #>, <#= i #> },
@@ -45,9 +40,9 @@ namespace <#= Namespace #>
};
}
- public void Serialize(ref MessagePackWriter writer, <#= info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options)
+ public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options)
{
- KeyValuePair<int, int> keyValuePair;
+ global::System.Collections.Generic.KeyValuePair<int, int> keyValuePair;
if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair))
{
writer.WriteArrayHeader(2);
@@ -69,7 +64,7 @@ namespace <#= Namespace #>
writer.WriteNil();
}
- public <#= info.FullName #> Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
+ public <#= info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -78,7 +73,7 @@ namespace <#= Namespace #>
if (reader.ReadArrayHeader() != 2)
{
- throw new InvalidOperationException("Invalid Union data was detected. Type:<#= info.FullName #>");
+ throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:<#= info.FullName #>");
}
options.Security.DepthStep(ref reader);
@@ -116,6 +111,5 @@ namespace <#= Namespace #>
#pragma warning restore 618
#pragma warning restore 612
-#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name
diff --git a/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj b/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj
index 526615e5..df4755e2 100644
--- a/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj
+++ b/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj
@@ -11,9 +11,8 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" />
- <PackageReference Include="Microsoft.Build" Version="15.9.20" />
- <PackageReference Include="System.CodeDom" Version="4.7.0" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
+ <PackageReference Include="System.CodeDom" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs
index 06d2ef80..07da2097 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs
@@ -70,4 +70,50 @@ namespace MessagePack.Formatters
return array;
}
}
+
+#if NET6_0_OR_GREATER
+ /// <summary>
+ /// Serializes a <see cref="DateOnly"/> value as an ordinary <see cref="int"/> using the <see cref="DateOnly.DayNumber"/>.
+ /// </summary>
+ public sealed class DateOnlyFormatter : IMessagePackFormatter<DateOnly>
+ {
+ public static readonly DateOnlyFormatter Instance = new DateOnlyFormatter();
+
+ private DateOnlyFormatter()
+ {
+ }
+
+ public void Serialize(ref MessagePackWriter writer, DateOnly value, MessagePackSerializerOptions options)
+ {
+ writer.Write(value.DayNumber);
+ }
+
+ public DateOnly Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
+ {
+ return DateOnly.FromDayNumber(reader.ReadInt32());
+ }
+ }
+
+ /// <summary>
+ /// Serializes a <see cref="TimeOnly"/> value as an extension, recording either seconds or ticks depending on the resolution required.
+ /// </summary>
+ public sealed class TimeOnlyFormatter : IMessagePackFormatter<TimeOnly>
+ {
+ public static readonly TimeOnlyFormatter Instance = new TimeOnlyFormatter();
+
+ private TimeOnlyFormatter()
+ {
+ }
+
+ public void Serialize(ref MessagePackWriter writer, TimeOnly value, MessagePackSerializerOptions options)
+ {
+ writer.Write(value.Ticks);
+ }
+
+ public TimeOnly Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
+ {
+ return new TimeOnly(reader.ReadInt64());
+ }
+ }
+#endif
}
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs
new file mode 100644
index 00000000..9e07521b
--- /dev/null
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs
@@ -0,0 +1,61 @@
+// Copyright (c) All contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using Microsoft.NET.StringTools;
+
+namespace MessagePack.Formatters
+{
+ /// <summary>
+ /// A <see cref="string" /> formatter that interns strings on deserialization.
+ /// </summary>
+ public sealed class StringInterningFormatter : IMessagePackFormatter<string>
+ {
+ /// <inheritdoc/>
+ public string Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
+ {
+ if (reader.TryReadNil())
+ {
+ return null;
+ }
+
+ MessagePackReader retryReader = reader;
+ if (reader.TryReadStringSpan(out ReadOnlySpan<byte> bytes))
+ {
+ if (bytes.Length < 4096)
+ {
+ if (bytes.Length == 0)
+ {
+ return string.Empty;
+ }
+
+ Span<char> chars = stackalloc char[bytes.Length];
+ int charLength;
+#if SPAN_BUILTIN
+ charLength = StringEncoding.UTF8.GetChars(bytes, chars);
+#else
+ unsafe
+ {
+ fixed (byte* pBytes = bytes)
+ fixed (char* pChars = chars)
+ {
+ charLength = StringEncoding.UTF8.GetChars(pBytes, bytes.Length, pChars, chars.Length);
+ }
+ }
+#endif
+ return Strings.WeakIntern(chars.Slice(0, charLength));
+ }
+ else
+ {
+ // Rewind the reader to the start of the string because we're taking the slow path.
+ reader = retryReader;
+ }
+ }
+
+ return Strings.WeakIntern(reader.ReadString());
+ }
+
+ /// <inheritdoc/>
+ public void Serialize(ref MessagePackWriter writer, string value, MessagePackSerializerOptions options) => writer.Write(value);
+ }
+}
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs.meta b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs.meta
new file mode 100644
index 00000000..329667d4
--- /dev/null
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 78f9cfd44a10b334582b112b07143434
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/Sequence`1.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/Sequence`1.cs
index 9fe752df..2813b92e 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/Sequence`1.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/Sequence`1.cs
@@ -27,7 +27,11 @@ namespace Nerdbank.Streams
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
internal class Sequence<T> : IBufferWriter<T>, IDisposable
{
- private static readonly int DefaultLengthFromArrayPool = 1 + (4095 / Marshal.SizeOf<T>());
+ private const int MaximumAutoGrowSize = 32 * 1024;
+
+ private static readonly int DefaultLengthFromArrayPool = 1 + (4095 / Unsafe.SizeOf<T>());
+
+ private static readonly ReadOnlySequence<T> Empty = new ReadOnlySequence<T>(SequenceSegment.Empty, 0, SequenceSegment.Empty, 0);
private readonly Stack<SequenceSegment> segmentPool = new Stack<SequenceSegment>();
@@ -87,10 +91,22 @@ namespace Nerdbank.Streams
/// The <see cref="MemoryPool{T}"/> in use may itself have a minimum array length as well,
/// in which case the higher of the two minimums dictate the minimum array size that will be allocated.
/// </para>
+ /// <para>
+ /// If <see cref="AutoIncreaseMinimumSpanLength"/> is <c>true</c>, this value may be automatically increased as the length of a sequence grows.
+ /// </para>
/// </remarks>
public int MinimumSpanLength { get; set; } = 0;
/// <summary>
+ /// Gets or sets a value indicating whether the <see cref="MinimumSpanLength"/> should be
+ /// intelligently increased as the length of the sequence grows.
+ /// </summary>
+ /// <remarks>
+ /// This can help prevent long sequences made up of many very small arrays.
+ /// </remarks>
+ public bool AutoIncreaseMinimumSpanLength { get; set; } = true;
+
+ /// <summary>
/// Gets this sequence expressed as a <see cref="ReadOnlySequence{T}"/>.
/// </summary>
/// <returns>A read only sequence representing the data in this object.</returns>
@@ -112,9 +128,9 @@ namespace Nerdbank.Streams
/// <param name="sequence">The sequence to convert.</param>
public static implicit operator ReadOnlySequence<T>(Sequence<T> sequence)
{
- return sequence.first != null
+ return sequence.first != null && sequence.last != null
? new ReadOnlySequence<T>(sequence.first, sequence.first.Start, sequence.last, sequence.last.End)
- : ReadOnlySequence<T>.Empty;
+ : Empty;
}
/// <summary>
@@ -128,10 +144,22 @@ namespace Nerdbank.Streams
public void AdvanceTo(SequencePosition position)
{
var firstSegment = (SequenceSegment)position.GetObject();
+ if (firstSegment == null)
+ {
+ // Emulate PipeReader behavior which is to just return for default(SequencePosition)
+ return;
+ }
+
+ if (ReferenceEquals(firstSegment, SequenceSegment.Empty) && this.Length == 0)
+ {
+ // We were called with our own empty buffer segment.
+ return;
+ }
+
int firstIndex = position.GetInteger();
// Before making any mutations, confirm that the block specified belongs to this sequence.
- var current = this.first;
+ Sequence<T>.SequenceSegment current = this.first;
while (current != firstSegment && current != null)
{
current = current.Next;
@@ -151,12 +179,7 @@ namespace Nerdbank.Streams
firstSegment.AdvanceTo(firstIndex);
- if (firstSegment.Length == 0)
- {
- firstSegment = this.RecycleAndGetNext(firstSegment);
- }
-
- this.first = firstSegment;
+ this.first = firstSegment.Length == 0 ? this.RecycleAndGetNext(firstSegment) : firstSegment;
if (this.first == null)
{
@@ -174,6 +197,7 @@ namespace Nerdbank.Streams
SequenceSegment last = this.last;
Verify.Operation(last != null, "Cannot advance before acquiring memory.");
last.Advance(count);
+ this.ConsiderMinimumSizeIncrease();
}
/// <summary>
@@ -191,6 +215,24 @@ namespace Nerdbank.Streams
public Span<T> GetSpan(int sizeHint) => this.GetSegment(sizeHint).RemainingSpan;
/// <summary>
+ /// Adds an existing memory location to this sequence without copying.
+ /// </summary>
+ /// <param name="memory">The memory to add.</param>
+ /// <remarks>
+ /// This *may* leave significant slack space in a previously allocated block if calls to <see cref="Append(ReadOnlyMemory{T})"/>
+ /// follow calls to <see cref="GetMemory(int)"/> or <see cref="GetSpan(int)"/>.
+ /// </remarks>
+ public void Append(ReadOnlyMemory<T> memory)
+ {
+ if (memory.Length > 0)
+ {
+ Sequence<T>.SequenceSegment segment = this.segmentPool.Count > 0 ? this.segmentPool.Pop() : new SequenceSegment();
+ segment.AssignForeign(memory);
+ this.Append(segment);
+ }
+ }
+
+ /// <summary>
/// Clears the entire sequence, recycles associated memory into pools,
/// and resets this instance for reuse.
/// This invalidates any <see cref="ReadOnlySequence{T}"/> previously produced by this instance.
@@ -204,7 +246,7 @@ namespace Nerdbank.Streams
/// </summary>
public void Reset()
{
- var current = this.first;
+ Sequence<T>.SequenceSegment current = this.first;
while (current != null)
{
current = this.RecycleAndGetNext(current);
@@ -236,7 +278,7 @@ namespace Nerdbank.Streams
if (minBufferSize.HasValue)
{
- var segment = this.segmentPool.Count > 0 ? this.segmentPool.Pop() : new SequenceSegment();
+ Sequence<T>.SequenceSegment segment = this.segmentPool.Count > 0 ? this.segmentPool.Pop() : new SequenceSegment();
if (this.arrayPool != null)
{
segment.Assign(this.arrayPool.Rent(minBufferSize.Value == -1 ? DefaultLengthFromArrayPool : minBufferSize.Value));
@@ -268,7 +310,7 @@ namespace Nerdbank.Streams
else
{
// The last block is completely unused. Replace it instead of appending to it.
- var current = this.first;
+ Sequence<T>.SequenceSegment current = this.first;
if (this.first != this.last)
{
while (current.Next != this.last)
@@ -291,24 +333,40 @@ namespace Nerdbank.Streams
private SequenceSegment RecycleAndGetNext(SequenceSegment segment)
{
- var recycledSegment = segment;
- segment = segment.Next;
+ Sequence<T>.SequenceSegment recycledSegment = segment;
+ Sequence<T>.SequenceSegment nextSegment = segment.Next;
recycledSegment.ResetMemory(this.arrayPool);
this.segmentPool.Push(recycledSegment);
- return segment;
+ return nextSegment;
+ }
+
+ private void ConsiderMinimumSizeIncrease()
+ {
+ if (this.AutoIncreaseMinimumSpanLength && this.MinimumSpanLength < MaximumAutoGrowSize)
+ {
+ int autoSize = Math.Min(MaximumAutoGrowSize, (int)Math.Min(int.MaxValue, this.Length / 2));
+ if (this.MinimumSpanLength < autoSize)
+ {
+ this.MinimumSpanLength = autoSize;
+ }
+ }
}
private class SequenceSegment : ReadOnlySequenceSegment<T>
{
+ internal static readonly SequenceSegment Empty = new SequenceSegment();
+
/// <summary>
/// A value indicating whether the element may contain references (and thus must be cleared).
/// </summary>
private static readonly bool MayContainReferences = !typeof(T).GetTypeInfo().IsPrimitive;
+#pragma warning disable SA1011 // Closing square brackets should be spaced correctly
/// <summary>
/// Gets the backing array, when using an <see cref="ArrayPool{T}"/> instead of a <see cref="MemoryPool{T}"/>.
/// </summary>
private T[] array;
+#pragma warning restore SA1011 // Closing square brackets should be spaced correctly
/// <summary>
/// Gets the position within <see cref="ReadOnlySequenceSegment{T}.Memory"/> where the data starts.
@@ -363,6 +421,11 @@ namespace Nerdbank.Streams
}
/// <summary>
+ /// Gets a value indicating whether this segment refers to memory that came from outside and that we cannot write to nor recycle.
+ /// </summary>
+ internal bool IsForeignMemory => this.array == null && this.MemoryOwner == null;
+
+ /// <summary>
/// Assigns this (recyclable) segment a new area in memory.
/// </summary>
/// <param name="memoryOwner">The memory and a means to recycle it.</param>
@@ -383,11 +446,21 @@ namespace Nerdbank.Streams
}
/// <summary>
+ /// Assigns this (recyclable) segment a new area in memory.
+ /// </summary>
+ /// <param name="memory">A memory block obtained from outside, that we do not own and should not recycle.</param>
+ internal void AssignForeign(ReadOnlyMemory<T> memory)
+ {
+ this.Memory = memory;
+ this.End = memory.Length;
+ }
+
+ /// <summary>
/// Clears all fields in preparation to recycle this instance.
/// </summary>
internal void ResetMemory(ArrayPool<T> arrayPool)
{
- this.ClearReferences(this.Start, this.End);
+ this.ClearReferences(this.Start, this.End - this.Start);
this.Memory = default;
this.Next = null;
this.RunningIndex = 0;
@@ -411,14 +484,17 @@ namespace Nerdbank.Streams
/// <param name="segment">The next segment in the linked list.</param>
internal void SetNext(SequenceSegment segment)
{
- Debug.Assert(segment != null, "Null not allowed.");
this.Next = segment;
segment.RunningIndex = this.RunningIndex + this.Start + this.Length;
- // When setting Memory, we start with index 0 instead of this.Start because
- // the first segment has an explicit index set anyway,
- // and we don't want to double-count it here.
- this.Memory = this.AvailableMemory.Slice(0, this.Start + this.Length);
+ // Trim any slack on this segment.
+ if (!this.IsForeignMemory)
+ {
+ // When setting Memory, we start with index 0 instead of this.Start because
+ // the first segment has an explicit index set anyway,
+ // and we don't want to double-count it here.
+ this.Memory = this.AvailableMemory.Slice(0, this.Start + this.Length);
+ }
}
/// <summary>
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef
index f1e851eb..ff7f5b38 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef
@@ -13,9 +13,10 @@
"System.Buffers.dll",
"System.Threading.Tasks.Extensions.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
+ "Microsoft.NET.StringTools.dll",
"System.Runtime.Extensions.dll"
],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
-} \ No newline at end of file
+}
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs
index 1d604957..38e39985 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs
@@ -171,7 +171,7 @@ namespace MessagePack
}
scratchWriter.Flush();
- ToLZ4BinaryCore(scratchRental.Value, ref writer, options.Compression);
+ ToLZ4BinaryCore(scratchRental.Value, ref writer, options.Compression, options.CompressionMinLength);
}
}
else
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs
index a4f902f5..f3773f70 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs
@@ -18,8 +18,7 @@ namespace MessagePack
[System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Each overload has sufficiently unique required parameters.")]
public static partial class MessagePackSerializer
{
- private const int LZ4NotCompressionSizeInLz4BlockType = 64;
- private const int MaxHintSize = 1024 * 1024;
+ private static MessagePackSerializerOptions defaultOptions;
/// <summary>
/// Gets or sets the default set of options to use when not explicitly specified for a method call.
@@ -33,7 +32,20 @@ namespace MessagePack
/// If you are an app author, realize that setting this property impacts the entire application so it should only be
/// set once, and before any use of <see cref="MessagePackSerializer"/> occurs.
/// </remarks>
- public static MessagePackSerializerOptions DefaultOptions { get; set; } = MessagePackSerializerOptions.Standard;
+ public static MessagePackSerializerOptions DefaultOptions
+ {
+ get
+ {
+ if (defaultOptions is null)
+ {
+ defaultOptions = MessagePackSerializerOptions.Standard;
+ }
+
+ return defaultOptions;
+ }
+
+ set => defaultOptions = value;
+ }
/// <summary>
/// A thread-local, recyclable array that may be used for short bursts of code.
@@ -92,7 +104,7 @@ namespace MessagePack
MessagePackWriter scratchWriter = writer.Clone(scratch);
options.Resolver.GetFormatterWithVerify<T>().Serialize(ref scratchWriter, value, options);
scratchWriter.Flush();
- ToLZ4BinaryCore(scratch, ref writer, options.Compression);
+ ToLZ4BinaryCore(scratch, ref writer, options.Compression, options.CompressionMinLength);
}
}
else
@@ -348,7 +360,7 @@ namespace MessagePack
do
{
cancellationToken.ThrowIfCancellationRequested();
- Span<byte> span = sequence.GetSpan(stream.CanSeek ? (int)Math.Min(MaxHintSize, stream.Length - stream.Position) : 0);
+ Span<byte> span = sequence.GetSpan(stream.CanSeek ? (int)Math.Min(options.SuggestedContiguousMemorySize, stream.Length - stream.Position) : 0);
bytesRead = stream.Read(span);
sequence.Advance(bytesRead);
}
@@ -396,7 +408,7 @@ namespace MessagePack
int bytesRead;
do
{
- Memory<byte> memory = sequence.GetMemory(stream.CanSeek ? (int)Math.Min(MaxHintSize, stream.Length - stream.Position) : 0);
+ Memory<byte> memory = sequence.GetMemory(stream.CanSeek ? (int)Math.Min(options.SuggestedContiguousMemorySize, stream.Length - stream.Position) : 0);
bytesRead = await stream.ReadAsync(memory, cancellationToken).ConfigureAwait(false);
sequence.Advance(bytesRead);
}
@@ -567,16 +579,16 @@ namespace MessagePack
return false;
}
- private static void ToLZ4BinaryCore(in ReadOnlySequence<byte> msgpackUncompressedData, ref MessagePackWriter writer, MessagePackCompression compression)
+ private static void ToLZ4BinaryCore(in ReadOnlySequence<byte> msgpackUncompressedData, ref MessagePackWriter writer, MessagePackCompression compression, int minCompressionSize)
{
- if (compression == MessagePackCompression.Lz4Block)
+ if (msgpackUncompressedData.Length < minCompressionSize)
{
- if (msgpackUncompressedData.Length < LZ4NotCompressionSizeInLz4BlockType)
- {
- writer.WriteRaw(msgpackUncompressedData);
- return;
- }
+ writer.WriteRaw(msgpackUncompressedData);
+ return;
+ }
+ if (compression == MessagePackCompression.Lz4Block)
+ {
var maxCompressedLength = LZ4Codec.MaximumOutputLength((int)msgpackUncompressedData.Length);
var lz4Span = ArrayPool<byte>.Shared.Rent(maxCompressedLength);
try
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs
index bc1557b0..de2bb4b8 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs
@@ -42,7 +42,7 @@ namespace MessagePack
/// <summary>
/// Initializes a new instance of the <see cref="MessagePackSerializerOptions"/> class.
/// </summary>
- protected internal MessagePackSerializerOptions(IFormatterResolver resolver)
+ public MessagePackSerializerOptions(IFormatterResolver resolver)
{
this.Resolver = resolver ?? throw new ArgumentNullException(nameof(resolver));
}
@@ -61,6 +61,8 @@ namespace MessagePack
this.Resolver = copyFrom.Resolver;
this.Compression = copyFrom.Compression;
+ this.CompressionMinLength = copyFrom.CompressionMinLength;
+ this.SuggestedContiguousMemorySize = copyFrom.SuggestedContiguousMemorySize;
this.OldSpec = copyFrom.OldSpec;
this.OmitAssemblyVersion = copyFrom.OmitAssemblyVersion;
this.AllowAssemblyVersionMismatch = copyFrom.AllowAssemblyVersionMismatch;
@@ -86,6 +88,26 @@ namespace MessagePack
public MessagePackCompression Compression { get; private set; }
/// <summary>
+ /// Gets the length a serialized msgpack result must equal or exceed before <see cref="Compression"/> is applied.
+ /// </summary>
+ /// <value>The default value is 64.</value>
+ /// <remarks>
+ /// When compression is <em>not</em> applied due to a short serialized result, deserialization will still succeed
+ /// even if <see cref="Compression"/> is set to something other than <see cref="MessagePackCompression.None"/>.
+ /// </remarks>
+ public int CompressionMinLength { get; private set; } = 64;
+
+ /// <summary>
+ /// Gets the size of contiguous memory blocks in bytes that may be allocated for buffering purposes.
+ /// </summary>
+ /// <value>The default value is 1MB.</value>
+ /// <remarks>
+ /// Larger values may perform a bit faster, but may result in adding a runtime perf tax due to using the
+ /// <see href="https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/large-object-heap">Large Object Heap</see>.
+ /// </remarks>
+ public int SuggestedContiguousMemorySize { get; private set; } = 1024 * 1024;
+
+ /// <summary>
/// Gets a value indicating whether to serialize with <see cref="MessagePackWriter.OldSpec"/> set to some value
/// causing messagepack spec compliance to be explicitly set to the old or new format.
/// </summary>
@@ -199,6 +221,50 @@ namespace MessagePack
}
/// <summary>
+ /// Gets a copy of these options with the <see cref="CompressionMinLength"/> property set to a new value.
+ /// </summary>
+ /// <param name="compressionMinLength">The new value for the <see cref="CompressionMinLength"/> property. Must be a positive integer.</param>
+ /// <returns>The new instance; or the original if the value is unchanged.</returns>
+ public MessagePackSerializerOptions WithCompressionMinLength(int compressionMinLength)
+ {
+ if (this.CompressionMinLength == compressionMinLength)
+ {
+ return this;
+ }
+
+ if (compressionMinLength <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(compressionMinLength));
+ }
+
+ var result = this.Clone();
+ result.CompressionMinLength = compressionMinLength;
+ return result;
+ }
+
+ /// <summary>
+ /// Gets a copy of these options with the <see cref="SuggestedContiguousMemorySize"/> property set to a new value.
+ /// </summary>
+ /// <param name="suggestedContiguousMemorySize">The new value for the <see cref="SuggestedContiguousMemorySize"/> property. Must be at least 256.</param>
+ /// <returns>The new instance; or the original if the value is unchanged.</returns>
+ public MessagePackSerializerOptions WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize)
+ {
+ if (this.SuggestedContiguousMemorySize == suggestedContiguousMemorySize)
+ {
+ return this;
+ }
+
+ if (suggestedContiguousMemorySize < 256)
+ {
+ throw new ArgumentOutOfRangeException(nameof(suggestedContiguousMemorySize), "This should be at least 256");
+ }
+
+ var result = this.Clone();
+ result.SuggestedContiguousMemorySize = suggestedContiguousMemorySize;
+ return result;
+ }
+
+ /// <summary>
/// Gets a copy of these options with the <see cref="OldSpec"/> property set to a new value.
/// </summary>
/// <param name="oldSpec">The new value for the <see cref="OldSpec"/>.</param>
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs
index 000b9fbd..0defd99f 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs
@@ -64,9 +64,13 @@ namespace MessagePack.Internal
{ typeof(byte), ByteFormatter.Instance },
{ typeof(sbyte), SByteFormatter.Instance },
{ typeof(DateTime), DateTimeFormatter.Instance },
+#if NET6_0_OR_GREATER
+ { typeof(DateOnly), DateOnlyFormatter.Instance },
+ { typeof(TimeOnly), TimeOnlyFormatter.Instance },
+#endif
{ typeof(char), CharFormatter.Instance },
- // Nulllable Primitive
+ // Nullable Primitive
{ typeof(Int16?), NullableInt16Formatter.Instance },
{ typeof(Int32?), NullableInt32Formatter.Instance },
{ typeof(Int64?), NullableInt64Formatter.Instance },
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json
index 677cba61..19011e4f 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json
@@ -1,7 +1,7 @@
{
"name": "com.neuecc.messagepack",
"displayName": "MessagePack",
- "version": "2.3.74",
+ "version": "2.4.25",
"unity": "2018.4",
"description": "Extremely Fast MessagePack Serializer for C#.",
"keywords": [
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackSerializerOptionsTests.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackSerializerOptionsTests.cs
index 96bec149..0db5157c 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackSerializerOptionsTests.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackSerializerOptionsTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
using MessagePack;
using MessagePack.Resolvers;
using Xunit;
@@ -13,7 +14,8 @@ public class MessagePackSerializerOptionsTests
.WithOmitAssemblyVersion(true)
.WithResolver(BuiltinResolver.Instance)
.WithOldSpec(false)
- .WithSecurity(MySecurityOptions.Instance);
+ .WithSecurity(MySecurityOptions.Instance)
+ .WithSuggestedContiguousMemorySize(64 * 1024);
[Fact]
public void AllowAssemblyVersionMismatch()
@@ -37,6 +39,26 @@ public class MessagePackSerializerOptionsTests
}
[Fact]
+ public void CompressionMinLength()
+ {
+ Assert.Equal(64, MessagePackSerializerOptions.Standard.CompressionMinLength);
+ Assert.Throws<ArgumentOutOfRangeException>(() => MessagePackSerializerOptions.Standard.WithCompressionMinLength(0));
+ Assert.Throws<ArgumentOutOfRangeException>(() => MessagePackSerializerOptions.Standard.WithCompressionMinLength(-1));
+ MessagePackSerializerOptions options = MessagePackSerializerOptions.Standard.WithCompressionMinLength(128);
+ Assert.Equal(128, options.CompressionMinLength);
+ }
+
+ [Fact]
+ public void SuggestedContiguousMemorySize()
+ {
+ Assert.Equal(1024 * 1024, MessagePackSerializerOptions.Standard.SuggestedContiguousMemorySize);
+ Assert.Throws<ArgumentOutOfRangeException>(() => MessagePackSerializerOptions.Standard.WithSuggestedContiguousMemorySize(0));
+ Assert.Throws<ArgumentOutOfRangeException>(() => MessagePackSerializerOptions.Standard.WithSuggestedContiguousMemorySize(4));
+ MessagePackSerializerOptions options = MessagePackSerializerOptions.Standard.WithSuggestedContiguousMemorySize(512);
+ Assert.Equal(512, options.SuggestedContiguousMemorySize);
+ }
+
+ [Fact]
public void OldSpec()
{
Assert.Null(MessagePackSerializerOptions.Standard.OldSpec);
@@ -63,6 +85,7 @@ public class MessagePackSerializerOptionsTests
var mutated = NonDefaultOptions.WithOldSpec(true);
Assert.True(mutated.OldSpec.Value);
Assert.Equal(NonDefaultOptions.Compression, mutated.Compression);
+ Assert.Equal(NonDefaultOptions.SuggestedContiguousMemorySize, mutated.SuggestedContiguousMemorySize);
Assert.Equal(NonDefaultOptions.AllowAssemblyVersionMismatch, mutated.AllowAssemblyVersionMismatch);
Assert.Equal(NonDefaultOptions.OmitAssemblyVersion, mutated.OmitAssemblyVersion);
Assert.Same(NonDefaultOptions.Resolver, mutated.Resolver);
@@ -82,11 +105,25 @@ public class MessagePackSerializerOptionsTests
}
[Fact]
+ public void WithSuggestedContiguousMemorySize_PreservesOtherProperties()
+ {
+ var mutated = NonDefaultOptions.WithSuggestedContiguousMemorySize(612);
+ Assert.Equal(612, mutated.SuggestedContiguousMemorySize);
+ Assert.Equal(NonDefaultOptions.Compression, mutated.Compression);
+ Assert.Equal(NonDefaultOptions.OldSpec, mutated.OldSpec);
+ Assert.Equal(NonDefaultOptions.AllowAssemblyVersionMismatch, mutated.AllowAssemblyVersionMismatch);
+ Assert.Equal(NonDefaultOptions.OmitAssemblyVersion, mutated.OmitAssemblyVersion);
+ Assert.Same(NonDefaultOptions.Resolver, mutated.Resolver);
+ Assert.Same(MySecurityOptions.Instance, mutated.Security);
+ }
+
+ [Fact]
public void WithAllowAssemblyVersionMismatch_PreservesOtherProperties()
{
var mutated = NonDefaultOptions.WithAllowAssemblyVersionMismatch(false);
Assert.False(mutated.AllowAssemblyVersionMismatch);
Assert.Equal(NonDefaultOptions.Compression, mutated.Compression);
+ Assert.Equal(NonDefaultOptions.SuggestedContiguousMemorySize, mutated.SuggestedContiguousMemorySize);
Assert.Equal(NonDefaultOptions.OldSpec, mutated.OldSpec);
Assert.Equal(NonDefaultOptions.OmitAssemblyVersion, mutated.OmitAssemblyVersion);
Assert.Same(NonDefaultOptions.Resolver, mutated.Resolver);
@@ -99,6 +136,7 @@ public class MessagePackSerializerOptionsTests
var mutated = NonDefaultOptions.WithOmitAssemblyVersion(false);
Assert.False(mutated.OmitAssemblyVersion);
Assert.Equal(NonDefaultOptions.Compression, mutated.Compression);
+ Assert.Equal(NonDefaultOptions.SuggestedContiguousMemorySize, mutated.SuggestedContiguousMemorySize);
Assert.Equal(NonDefaultOptions.OldSpec, mutated.OldSpec);
Assert.Equal(NonDefaultOptions.AllowAssemblyVersionMismatch, mutated.AllowAssemblyVersionMismatch);
Assert.Same(NonDefaultOptions.Resolver, mutated.Resolver);
@@ -111,6 +149,7 @@ public class MessagePackSerializerOptionsTests
var mutated = NonDefaultOptions.WithResolver(ContractlessStandardResolver.Instance);
Assert.Same(ContractlessStandardResolver.Instance, mutated.Resolver);
Assert.Equal(NonDefaultOptions.Compression, mutated.Compression);
+ Assert.Equal(NonDefaultOptions.SuggestedContiguousMemorySize, mutated.SuggestedContiguousMemorySize);
Assert.Equal(NonDefaultOptions.OldSpec, mutated.OldSpec);
Assert.Equal(NonDefaultOptions.AllowAssemblyVersionMismatch, mutated.AllowAssemblyVersionMismatch);
Assert.Equal(NonDefaultOptions.OmitAssemblyVersion, mutated.OmitAssemblyVersion);
@@ -124,6 +163,7 @@ public class MessagePackSerializerOptionsTests
Assert.Same(MessagePackSecurity.TrustedData, mutated.Security);
Assert.Same(NonDefaultOptions.Resolver, mutated.Resolver);
Assert.Equal(NonDefaultOptions.Compression, mutated.Compression);
+ Assert.Equal(NonDefaultOptions.SuggestedContiguousMemorySize, mutated.SuggestedContiguousMemorySize);
Assert.Equal(NonDefaultOptions.OldSpec, mutated.OldSpec);
Assert.Equal(NonDefaultOptions.AllowAssemblyVersionMismatch, mutated.AllowAssemblyVersionMismatch);
Assert.Equal(NonDefaultOptions.OmitAssemblyVersion, mutated.OmitAssemblyVersion);
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackWriterTests.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackWriterTests.cs
index 5d06e78d..85d29365 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackWriterTests.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackWriterTests.cs
@@ -10,6 +10,7 @@ using System.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;
+using MessagePackWriterCref = MessagePack.MessagePackWriter;
namespace MessagePack.Tests
{
@@ -33,7 +34,7 @@ namespace MessagePack.Tests
#endif
/// <summary>
- /// Verifies that <see cref="MessagePackWriter.WriteRaw(ReadOnlySpan{byte})"/>
+ /// Verifies that <see cref="MessagePackWriterCref.WriteRaw(ReadOnlySpan{byte})"/>
/// accepts a span that came from stackalloc.
/// </summary>
[Fact]
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StandardClassLibraryFormatterTests.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StandardClassLibraryFormatterTests.cs
index 12abda44..35123476 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StandardClassLibraryFormatterTests.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StandardClassLibraryFormatterTests.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
-using System.Linq;
+using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;
@@ -77,5 +77,60 @@ namespace MessagePack.Tests
byte[] byte_array = MessagePackSerializer.Deserialize<byte[]>(input);
Assert.Equal(new byte[] { 1, 2, 3 }, byte_array);
}
+
+#if NET6_0_OR_GREATER
+ [Fact]
+ public void DateOnly()
+ {
+ var value = new DateOnly(2012, 3, 5);
+ this.AssertRoundtrip(value);
+ this.AssertRoundtrip<DateOnly?>(value);
+ this.AssertRoundtrip(new[] { value });
+ }
+
+ [Fact]
+ public void TimeOnly()
+ {
+ TimeOnly lowRes = new TimeOnly(5, 4, 3);
+ this.AssertRoundtrip(lowRes);
+ this.AssertRoundtrip<TimeOnly?>(lowRes);
+ this.AssertRoundtrip(new[] { lowRes });
+
+ TimeOnly mediumRes = new TimeOnly(5, 4, 3, 2);
+ this.AssertRoundtrip(mediumRes);
+ this.AssertRoundtrip<TimeOnly?>(mediumRes);
+ this.AssertRoundtrip(new[] { mediumRes });
+
+ TimeOnly highRes = new TimeOnly(lowRes.Ticks + 1);
+ this.AssertRoundtrip(highRes);
+ this.AssertRoundtrip(System.TimeOnly.MaxValue);
+ }
+#endif
+
+ private void AssertRoundtrip<T>(T value)
+ {
+ Assert.Equal(value, this.Roundtrip(value, breakupBuffer: false));
+ Assert.Equal(value, this.Roundtrip(value, breakupBuffer: true));
+ }
+
+ private T Roundtrip<T>(T value, bool breakupBuffer = false)
+ {
+ byte[] msgpack = MessagePackSerializer.Serialize(value, MessagePackSerializerOptions.Standard);
+ this.logger.WriteLine("{0} 0x{1}", value, TestUtilities.ToHex(msgpack));
+
+ if (breakupBuffer)
+ {
+ using (Sequence<byte> seq = new Sequence<byte>())
+ {
+ seq.Append(msgpack.AsMemory(0, msgpack.Length - 1));
+ seq.Append(msgpack.AsMemory(msgpack.Length - 1, 1));
+ return MessagePackSerializer.Deserialize<T>(seq, MessagePackSerializerOptions.Standard);
+ }
+ }
+ else
+ {
+ return MessagePackSerializer.Deserialize<T>(msgpack, MessagePackSerializerOptions.Standard);
+ }
+ }
}
}
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs
new file mode 100644
index 00000000..d4e98f77
--- /dev/null
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs
@@ -0,0 +1,107 @@
+// Copyright (c) All contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using MessagePack.Formatters;
+using MessagePack.Resolvers;
+using Nerdbank.Streams;
+using Xunit;
+
+namespace MessagePack.Tests
+{
+ public class StringInterningTests
+ {
+ [Fact]
+ public void NullString()
+ {
+ var seq = new Sequence<byte>();
+ var writer = new MessagePackWriter(seq);
+ writer.WriteNil();
+ writer.Flush();
+
+ var reader = new MessagePackReader(seq);
+ string result = StandardResolver.Instance.GetFormatter<string>().Deserialize(ref reader, MessagePackSerializerOptions.Standard);
+ Assert.Null(result);
+ }
+
+ [Fact]
+ public void EmptyString()
+ {
+ var seq = new Sequence<byte>();
+ var writer = new MessagePackWriter(seq);
+ writer.Write(string.Empty);
+ writer.Flush();
+
+ var reader = new MessagePackReader(seq);
+ string result = StandardResolver.Instance.GetFormatter<string>().Deserialize(ref reader, MessagePackSerializerOptions.Standard);
+ Assert.Same(string.Empty, result);
+ }
+
+ [Theory]
+ [InlineData(3)]
+ [InlineData(1024 * 1024)]
+ public void EquivalentStringsGetSharedInstance(int length)
+ {
+ string originalValue1 = new string('a', length);
+ string originalValue3 = new string('b', length);
+ var seq = new Sequence<byte>();
+ var writer = new MessagePackWriter(seq);
+ writer.Write(originalValue1);
+ writer.Write(originalValue1);
+ writer.Write(originalValue3);
+ writer.Flush();
+
+ var reader = new MessagePackReader(seq);
+ var formatter = new StringInterningFormatter();
+ string value1 = formatter.Deserialize(ref reader, MessagePackSerializerOptions.Standard);
+ string value2 = formatter.Deserialize(ref reader, MessagePackSerializerOptions.Standard);
+ string value3 = formatter.Deserialize(ref reader, MessagePackSerializerOptions.Standard);
+
+ Assert.Equal(originalValue1, value1);
+ Assert.Equal(originalValue3, value3);
+
+ Assert.Same(value1, value2);
+ }
+
+ [Fact]
+ public void StringMemberInterning()
+ {
+ ClassOfStrings before = new ClassOfStrings { InternedString = "abc", OrdinaryString = "def" };
+ ClassOfStrings after1 = MessagePackSerializer.Deserialize<ClassOfStrings>(MessagePackSerializer.Serialize(before, MessagePackSerializerOptions.Standard), MessagePackSerializerOptions.Standard);
+ ClassOfStrings after2 = MessagePackSerializer.Deserialize<ClassOfStrings>(MessagePackSerializer.Serialize(before, MessagePackSerializerOptions.Standard), MessagePackSerializerOptions.Standard);
+ Assert.Equal(after1.InternedString, after2.InternedString);
+ Assert.Equal(after1.OrdinaryString, after2.OrdinaryString);
+
+ Assert.Same(after1.InternedString, after2.InternedString);
+ Assert.NotSame(after1.OrdinaryString, after2.OrdinaryString);
+ }
+
+ [Fact]
+ public void StringMemberInterning_CustomResolver()
+ {
+ var options = MessagePackSerializerOptions.Standard.WithResolver(
+ CompositeResolver.Create(
+ new IMessagePackFormatter[] { new StringInterningFormatter() },
+ new IFormatterResolver[] { StandardResolver.Instance }));
+
+ ClassOfStrings before = new ClassOfStrings { InternedString = "abc", OrdinaryString = "def" };
+ ClassOfStrings after1 = MessagePackSerializer.Deserialize<ClassOfStrings>(MessagePackSerializer.Serialize(before, options), options);
+ ClassOfStrings after2 = MessagePackSerializer.Deserialize<ClassOfStrings>(MessagePackSerializer.Serialize(before, options), options);
+ Assert.Equal(after1.InternedString, after2.InternedString);
+ Assert.Equal(after1.OrdinaryString, after2.OrdinaryString);
+
+ Assert.Same(after1.InternedString, after2.InternedString);
+ Assert.Same(after1.OrdinaryString, after2.OrdinaryString);
+ }
+
+ [MessagePackObject]
+ public class ClassOfStrings
+ {
+ [Key(0)]
+ [MessagePackFormatter(typeof(StringInterningFormatter))]
+ public string InternedString { get; set; }
+
+ [Key(1)]
+ public string OrdinaryString { get; set; }
+ }
+ }
+}
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs.meta b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs.meta
new file mode 100644
index 00000000..a6117b9c
--- /dev/null
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 593d09755237d984a95626a65167c3a7
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/TestUtilities.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/TestUtilities.cs
index 0a4bf9fb..abc85b0f 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/TestUtilities.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/TestUtilities.cs
@@ -15,6 +15,8 @@ namespace MessagePack.Tests
/// Gets a value indicating whether the mono runtime is executing this code.
/// </summary>
internal static bool IsRunningOnMono => Type.GetType("Mono.Runtime") != null;
+
+ internal static string ToHex(byte[] buffer) => BitConverter.ToString(buffer).Replace("-", string.Empty).ToLowerInvariant();
}
public class NullTestOutputHelper : ITestOutputHelper
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/Shims/XUnit.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/Shims/XUnit.cs
index c83b4d51..f1eee269 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/Shims/XUnit.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/Shims/XUnit.cs
@@ -130,6 +130,11 @@ namespace Xunit
{
NUnit.Framework.Assert.AreSame(expected, actual);
}
+
+ public static void NotSame(object expected, object actual)
+ {
+ NUnit.Framework.Assert.AreNotSame(expected, actual);
+ }
}
[Serializable]
diff --git a/src/MessagePack.UnityClient/copy_assets.bat b/src/MessagePack.UnityClient/copy_assets.bat
index bb7232df..c2b03f0e 100644
--- a/src/MessagePack.UnityClient/copy_assets.bat
+++ b/src/MessagePack.UnityClient/copy_assets.bat
@@ -11,6 +11,7 @@
echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Buffers.dll" ".\Assets\Plugins\System.Buffers.dll" /Y /I
echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Memory.dll" ".\Assets\Plugins\System.Memory.dll" /Y /I
echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Runtime.CompilerServices.Unsafe.dll" ".\Assets\Plugins\System.Runtime.CompilerServices.Unsafe.dll" /Y /I
+echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\Microsoft.NET.StringTools.dll" ".\Assets\Plugins\Microsoft.NET.StringTools.dll" /Y /I
echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Threading.Tasks.Extensions.dll" ".\Assets\Plugins\System.Threading.Tasks.Extensions.dll" /Y /I
@popd
diff --git a/src/MessagePack.UnityClient/copy_assets.sh b/src/MessagePack.UnityClient/copy_assets.sh
index 9912ab97..7743fd66 100755
--- a/src/MessagePack.UnityClient/copy_assets.sh
+++ b/src/MessagePack.UnityClient/copy_assets.sh
@@ -21,4 +21,5 @@ fi
cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Buffers.dll ${SCRIPT_DIR}/Assets/Plugins/System.Buffers.dll
cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Memory.dll ${SCRIPT_DIR}/Assets/Plugins/System.Memory.dll
cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Runtime.CompilerServices.Unsafe.dll ${SCRIPT_DIR}/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll
+cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/Microsoft.NET.StringTools.dll ${SCRIPT_DIR}/Assets/Plugins/Microsoft.NET.StringTools.dll
cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Threading.Tasks.Extensions.dll ${SCRIPT_DIR}/Assets/Plugins/System.Threading.Tasks.Extensions.dll
diff --git a/src/MessagePack/MessagePack.csproj b/src/MessagePack/MessagePack.csproj
index bffdded8..801ab7de 100644
--- a/src/MessagePack/MessagePack.csproj
+++ b/src/MessagePack/MessagePack.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks>netstandard2.0;netcoreapp3.1;net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS0649</NoWarn>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DefineConstants Condition=" '$(TargetFramework)' != 'netstandard2.0' ">$(DefineConstants);SPAN_BUILTIN</DefineConstants>
@@ -33,16 +33,15 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.2" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.NET.StringTools" Version="1.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
- <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
- <PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
- <PackageReference Include="System.Reflection.Emit" Version="4.6.0" />
- <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.6.0" />
- <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
- <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
- <PackageReference Include="System.Memory" Version="4.5.3" />
+ <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
+ <PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
+ <PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
+ <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
+ <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>
<ItemGroup>
diff --git a/src/MessagePack/net5.0/PublicAPI.Unshipped.txt b/src/MessagePack/net5.0/PublicAPI.Unshipped.txt
index e69de29b..49e84ad1 100644
--- a/src/MessagePack/net5.0/PublicAPI.Unshipped.txt
+++ b/src/MessagePack/net5.0/PublicAPI.Unshipped.txt
@@ -0,0 +1,6 @@
+MessagePack.Formatters.StringInterningFormatter
+MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> string
+MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> void
+MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int
+MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions \ No newline at end of file
diff --git a/src/MessagePack/netcoreapp2.1/PublicAPI.Shipped.txt b/src/MessagePack/net6.0/PublicAPI.Shipped.txt
index c7fc0219..b0a1a3dc 100644
--- a/src/MessagePack/netcoreapp2.1/PublicAPI.Shipped.txt
+++ b/src/MessagePack/net6.0/PublicAPI.Shipped.txt
@@ -1015,9 +1015,7 @@ MessagePack.MessagePackSerializerOptions.Security.get -> MessagePack.MessagePack
MessagePack.MessagePackSerializerOptions.WithSecurity(MessagePack.MessagePackSecurity security) -> MessagePack.MessagePackSerializerOptions
MessagePack.MessagePackStreamReader.DiscardBufferedData() -> void
MessagePack.MessagePackStreamReader.MessagePackStreamReader(System.IO.Stream stream, bool leaveOpen) -> void
-MessagePack.MessagePackStreamReader.ReadArrayHeaderAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<int>
MessagePack.MessagePackStreamReader.ReadArrayAsync(System.Threading.CancellationToken cancellationToken) -> System.Collections.Generic.IAsyncEnumerable<System.Buffers.ReadOnlySequence<byte>>
-MessagePack.MessagePackStreamReader.ReadMapHeaderAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<int>
MessagePack.MessagePackWriter.WriteBinHeader(int length) -> void
MessagePack.MessagePackWriter.WriteStringHeader(int byteCount) -> void
static readonly MessagePack.MessagePackSecurity.TrustedData -> MessagePack.MessagePackSecurity
@@ -1155,10 +1153,17 @@ virtual MessagePack.Formatters.PrimitiveObjectFormatter.DeserializeMap(ref Messa
MessagePack.ExtensionHeader.ExtensionHeader() -> void
MessagePack.ExtensionResult.ExtensionResult() -> void
MessagePack.FormatterNotRegisteredException.FormatterNotRegisteredException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void
+MessagePack.Formatters.HalfFormatter
+MessagePack.Formatters.HalfFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> System.Half
+MessagePack.Formatters.HalfFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Half value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.Formatters.InterfaceReadOnlySetFormatter<T>
+MessagePack.Formatters.InterfaceReadOnlySetFormatter<T>.InterfaceReadOnlySetFormatter() -> void
MessagePack.MessagePackReader.MessagePackReader() -> void
MessagePack.MessagePackSerializerOptions.SequencePool.get -> MessagePack.SequencePool
MessagePack.MessagePackSerializerOptions.WithPool(MessagePack.SequencePool pool) -> MessagePack.MessagePackSerializerOptions
MessagePack.MessagePackStreamReader.MessagePackStreamReader(System.IO.Stream stream, bool leaveOpen, MessagePack.SequencePool sequencePool) -> void
+MessagePack.MessagePackStreamReader.ReadArrayHeaderAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<int>
+MessagePack.MessagePackStreamReader.ReadMapHeaderAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<int>
MessagePack.MessagePackWriter.MessagePackWriter() -> void
MessagePack.SequencePool
MessagePack.SequencePool.SequencePool() -> void
@@ -1167,6 +1172,7 @@ MessagePack.SequencePool.SequencePool(int maxSize, System.Buffers.ArrayPool<byte
MessagePack.TinyJsonException.TinyJsonException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void
static MessagePack.Nil.operator !=(MessagePack.Nil left, MessagePack.Nil right) -> bool
static MessagePack.Nil.operator ==(MessagePack.Nil left, MessagePack.Nil right) -> bool
+static readonly MessagePack.Formatters.HalfFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter<System.Half>
virtual MessagePack.MessagePackStreamReader.Dispose(bool disposing) -> void
MessagePack.Formatters.GenericEnumerableFormatter<TElement, TCollection>
MessagePack.Formatters.GenericEnumerableFormatter<TElement, TCollection>.GenericEnumerableFormatter() -> void
diff --git a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt
new file mode 100644
index 00000000..89697310
--- /dev/null
+++ b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt
@@ -0,0 +1,16 @@
+MessagePack.Formatters.DateOnlyFormatter
+MessagePack.Formatters.DateOnlyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> System.DateOnly
+MessagePack.Formatters.DateOnlyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateOnly value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.Formatters.StringInterningFormatter
+MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> string
+MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> void
+MessagePack.Formatters.TimeOnlyFormatter
+MessagePack.Formatters.TimeOnlyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> System.TimeOnly
+MessagePack.Formatters.TimeOnlyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.TimeOnly value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int
+MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int
+MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions
+MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions
+static readonly MessagePack.Formatters.DateOnlyFormatter.Instance -> MessagePack.Formatters.DateOnlyFormatter
+static readonly MessagePack.Formatters.TimeOnlyFormatter.Instance -> MessagePack.Formatters.TimeOnlyFormatter
diff --git a/src/MessagePack/netcoreapp2.1/PublicAPI.Unshipped.txt b/src/MessagePack/netcoreapp2.1/PublicAPI.Unshipped.txt
deleted file mode 100644
index e69de29b..00000000
--- a/src/MessagePack/netcoreapp2.1/PublicAPI.Unshipped.txt
+++ /dev/null
diff --git a/src/MessagePack/netcoreapp3.1/PublicAPI.Unshipped.txt b/src/MessagePack/netcoreapp3.1/PublicAPI.Unshipped.txt
index e69de29b..ba449cac 100644
--- a/src/MessagePack/netcoreapp3.1/PublicAPI.Unshipped.txt
+++ b/src/MessagePack/netcoreapp3.1/PublicAPI.Unshipped.txt
@@ -0,0 +1,8 @@
+MessagePack.Formatters.StringInterningFormatter
+MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> string
+MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> void
+MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int
+MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int
+MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions
+MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions
diff --git a/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt b/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt
index e69de29b..2cdd3d32 100644
--- a/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt
+++ b/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt
@@ -0,0 +1,8 @@
+MessagePack.Formatters.StringInterningFormatter
+MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> string
+MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string value, MessagePack.MessagePackSerializerOptions options) -> void
+MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> void
+MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int
+MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int
+MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions
+MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions \ No newline at end of file
diff --git a/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj b/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj
index 99ef099c..0844ff4e 100644
--- a/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj
+++ b/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj
@@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
- <PackageReference Include="Nerdbank.Streams" Version="2.4.48" />
+ <PackageReference Include="Nerdbank.Streams" Version="2.8.57" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj
index 9f399389..7c12e7f5 100644
--- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj
+++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj
@@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
- <PackageReference Include="Nerdbank.Streams" Version="2.4.48" />
+ <PackageReference Include="Nerdbank.Streams" Version="2.8.57" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
diff --git a/tests/MessagePack.Tests/MessagePack.Tests.csproj b/tests/MessagePack.Tests/MessagePack.Tests.csproj
index 2e5229df..5fb26383 100644
--- a/tests/MessagePack.Tests/MessagePack.Tests.csproj
+++ b/tests/MessagePack.Tests/MessagePack.Tests.csproj
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFrameworks>net472;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <LangVersion>9.0</LangVersion>
+ <LangVersion>10</LangVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<NoWarn>$(NoWarn);CS1701</NoWarn>
@@ -27,7 +27,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MsgPack.Cli" version="0.9.0-beta2" />
- <PackageReference Include="Nerdbank.Streams" Version="2.4.48" />
+ <PackageReference Include="Nerdbank.Streams" Version="2.8.57" />
<PackageReference Include="ReactiveProperty" version="4.2.2" />
<PackageReference Include="xunit" version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1
index fac05df7..0606d802 100755
--- a/tools/Install-DotNetSdk.ps1
+++ b/tools/Install-DotNetSdk.ps1
@@ -29,6 +29,12 @@ $DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot
# Look up actual required .NET Core SDK version from global.json
$sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1"
+$arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture
+if (!$arch) { # Windows Powershell leaves this blank
+ $arch = 'x64'
+ if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' }
+}
+
# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them.
$runtimeVersions = @()
$windowsDesktopRuntimeVersions = @()
@@ -44,13 +50,22 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\tests\*.*proj","$
}
}
}
- $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% {
+ $targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% {
$v = $Matches[1]
$runtimeVersions += $v
if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) {
$windowsDesktopRuntimeVersions += $v
}
}
+
+ # Add target frameworks of the form: netXX
+ $targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% {
+ $v = $Matches[1]
+ $runtimeVersions += $v
+ if (-not ($IsMacOS -or $IsLinux)) {
+ $windowsDesktopRuntimeVersions += $v
+ }
+ }
}
Function Get-FileFromWeb([Uri]$Uri, $OutDir) {
@@ -77,7 +92,7 @@ Function Get-InstallerExe($Version, [switch]$Runtime) {
$Version = $versionInfo[-1]
}
- Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-x64.exe" -OutDir "$DotNetInstallScriptRoot"
+ Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-$arch.exe" -OutDir "$DotNetInstallScriptRoot"
}
Function Install-DotNet($Version, [switch]$Runtime) {
@@ -94,7 +109,7 @@ Function Install-DotNet($Version, [switch]$Runtime) {
}
$switches = @(
- '-Architecture','x64'
+ '-Architecture',$arch
)
$envVars = @{
# For locally installed dotnet, skip first time experience which takes a long time
@@ -142,10 +157,10 @@ if ($DotNetInstallDir) {
}
if ($IsMacOS -or $IsLinux) {
- $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/49d5da7f7d313aa65d24fe95cc29767faef553fd/src/dotnet-install.sh"
+ $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.sh"
$DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh"
} else {
- $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/49d5da7f7d313aa65d24fe95cc29767faef553fd/src/dotnet-install.ps1"
+ $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.ps1"
$DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1"
}
diff --git a/version.json b/version.json
index 5d063bf1..fff14ab3 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "2.3",
+ "version": "2.4",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/v1\\.x$",