From adf72cbf3667b99cb7b4bd10a8770d98eaeaa78a Mon Sep 17 00:00:00 2001 From: neuecc Date: Mon, 26 Sep 2022 02:55:41 +0900 Subject: [PATCH] minimum readme --- .github/workflows/build-release.yml | 71 ++++++++++++++++++- README.md | 38 +++++++++- sandbox/Benchmark/Benchmark.csproj | 2 + .../SandboxConsoleApp.csproj | 1 + .../MemoryPack.Streaming.csproj | 2 + 5 files changed, 111 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index aefc71c9..fb543f44 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -1 +1,70 @@ -name: Build-Release \ No newline at end of file +name: Build-Release + +on: + workflow_dispatch: + inputs: + tag: + description: "tag: git tag you want create. (sample 1.0.0)" + required: true + dry-run: + description: "dry-run: true will never create release/nuget." + required: true + default: "false" + +env: + GIT_TAG: ${{ github.event.inputs.tag }} + DRY_RUN: ${{ github.event.inputs.dry-run }} + +jobs: + build-dotnet: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + - uses: Cysharp/Actions/.github/actions/setup-dotnet@main + with: + dotnet-version: '7.0' # require 7.0-rc + include-prerelease: 'true' + # pack nuget + - run: dotnet build -c Release -p:Version=${{ env.GIT_TAG }} + - run: dotnet test -c Release --no-build + - run: dotnet pack -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish + - uses: actions/upload-artifact@v2 + with: + name: nuget + path: ./publish + + create-release: + if: github.event.inputs.dry-run == 'false' + needs: [build-dotnet] + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + # tag + - uses: Cysharp/Actions/.github/actions/setup-dotnet@main + with: + dotnet-version: '7.0' # require 7.0-rc + include-prerelease: 'true' + - uses: actions/checkout@v3 + - name: tag + run: git tag ${{ env.GIT_TAG }} + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + tags: true + # Create Releases + - uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.GIT_TAG }} + release_name: Ver.${{ env.GIT_TAG }} + draft: true + prerelease: false + # Download (All) Artifacts to current directory + - uses: actions/download-artifact@v2 + # Upload to NuGet + - run: dotnet nuget push "./nuget/*.nupkg" -s https://www.nuget.org/api/v2/package -k ${{ secrets.NUGET_KEY }} \ No newline at end of file diff --git a/README.md b/README.md index 4377322f..41f41ec9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,47 @@ # 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) -Ideally fast no encoding binary serializer for .NET. +Zero encoding binary serializer for C#. +Currently preview. +Installation +--- +This library is distributed via NuGet. Minimum requirement is `.NET 7 RC1` and Roslyn Incremental Generator(`4.4.0-1.final`) support. + +> PM> Install-Package [MemoryPack](https://www.nuget.org/packages/MemoryPack) + +And you need to enable preview features to `.csproj`. + +```xml +True +``` + +Quick Start +--- +Define the struct or class to be serialized and annotate it with a `[MemoryPackable]` attribute and `partial` keyword. + +```csharp +[MemoryPackable] +public partial class MyClass +{ + public int MyProperty1 { get; set; } + public int MyProperty2 { get; set; } +} +``` + +MemoryPack code generator generates `IMemoryPackable` static abstract member. + +In Visual Studio, you can check generated code via `Ctrl+K, R` on class name and select `*.MemoryPackFormatter.g.cs`. -`True` +Call `MemoryPackSerializer.Serialize/Deserialize` to serialize/deserialize your object instance. +```csharp +var v = new MyClass { MyProperty1 = 10, MyProperty2 = 40 }; +var bin = MemoryPackSerializer.Serialize(v); +var v2 = MemoryPackSerializer.Deserialize(bin); +``` wire format --- diff --git a/sandbox/Benchmark/Benchmark.csproj b/sandbox/Benchmark/Benchmark.csproj index 298b68f5..7128d829 100644 --- a/sandbox/Benchmark/Benchmark.csproj +++ b/sandbox/Benchmark/Benchmark.csproj @@ -7,6 +7,8 @@ True True enable + + false diff --git a/sandbox/SandboxConsoleApp/SandboxConsoleApp.csproj b/sandbox/SandboxConsoleApp/SandboxConsoleApp.csproj index 2b53ea0e..6bfcc4b0 100644 --- a/sandbox/SandboxConsoleApp/SandboxConsoleApp.csproj +++ b/sandbox/SandboxConsoleApp/SandboxConsoleApp.csproj @@ -6,6 +6,7 @@ disable enable True + false diff --git a/src/MemoryPack.Streaming/MemoryPack.Streaming.csproj b/src/MemoryPack.Streaming/MemoryPack.Streaming.csproj index 21494438..3a614822 100644 --- a/src/MemoryPack.Streaming/MemoryPack.Streaming.csproj +++ b/src/MemoryPack.Streaming/MemoryPack.Streaming.csproj @@ -4,6 +4,8 @@ net6.0 enable enable + + false