Skip to content

Commit

Permalink
Merge pull request #27 from Cysharp/netstandard21
Browse files Browse the repository at this point in the history
.NET Standard 2.1 Support(.NET 5, 6 and Unity)
  • Loading branch information
neuecc authored Oct 16, 2022
2 parents f60fdc0 + dc90ca0 commit fd750f8
Show file tree
Hide file tree
Showing 264 changed files with 20,303 additions and 180 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- uses: actions/checkout@v3
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: '7.0' # require 7.0-rc
dotnet-version: |
6.0.x
7.0.x
include-prerelease: 'true'
- run: dotnet build -c Debug
- run: dotnet test -c Debug --no-build
8 changes: 6 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
- uses: actions/checkout@v3
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: '7.0' # require 7.0-rc
dotnet-version: |
6.0.x
7.0.x
include-prerelease: 'true'
# pack nuget
- run: dotnet build -c Release -p:Version=${{ env.GIT_TAG }}
Expand All @@ -43,7 +45,9 @@ jobs:
# tag
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: '7.0' # require 7.0-rc
dotnet-version: |
6.0.x
7.0.x
include-prerelease: 'true'
- uses: actions/checkout@v3
- name: tag
Expand Down
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,19 @@ nuget/*.unitypackage
# Jetbrains Rider
.idea/

# Unity

__packages/

sandbox/SandboxConsoleApp/MemoryPackLogs/
/sandbox/SandboxWebApp/node_modules

# Unity

src/MemoryPack.Unity/Library/*
src/MemoryPack.Unity/Temp/*
src/MemoryPack.Unity/Logs/*

src/MemoryPack.Unity/*.csproj
src/MemoryPack.Unity/*.sln
src/MemoryPack.Unity/MemoryPack.1.0.0.unitypackage

src/MemoryPack.Unity/MemoryPack.1.4.0.unitypackage
57 changes: 57 additions & 0 deletions MemoryPack.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,101 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SandboxWebApp", "sandbox\Sa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MemoryPack.AspNetCoreMvcFormatter", "src\MemoryPack.AspNetCoreMvcFormatter\MemoryPack.AspNetCoreMvcFormatter.csproj", "{64B20612-4990-40C7-8191-E2A033CD1EF5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SandboxNet6", "sandbox\SandboxNet6\SandboxNet6.csproj", "{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{C56A9A52-EE3A-44A5-A8EA-AE36C79FFB6C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PostBuildUtility", "tools\PostBuildUtility\PostBuildUtility.csproj", "{06384E50-13CE-4AA2-90B3-5EC116B06D01}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MemoryPack.Tests.Roslyn3", "tests\MemoryPack.Tests.Roslyn3\MemoryPack.Tests.Roslyn3.csproj", "{E2C01D05-E7F1-4151-B536-90B138AF18EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MemoryPack.Generator.Roslyn3", "src\MemoryPack.Generator.Roslyn3\MemoryPack.Generator.Roslyn3.csproj", "{0F57F162-9C68-4E0F-B89B-2EED31B69F38}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
WinBenchmark|Any CPU = WinBenchmark|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{03BF8319-91FB-4ABA-8FA2-E7D088C94E5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03BF8319-91FB-4ABA-8FA2-E7D088C94E5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03BF8319-91FB-4ABA-8FA2-E7D088C94E5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03BF8319-91FB-4ABA-8FA2-E7D088C94E5D}.Release|Any CPU.Build.0 = Release|Any CPU
{03BF8319-91FB-4ABA-8FA2-E7D088C94E5D}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{03BF8319-91FB-4ABA-8FA2-E7D088C94E5D}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{668B187F-726A-4558-90DB-019C332E51F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{668B187F-726A-4558-90DB-019C332E51F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{668B187F-726A-4558-90DB-019C332E51F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{668B187F-726A-4558-90DB-019C332E51F0}.Release|Any CPU.Build.0 = Release|Any CPU
{668B187F-726A-4558-90DB-019C332E51F0}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{668B187F-726A-4558-90DB-019C332E51F0}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{1C22BB73-56D7-4C13-99BA-D7C25C45510F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C22BB73-56D7-4C13-99BA-D7C25C45510F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C22BB73-56D7-4C13-99BA-D7C25C45510F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C22BB73-56D7-4C13-99BA-D7C25C45510F}.Release|Any CPU.Build.0 = Release|Any CPU
{1C22BB73-56D7-4C13-99BA-D7C25C45510F}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{1C22BB73-56D7-4C13-99BA-D7C25C45510F}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{92BFD932-2627-496D-BECA-4160C895C397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92BFD932-2627-496D-BECA-4160C895C397}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92BFD932-2627-496D-BECA-4160C895C397}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92BFD932-2627-496D-BECA-4160C895C397}.Release|Any CPU.Build.0 = Release|Any CPU
{92BFD932-2627-496D-BECA-4160C895C397}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{92BFD932-2627-496D-BECA-4160C895C397}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{4118975E-9AA8-4CB1-9C49-BD3DE1B45581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4118975E-9AA8-4CB1-9C49-BD3DE1B45581}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4118975E-9AA8-4CB1-9C49-BD3DE1B45581}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4118975E-9AA8-4CB1-9C49-BD3DE1B45581}.Release|Any CPU.Build.0 = Release|Any CPU
{4118975E-9AA8-4CB1-9C49-BD3DE1B45581}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{4118975E-9AA8-4CB1-9C49-BD3DE1B45581}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{71898098-EA11-4839-AAD2-D4CB974D98E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71898098-EA11-4839-AAD2-D4CB974D98E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71898098-EA11-4839-AAD2-D4CB974D98E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71898098-EA11-4839-AAD2-D4CB974D98E7}.Release|Any CPU.Build.0 = Release|Any CPU
{71898098-EA11-4839-AAD2-D4CB974D98E7}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{71898098-EA11-4839-AAD2-D4CB974D98E7}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F}.Release|Any CPU.Build.0 = Release|Any CPU
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0}.Release|Any CPU.Build.0 = Release|Any CPU
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{64B20612-4990-40C7-8191-E2A033CD1EF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64B20612-4990-40C7-8191-E2A033CD1EF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64B20612-4990-40C7-8191-E2A033CD1EF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64B20612-4990-40C7-8191-E2A033CD1EF5}.Release|Any CPU.Build.0 = Release|Any CPU
{64B20612-4990-40C7-8191-E2A033CD1EF5}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{64B20612-4990-40C7-8191-E2A033CD1EF5}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}.Release|Any CPU.Build.0 = Release|Any CPU
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}.WinBenchmark|Any CPU.ActiveCfg = Release|Any CPU
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2}.WinBenchmark|Any CPU.Build.0 = Release|Any CPU
{06384E50-13CE-4AA2-90B3-5EC116B06D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06384E50-13CE-4AA2-90B3-5EC116B06D01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06384E50-13CE-4AA2-90B3-5EC116B06D01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06384E50-13CE-4AA2-90B3-5EC116B06D01}.Release|Any CPU.Build.0 = Release|Any CPU
{06384E50-13CE-4AA2-90B3-5EC116B06D01}.WinBenchmark|Any CPU.ActiveCfg = WinBenchmark|Any CPU
{06384E50-13CE-4AA2-90B3-5EC116B06D01}.WinBenchmark|Any CPU.Build.0 = WinBenchmark|Any CPU
{E2C01D05-E7F1-4151-B536-90B138AF18EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2C01D05-E7F1-4151-B536-90B138AF18EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2C01D05-E7F1-4151-B536-90B138AF18EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2C01D05-E7F1-4151-B536-90B138AF18EF}.Release|Any CPU.Build.0 = Release|Any CPU
{E2C01D05-E7F1-4151-B536-90B138AF18EF}.WinBenchmark|Any CPU.ActiveCfg = Debug|Any CPU
{E2C01D05-E7F1-4151-B536-90B138AF18EF}.WinBenchmark|Any CPU.Build.0 = Debug|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.Release|Any CPU.Build.0 = Release|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.WinBenchmark|Any CPU.ActiveCfg = Debug|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.WinBenchmark|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -83,6 +136,10 @@ Global
{31F067EA-3E16-47DD-A6E6-9AFDDD82E22F} = {796FB992-A35C-405B-82A7-4C90C5673174}
{F9D66CB1-8D28-426B-BB12-C9F5D30EC6A0} = {796FB992-A35C-405B-82A7-4C90C5673174}
{64B20612-4990-40C7-8191-E2A033CD1EF5} = {81B295E0-EEDE-4D5B-B4AC-1202D5E6B3CF}
{87C0CEAA-E511-46AA-93AB-AF742A1F8EE2} = {796FB992-A35C-405B-82A7-4C90C5673174}
{06384E50-13CE-4AA2-90B3-5EC116B06D01} = {C56A9A52-EE3A-44A5-A8EA-AE36C79FFB6C}
{E2C01D05-E7F1-4151-B536-90B138AF18EF} = {204004F9-9B91-4DD1-812C-80D629169ED5}
{0F57F162-9C68-4E0F-B89B-2EED31B69F38} = {81B295E0-EEDE-4D5B-B4AC-1202D5E6B3CF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01ADF7A3-0758-4A3C-9A18-AEF0F30B6E1B}
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# MemoryPack
[![GitHub Actions](https://github.com/Cysharp/MemoryPack/workflows/Build-Debug/badge.svg)](https://github.com/Cysharp/MemoryPack/actions) [![Releases](https://img.shields.io/github/release/Cysharp/MemoryPack.svg)](https://github.com/Cysharp/MemoryPack/releases)

Zero encoding extreme performance binary serializer for C#.
Zero encoding extreme performance binary serializer for C# and Unity.

![image](https://user-images.githubusercontent.com/46207/192748136-262ac2e7-4646-46e1-afb8-528a51a4a987.png)

For standard object, MemoryPack is x3 faster than MessagePack for C#. For struct array, MemoryPack gots boosted power, x50~100 faster than other serializers.

MemoryPack is my 4th serializer, previously I've created well known serializers, ~~[ZeroFormatter](https://github.com/neuecc/ZeroFormatter)~~, ~~[Utf8Json](https://github.com/neuecc/Utf8Json)~~, [MessagePack for C#](https://github.com/neuecc/MessagePack-CSharp). The reason for MemoryPack's speed is due to its C#-specific, C#-optimized binary format and a well tuned implementation based on my past experience. It is also a completely new design utilizing .NET 7 and C# 11 and the Incremental Source Generator.
MemoryPack is my 4th serializer, previously I've created well known serializers, ~~[ZeroFormatter](https://github.com/neuecc/ZeroFormatter)~~, ~~[Utf8Json](https://github.com/neuecc/Utf8Json)~~, [MessagePack for C#](https://github.com/neuecc/MessagePack-CSharp). The reason for MemoryPack's speed is due to its C#-specific, C#-optimized binary format and a well tuned implementation based on my past experience. It is also a completely new design utilizing .NET 7 and C# 11 and the Incremental Source Generator(.NET Standard 2.1(.NET 5, 6) and Unity support is also exists).

Other serializers performs many encoding operations such as VarInt encoding, tag, string, etc. MemoryPack format uses a zero-encoding design that copies as much of the C# memory as possible. zero-encoding is similar as FlatBuffers but don't need special type, MemoryPack's serialize target is POCO.

Expand All @@ -20,22 +20,17 @@ Other than performance, MemoryPack has these features.
* Polymorphism(Union) serialization
* PipeWriter/Reader based streaming serialization
* TypeScript code generation and ASP.NET Core Formatter

> Currently support target framework is .NET 7 only, however, I'm now working for .NET Standard 2.1(.NET 5, 6) and Unity(2021.2) support. Stay tuned.
* Unity(2021.3) IL2CPP Support via .NET Source Generator

Installation
---
This library is distributed via NuGet. Minimum requirement is `.NET 7 RC1`.
This library is distributed via NuGet. For best performance, recommend to use `.NET 7`. Minimum requirement is `.NET Standard 2.1`.

> PM> Install-Package [MemoryPack](https://www.nuget.org/packages/MemoryPack)
And you need to enable preview features to `.csproj`.
And also editor requires Roslyn 4.3.0 support, for example Visual Studio 2022 version 17.3. For details, see [Roslyn Version Support](https://learn.microsoft.com/en-us/visualstudio/extensibility/roslyn-version-support2) document.

```xml
<PropertyGroup>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
</PropertyGroup>
```
For Unity, the requirements and installation process are completely different. See the [Unity](#unity) section for details.

Quick Start
---
Expand Down Expand Up @@ -745,11 +740,19 @@ The created formatter is registered with `MemoryPackFormatterProvider`.
MemoryPackFormatterProvider.Register(new SkeltonFormatter());
```

Unity support
Unity
---
Currently MemoryPack dependents .NET 7 runtime, incremental generator and C# 11. Therefore it will not work in Unity. .NET 7 support is planned for Unity 2025.
Install via UPM git URL package or asset package(MemoryPack.*.*.*.unitypackage) available in [MemoryPack/releases](https://github.com/Cysharp/MemoryPack/releases) page.

* https://github.com/Cysharp/MemoryPack.git?path=src/MemoryPack.Unity/Assets/Plugins/MemoryPack

Supporting minimum Unity version is `2021.3`. The dependency managed DLL `System.Runtime.CompilerSErvices.Unsafe/6.0.0` is included with unitypackage. For git references, you will need to add them in another way as they are not included to avoid unnecessary dependencies; either extract the dll from unitypackage or download it from the [NuGet page](https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/6.0.0).

As with the .NET version, the code is generated by a code generator(`MemoryPack.Generator.Roslyn3.dll`). Reflection-free implementation also provides the best performance in IL2CPP.

For more information on Unity and Source Generator, please refer to the [Unity documentation](https://docs.unity3d.com/Manual/roslyn-analyzers.html).

However, now working for .NET Standard 2.1 support(see [PR #27](https://github.com/Cysharp/MemoryPack/pull/27)), it can run on Unity 2021. Stay tuned.
Source Generator is also used officially by Unity by [com.unity.properties](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) and [com.unity.entities](https://docs.unity3d.com/Packages/[email protected]/changelog/CHANGELOG.html). In other words, it is the standard for code generation in the next generation of Unity.

Binary wire format specification
---
Expand Down
1 change: 0 additions & 1 deletion sandbox/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand Down
2 changes: 2 additions & 0 deletions sandbox/Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Benchmark.Benchmarks;
using Benchmark.Micro;
using Benchmark.Models;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Exporters;
Expand All @@ -19,6 +20,7 @@

var config = ManualConfig.CreateMinimumViable()
.AddDiagnoser(MemoryDiagnoser.Default)
.AddColumn(StatisticColumn.OperationsPerSecond)
.AddExporter(DefaultExporters.Plain)
.AddExporter(MarkdownExporter.Default)
.AddJob(Job.Default.WithWarmupCount(1).WithIterationCount(1)); // .AddJob(Job.ShortRun);
Expand Down
1 change: 0 additions & 1 deletion sandbox/SandboxConsoleApp/SandboxConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
16 changes: 16 additions & 0 deletions sandbox/SandboxNet6/NamespaceTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using MemoryPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SandboxNet6
{
[MemoryPackable]
public partial class NamespaceTest
{
public int MyProperty { get; set; }
}

}
74 changes: 74 additions & 0 deletions sandbox/SandboxNet6/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// See https://aka.ms/new-console-template for more information
using MemoryPack;
using System.Buffers;
using System.Runtime.CompilerServices;


// System.Buffers.IBufferWriter<byte>
Console.WriteLine("Hello, World!");

[MemoryPackable]
public partial class HelloMemoryPackable
{
public int MyProperty { get; set; }
}


[MemoryPackable]
public partial class HelloMemoryPackable2
{
public HelloMemoryPackable? MyProperty { get; set; }
// public TypeAccessException My3Property { get; set; }
}


[MemoryPackable]
[MemoryPackUnion(0, typeof(FooClass))]
[MemoryPackUnion(249, typeof(BarClass))]
public partial interface IUnionSample
{
}

[MemoryPackable]
public partial class FooClass : IUnionSample
{
public int XYZ { get; set; }
}

[MemoryPackable]
public partial class BarClass : IUnionSample
{
public string? OPQ { get; set; }
}


[MemoryPackable]
public partial struct IncludesReferenceStruct
{
public int X;
public string? Y;
}


[MemoryPackable]
[MemoryPackUnion(0, typeof(GenricUnionA<>))]
[MemoryPackUnion(1, typeof(GenricUnionB<>))]
public partial interface IGenericUnion<ToaruHoge>
{
ToaruHoge? Value { get; set; }
}


[MemoryPackable]
public partial class GenricUnionA<T> : IGenericUnion<T>
{
public T? Value { get; set; }
public int MyProperty { get; set; }
}

[MemoryPackable]
public partial class GenricUnionB<T> : IGenericUnion<T>
{
public T? Value { get; set; }
public double MyProperty { get; set; }
}
27 changes: 27 additions & 0 deletions sandbox/SandboxNet6/SandboxNet6.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MemoryPack.Core\MemoryPack.Core.csproj" />
<ProjectReference Include="..\..\src\MemoryPack.Generator.Roslyn3\MemoryPack.Generator.Roslyn3.csproj">
<OutputItemType>Analyzer</OutputItemType>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

<!--<ItemGroup>
<CompilerVisibleProperty Include="MemoryPackGenerator_SerializationInfoOutputDirectory" />
</ItemGroup>
<PropertyGroup>
<MemoryPackGenerator_SerializationInfoOutputDirectory>$(MSBuildProjectDirectory)\MemoryPackLogs</MemoryPackGenerator_SerializationInfoOutputDirectory>
</PropertyGroup>-->

</Project>
1 change: 0 additions & 1 deletion sandbox/SandboxWebApp/SandboxWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Loading

0 comments on commit fd750f8

Please sign in to comment.