diff --git a/.github/workflows/dotnet-format-action.yml b/.github/workflows/dotnet-format-action.yml index 52f2a99..b20e59d 100644 --- a/.github/workflows/dotnet-format-action.yml +++ b/.github/workflows/dotnet-format-action.yml @@ -17,6 +17,7 @@ jobs: 5.0.x 6.0.x 7.0.x + 8.0.x - name: Run dotnet format id: format uses: jfversluis/dotnet-format@v1.0.5 diff --git a/.github/workflows/dotnet-linux.yml b/.github/workflows/dotnet-linux.yml index 5ecc20f..228d1f1 100644 --- a/.github/workflows/dotnet-linux.yml +++ b/.github/workflows/dotnet-linux.yml @@ -19,6 +19,7 @@ jobs: 5.0.x 6.0.x 7.0.x + 8.0.x - name: Restore dependencies run: dotnet restore ./src/CSharp/EasyMicroservices.Serialization.sln - name: Build diff --git a/.github/workflows/dotnet-macos.yml b/.github/workflows/dotnet-macos.yml index 0549ec7..ed2c8d2 100644 --- a/.github/workflows/dotnet-macos.yml +++ b/.github/workflows/dotnet-macos.yml @@ -19,6 +19,7 @@ jobs: 5.0.x 6.0.x 7.0.x + 8.0.x - name: Restore dependencies run: dotnet restore ./src/CSharp/EasyMicroservices.Serialization.sln - name: Build diff --git a/.github/workflows/dotnet-windows.yml b/.github/workflows/dotnet-windows.yml index 449437c..17dc146 100644 --- a/.github/workflows/dotnet-windows.yml +++ b/.github/workflows/dotnet-windows.yml @@ -19,6 +19,7 @@ jobs: 5.0.x 6.0.x 7.0.x + 8.0.x - name: Restore dependencies run: dotnet restore ./src/CSharp/EasyMicroservices.Serialization.sln - name: Build diff --git a/.github/workflows/nuget-push-public.yml b/.github/workflows/nuget-push-public.yml index 57c2e4d..be201de 100644 --- a/.github/workflows/nuget-push-public.yml +++ b/.github/workflows/nuget-push-public.yml @@ -14,7 +14,7 @@ jobs: 5.0.x 6.0.x 7.0.x - + 8.0.x env: DOTNET_INSTALL_DIR: /usr/share/dotnet - name: Restore dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d91fbf..7a8e2c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: 5.0.x 6.0.x 7.0.x - + 8.0.x env: DOTNET_INSTALL_DIR: /usr/share/dotnet - name: build and test diff --git a/src/CSharp/EasyMicroservices.Serialization.BinaryGo/EasyMicroservices.Serialization.BinaryGo.csproj b/src/CSharp/EasyMicroservices.Serialization.BinaryGo/EasyMicroservices.Serialization.BinaryGo.csproj index a7a826e..4083dd8 100644 --- a/src/CSharp/EasyMicroservices.Serialization.BinaryGo/EasyMicroservices.Serialization.BinaryGo.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.BinaryGo/EasyMicroservices.Serialization.BinaryGo.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net45;net7.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net45;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservices@gmail.com Serialize,deserialize diff --git a/src/CSharp/EasyMicroservices.Serialization.DependencyInjection/EasyMicroservices.Serialization.DependencyInjection.csproj b/src/CSharp/EasyMicroservices.Serialization.DependencyInjection/EasyMicroservices.Serialization.DependencyInjection.csproj index 8634191..a61603e 100644 --- a/src/CSharp/EasyMicroservices.Serialization.DependencyInjection/EasyMicroservices.Serialization.DependencyInjection.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.DependencyInjection/EasyMicroservices.Serialization.DependencyInjection.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservices@gmail.com Serialize,deserialize diff --git a/src/CSharp/EasyMicroservices.Serialization.MemoryPack/EasyMicroservices.Serialization.MemoryPack.csproj b/src/CSharp/EasyMicroservices.Serialization.MemoryPack/EasyMicroservices.Serialization.MemoryPack.csproj index b349e2a..c95fdfb 100644 --- a/src/CSharp/EasyMicroservices.Serialization.MemoryPack/EasyMicroservices.Serialization.MemoryPack.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.MemoryPack/EasyMicroservices.Serialization.MemoryPack.csproj @@ -8,7 +8,7 @@ - net7.0 + net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservice@gmail.com Serialize,deserialize diff --git a/src/CSharp/EasyMicroservices.Serialization.MessagePack/EasyMicroservices.Serialization.MessagePack.csproj b/src/CSharp/EasyMicroservices.Serialization.MessagePack/EasyMicroservices.Serialization.MessagePack.csproj index bb58505..3b5ae99 100644 --- a/src/CSharp/EasyMicroservices.Serialization.MessagePack/EasyMicroservices.Serialization.MessagePack.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.MessagePack/EasyMicroservices.Serialization.MessagePack.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serilize and deserilize wrapper EasyMicroservices@gmail.com Serilize,deserilize @@ -26,8 +26,10 @@ true .\bin\$(Configuration)\$(TargetFramework)\EasyMicroservice.Serialization.MessagePack.xml + + \ No newline at end of file diff --git a/src/CSharp/EasyMicroservices.Serialization.NewtonSoft.Json/EasyMicroservices.Serialization.Newtonsoft.Json.csproj b/src/CSharp/EasyMicroservices.Serialization.NewtonSoft.Json/EasyMicroservices.Serialization.Newtonsoft.Json.csproj index e10ff9f..e117eff 100644 --- a/src/CSharp/EasyMicroservices.Serialization.NewtonSoft.Json/EasyMicroservices.Serialization.Newtonsoft.Json.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.NewtonSoft.Json/EasyMicroservices.Serialization.Newtonsoft.Json.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net452;net7.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net452;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservices@gmail.com Serialize,deserialize @@ -26,8 +26,10 @@ true .\bin\$(Configuration)\$(TargetFramework)\EasyMicroservice.Serialization.Newtonsoft.Json.xml + + diff --git a/src/CSharp/EasyMicroservices.Serialization.System.Text.Json/EasyMicroservices.Serialization.System.Text.Json.csproj b/src/CSharp/EasyMicroservices.Serialization.System.Text.Json/EasyMicroservices.Serialization.System.Text.Json.csproj index c0ec22d..2033b46 100644 --- a/src/CSharp/EasyMicroservices.Serialization.System.Text.Json/EasyMicroservices.Serialization.System.Text.Json.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.System.Text.Json/EasyMicroservices.Serialization.System.Text.Json.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0;net48 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0;net8.0;net48 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservice@gmail.com Serialize,deserialize @@ -27,10 +27,21 @@ .\bin\$(Configuration)\$(TargetFramework)\EasyMicroservice.Serialization.System.Text.json.xml - - - + + + + + + + + + + + + + + diff --git a/src/CSharp/EasyMicroservices.Serialization.System.Text.Xml/EasyMicroservices.Serialization.System.Text.Xml.csproj b/src/CSharp/EasyMicroservices.Serialization.System.Text.Xml/EasyMicroservices.Serialization.System.Text.Xml.csproj index 888da81..edfa4df 100644 --- a/src/CSharp/EasyMicroservices.Serialization.System.Text.Xml/EasyMicroservices.Serialization.System.Text.Xml.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.System.Text.Xml/EasyMicroservices.Serialization.System.Text.Xml.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net452;net7.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net452;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservice@gmail.com Serialize,deserialize @@ -34,4 +34,5 @@ + diff --git a/src/CSharp/EasyMicroservices.Serialization.Tests/EasyMicroservices.Serialization.Tests.csproj b/src/CSharp/EasyMicroservices.Serialization.Tests/EasyMicroservices.Serialization.Tests.csproj index 08f9e25..d1c2c55 100644 --- a/src/CSharp/EasyMicroservices.Serialization.Tests/EasyMicroservices.Serialization.Tests.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.Tests/EasyMicroservices.Serialization.Tests.csproj @@ -8,7 +8,7 @@ - netcoreapp3.1;net6.0;net48;net452;net7.0 + netcoreapp3.1;net6.0;net48;net452;net7.0;net8.0 diff --git a/src/CSharp/EasyMicroservices.Serialization.YamlDotNet/EasyMicroservices.Serialization.YamlDotNet.csproj b/src/CSharp/EasyMicroservices.Serialization.YamlDotNet/EasyMicroservices.Serialization.YamlDotNet.csproj index 049fdbb..bc3841d 100644 --- a/src/CSharp/EasyMicroservices.Serialization.YamlDotNet/EasyMicroservices.Serialization.YamlDotNet.csproj +++ b/src/CSharp/EasyMicroservices.Serialization.YamlDotNet/EasyMicroservices.Serialization.YamlDotNet.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net452;net7.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net452;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservices@gmail.com Serialize,deserialize @@ -26,8 +26,10 @@ true .\bin\$(Configuration)\$(TargetFramework)\EasyMicroservice.Serialization.YamlDotNet.xml + + diff --git a/src/CSharp/EasyMicroservices.Serialization/EasyMicroservices.Serialization.csproj b/src/CSharp/EasyMicroservices.Serialization/EasyMicroservices.Serialization.csproj index d508984..88987aa 100644 --- a/src/CSharp/EasyMicroservices.Serialization/EasyMicroservices.Serialization.csproj +++ b/src/CSharp/EasyMicroservices.Serialization/EasyMicroservices.Serialization.csproj @@ -8,7 +8,7 @@ - netstandard2.0;netstandard2.1;net6.0;net45;net7.0 + netstandard2.0;netstandard2.1;net6.0;net45;net7.0;net8.0 @@ -17,7 +17,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.8 + 0.0.0.9 Serialize and deserialize wrapper EasyMicroservices@gmail.com Serialize,deserialize diff --git a/src/CSharp/EasyMicroservices.Serialization/Interfaces/IBaseSerializationProvider.cs b/src/CSharp/EasyMicroservices.Serialization/Interfaces/IBaseSerializationProvider.cs index 97956f6..f3d83e3 100644 --- a/src/CSharp/EasyMicroservices.Serialization/Interfaces/IBaseSerializationProvider.cs +++ b/src/CSharp/EasyMicroservices.Serialization/Interfaces/IBaseSerializationProvider.cs @@ -13,5 +13,18 @@ public interface IBaseSerializationProvider /// /// bool CanConvert(Type objectType); + /// + /// + /// + /// + /// + ReadOnlySpan SerializeToBytes(T value); + /// + /// + /// + /// + /// + /// + T DeserializeFromBytes(ReadOnlySpan bytes); } } diff --git a/src/CSharp/EasyMicroservices.Serialization/Providers/BaseProvider.cs b/src/CSharp/EasyMicroservices.Serialization/Providers/BaseProvider.cs index 806ea49..786f475 100644 --- a/src/CSharp/EasyMicroservices.Serialization/Providers/BaseProvider.cs +++ b/src/CSharp/EasyMicroservices.Serialization/Providers/BaseProvider.cs @@ -58,5 +58,21 @@ protected virtual Type ReplaceType(Type type) { return type; } + + /// + /// + /// + /// + /// + /// + public abstract ReadOnlySpan SerializeToBytes(T value); + + /// + /// + /// + /// + /// + /// + public abstract T DeserializeFromBytes(ReadOnlySpan bytes); } } diff --git a/src/CSharp/EasyMicroservices.Serialization/Providers/BinarySerializationBaseProvider.cs b/src/CSharp/EasyMicroservices.Serialization/Providers/BinarySerializationBaseProvider.cs index 161c639..4221d07 100644 --- a/src/CSharp/EasyMicroservices.Serialization/Providers/BinarySerializationBaseProvider.cs +++ b/src/CSharp/EasyMicroservices.Serialization/Providers/BinarySerializationBaseProvider.cs @@ -21,5 +21,27 @@ public abstract class BinarySerializationBaseProvider : BaseProvider, IBinarySer /// /// public abstract ReadOnlySpan Serialize(T value); + + /// + /// + /// + /// + /// + /// + public override ReadOnlySpan SerializeToBytes(T value) + { + return Serialize(value); + } + + /// + /// + /// + /// + /// + /// + public override T DeserializeFromBytes(ReadOnlySpan bytes) + { + return Deserialize(bytes); + } } } diff --git a/src/CSharp/EasyMicroservices.Serialization/Providers/TextSerializationBaseProvider.cs b/src/CSharp/EasyMicroservices.Serialization/Providers/TextSerializationBaseProvider.cs index bb23e54..970287a 100644 --- a/src/CSharp/EasyMicroservices.Serialization/Providers/TextSerializationBaseProvider.cs +++ b/src/CSharp/EasyMicroservices.Serialization/Providers/TextSerializationBaseProvider.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Text; using EasyMicroservices.Serialization.Interfaces; namespace EasyMicroservices.Serialization.Providers @@ -24,5 +28,26 @@ public abstract class TextSerializationBaseProvider : BaseProvider, ITextSeriali /// /// public abstract string Serialize(T value); + /// + /// + /// + /// + /// + /// + public override ReadOnlySpan SerializeToBytes(T value) + { + return Encoding.UTF8.GetBytes(Serialize(value)); + } + + /// + /// + /// + /// + /// + /// + public override T DeserializeFromBytes(ReadOnlySpan bytes) + { + return Deserialize(Encoding.UTF8.GetString(bytes.ToArray())); + } } }