Skip to content

Commit 433774b

Browse files
committed
Merge remote-tracking branch 'origin/master' into support-record
2 parents f2b42ec + e03f2aa commit 433774b

File tree

9 files changed

+81
-6
lines changed

9 files changed

+81
-6
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ MessagePack has a compact binary size and a full set of general purpose expressi
4444
- [Be careful when copying buffers](#be-careful-when-copying-buffers)
4545
- [Choosing compression](#choosing-compression)
4646
- [Extensions](#extensions)
47+
- [Experimental Features](#experimental-features)
4748
- [High-Level API (`MessagePackSerializer`)](#high-level-api-messagepackserializer)
4849
- [Multiple MessagePack structures on a single `Stream`](#multiple-messagepack-structures-on-a-single-stream)
4950
- [Low-Level API (`IMessagePackFormatter<T>`)](#low-level-api-imessagepackformattert)
@@ -993,6 +994,16 @@ You can make your own extension serializers or integrate with frameworks. Let's
993994
* [WebApiContrib.Core.Formatter.MessagePack](https://github.com/WebApiContrib/WebAPIContrib.Core#formatters) - supports ASP.NET Core MVC ([details in blog post](https://www.strathweb.com/2017/06/using-messagepack-with-asp-net-core-mvc/))
994995
* [MessagePack.MediaTypeFormatter](https://github.com/sketch7/MessagePack.MediaTypeFormatter) - MessagePack MediaTypeFormatter
995996

997+
## Experimental Features
998+
999+
MessagePack for C# has experimental features which provides you with very performant formatters. There is an official package.
1000+
1001+
```ps1
1002+
Install-Package MessagePack.Experimental
1003+
```
1004+
1005+
For detailed information, see: [Experimental.md](src/MessagePack.Experimental/Experimental.md)
1006+
9961007
# API
9971008

9981009
## High-Level API (`MessagePackSerializer`)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# MessagePack.Experimental
2+
3+
This C# project is the experimental project for the features which are very complex, unstable or unsafe.
4+
5+
- [HardwareIntrinsics](HardwareIntrinsics/HardwareIntrinsics.md)
6+
- [UnsafeUnmanagedStructFormatter](UnsafeUnmanagedStructFormatter/UnsafeUnmanagedStructFormatter.md)
7+
8+
**Caution!**
9+
10+
`MessagePack.Experimental` only targets `.NET Core 3.1` and above.
11+
You can not use this in Unity and .NET Framework.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Abstract
2+
3+
`Hardware Intrinsics` is a feature in order to utilize maximum power of the cpu.
4+
You can serialize/deserialize primitive type array much faster than current implementation!
5+
6+
Supported types
7+
8+
- `sbyte[]`
9+
- `short[]`
10+
- `int[]`
11+
- `bool[]`
12+
- `float[]`
13+
- `double[]`
14+
15+
# Usage
16+
17+
```csharp
18+
var resolver = MessagePack.Resolvers.CompositeResolver.Create(new[] { PrimitiveArrayResolver.Instance, MessagePack.Resolvers.StandardResolver.Instance });
19+
```
20+
21+
# When will this feature become official?
22+
23+
- The MessagePack-CSharp's lowest target framework is greater or equals to `.NET Core 3.1`.
24+
- The current very complex and hard to understand implementation is rewritten.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Abstract
2+
3+
`UnsafeUnmanagedStructFormatter`s (de)serialize the blittable value(s) directly.
4+
They are very performant but unstable against the endian.
5+
6+
You should be careful not to share the encoded byte[] among the different endian environments.
7+
8+
Supported types (T where T : unamanaged)
9+
10+
- `T``UnsafeUnmanagedStructFormatter<T>`
11+
- `T[]``UnsafeUnmanagedStructArrayFormatter<T>`
12+
- `Memory<T>``UnsafeUnmanagedStructMemoryFormatter<T>`
13+
- `ReadOnlyMemory<T>``UnsafeUnmanagedStructReadOnlyMemoryFormatter<T>`
14+
- `ReadOnlySequence<T>``UnsafeUnmanagedStructReadOnlySequenceFormatter<T>`
15+
16+
# Usage
17+
18+
```csharp
19+
var resolver = MessagePack.Resolvers.CompositeResolver.Create(
20+
new[] { new UnsafeUnmanagedStructFormatter<Matrix4x4>(typeCode: 96) },
21+
new[] { MessagePack.Resolvers.StandardResolver.Instance });
22+
```
23+
24+
The constructor takes 1 sbyte value.
25+
The sbyte value is the extension type code embedded in serialized byte sequence.
26+
27+
# When will this feature become official?
28+
29+
- Requests are needed.

src/MessagePack.Generator/MessagepackCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ await Host.CreateDefaultBuilder()
3939
}
4040

4141
public async Task RunAsync(
42-
[Option("i", "Input path of analyze MSBuild project file or directory, if input multiple project files split with ','.")] string input,
42+
[Option("i", "Input path to MSBuild project file or the directory containing Unity source files.")] string input,
4343
[Option("o", "Output file path(.cs) or directory (multiple generate file).")] string output,
4444
[Option("c", "Conditional compiler symbols, split with ','. Ignored if a project file is specified for input.")] string? conditionalSymbol = null,
4545
[Option("r", "Set resolver name.")] string resolverName = "GeneratedResolver",

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ private BigIntegerFormatter()
476476

477477
public void Serialize(ref MessagePackWriter writer, System.Numerics.BigInteger value, MessagePackSerializerOptions options)
478478
{
479-
#if NETCOREAPP2_1
479+
#if NETCOREAPP
480480
if (!writer.OldSpec)
481481
{
482482
// try to get bin8 buffer.
@@ -504,7 +504,7 @@ public void Serialize(ref MessagePackWriter writer, System.Numerics.BigInteger v
504504
public System.Numerics.BigInteger Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
505505
{
506506
ReadOnlySequence<byte> bytes = reader.ReadBytes().Value;
507-
#if NETCOREAPP2_1
507+
#if NETCOREAPP
508508
if (bytes.IsSingleSegment)
509509
{
510510
return new System.Numerics.BigInteger(bytes.First.Span);

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ private string ReadStringSlow(int byteLength)
11091109
int bytesRead = Math.Min(remainingByteLength, this.reader.UnreadSpan.Length);
11101110
remainingByteLength -= bytesRead;
11111111
bool flush = remainingByteLength == 0;
1112-
#if NETCOREAPP2_1
1112+
#if NETCOREAPP
11131113
initializedChars += decoder.GetChars(this.reader.UnreadSpan.Slice(0, bytesRead), charArray.AsSpan(initializedChars), flush);
11141114
#else
11151115
unsafe

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StringEncoding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal static class StringEncoding
1313
{
1414
internal static readonly Encoding UTF8 = new UTF8Encoding(false);
1515

16-
#if !NETCOREAPP2_1 // Define the extension method only where an instance method does not already exist.
16+
#if !NETCOREAPP // Define the extension method only where an instance method does not already exist.
1717
internal static unsafe string GetString(this Encoding encoding, ReadOnlySpan<byte> bytes)
1818
{
1919
if (bytes.Length == 0)

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async void OnGUI()
150150
invokingMpc = true;
151151
try
152152
{
153-
var log = await ProcessHelper.InvokeProcessStartAsync("mpc " + commnadLineArguments);
153+
var log = await ProcessHelper.InvokeProcessStartAsync("mpc", commnadLineArguments);
154154
UnityEngine.Debug.Log(log);
155155
}
156156
finally

0 commit comments

Comments
 (0)