diff --git a/Akka.Serialization.Compressed.sln b/Akka.Serialization.Compressed.sln index 165f471..0131ddb 100644 --- a/Akka.Serialization.Compressed.sln +++ b/Akka.Serialization.Compressed.sln @@ -15,6 +15,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject README.md = README.md RELEASE_NOTES.md = RELEASE_NOTES.md + src\Directory.Build.props = src\Directory.Build.props + src\Directory.Generated.props = src\Directory.Generated.props + src\Directory.Packages.props = src\Directory.Packages.props + NuGet.Config = NuGet.Config EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Json", "Json", "{25F8AE7C-D98B-41B1-A534-49E9603D8533}" diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..8bb7f8f --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/build/Build.cs b/build/Build.cs index 0769b33..081e44a 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -330,8 +330,8 @@ IEnumerable GetProjects() .After(Restore) .Executes(() => { - XmlTasks.XmlPoke(SourceDirectory / "Directory.Build.props", "//Project/PropertyGroup/PackageReleaseNotes", GetNuGetReleaseNotes(ChangelogFile)); - XmlTasks.XmlPoke(SourceDirectory / "Directory.Build.props", "//Project/PropertyGroup/VersionPrefix", ReleaseVersion); + XmlTasks.XmlPoke(SourceDirectory / "Directory.Generated.props", "//Project/PropertyGroup/PackageReleaseNotes", GetNuGetReleaseNotes(ChangelogFile)); + XmlTasks.XmlPoke(SourceDirectory / "Directory.Generated.props", "//Project/PropertyGroup/VersionPrefix", ReleaseVersion); }); diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index 7bc2848..337271d 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -16,6 +16,8 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> True True True @@ -24,4 +26,5 @@ True True True - True + True + True diff --git a/src/Akka.Serialization.Compressed.Json.Tests.Performance/Akka.Serialization.Compressed.Json.Tests.Performance.csproj b/src/Akka.Serialization.Compressed.Json.Tests.Performance/Akka.Serialization.Compressed.Json.Tests.Performance.csproj index 99fbd96..28a12c4 100644 --- a/src/Akka.Serialization.Compressed.Json.Tests.Performance/Akka.Serialization.Compressed.Json.Tests.Performance.csproj +++ b/src/Akka.Serialization.Compressed.Json.Tests.Performance/Akka.Serialization.Compressed.Json.Tests.Performance.csproj @@ -2,12 +2,12 @@ Exe - $(TestsNetCore);$(TestsNet) + $(TestsNetFx);$(TestsNet) false - + diff --git a/src/Akka.Serialization.Compressed.Json.Tests/Akka.Serialization.Compressed.Json.Tests.csproj b/src/Akka.Serialization.Compressed.Json.Tests/Akka.Serialization.Compressed.Json.Tests.csproj index f640eba..86abce4 100644 --- a/src/Akka.Serialization.Compressed.Json.Tests/Akka.Serialization.Compressed.Json.Tests.csproj +++ b/src/Akka.Serialization.Compressed.Json.Tests/Akka.Serialization.Compressed.Json.Tests.csproj @@ -1,13 +1,13 @@  - $(TestsNetCore);$(TestsNet) + $(TestsNetFx);$(TestsNet) false - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Akka.Serialization.Compressed.Json/Akka.Serialization.Compressed.Json.csproj b/src/Akka.Serialization.Compressed.Json/Akka.Serialization.Compressed.Json.csproj index 1425f79..9832584 100644 --- a/src/Akka.Serialization.Compressed.Json/Akka.Serialization.Compressed.Json.csproj +++ b/src/Akka.Serialization.Compressed.Json/Akka.Serialization.Compressed.Json.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/src/Akka.Serialization.Compressed.Json/AkkaHostingExtensions.cs b/src/Akka.Serialization.Compressed.Json/AkkaHostingExtensions.cs index 920d18c..ae190f6 100644 --- a/src/Akka.Serialization.Compressed.Json/AkkaHostingExtensions.cs +++ b/src/Akka.Serialization.Compressed.Json/AkkaHostingExtensions.cs @@ -6,6 +6,7 @@ // ----------------------------------------------------------------------- using System; +using System.Collections.Immutable; using System.Linq; using Akka.Hosting; @@ -23,8 +24,8 @@ public static AkkaConfigurationBuilder WithCompressedJsonSerializer(this AkkaCon public static AkkaConfigurationBuilder WithCompressedJsonSerializer(this AkkaConfigurationBuilder builder, params Type[] boundTypes) { - var typeHash = boundTypes.ToHashSet(); - typeHash.Add(typeof(IShouldCompress)); + var typeHash = boundTypes.ToImmutableHashSet(); + typeHash = typeHash.Add(typeof(IShouldCompress)); return builder.WithCustomSerializer( serializerIdentifier: "json-gzip", diff --git a/src/Akka.Serialization.Compressed.Json/CompressedJsonSerializer.cs b/src/Akka.Serialization.Compressed.Json/CompressedJsonSerializer.cs index 02c50b9..bd6d496 100644 --- a/src/Akka.Serialization.Compressed.Json/CompressedJsonSerializer.cs +++ b/src/Akka.Serialization.Compressed.Json/CompressedJsonSerializer.cs @@ -371,8 +371,8 @@ private static object GetValue(string? value) if(value is null) throw new NotSupportedException("Null is not supported"); - var t = value[..1]; - var v = value[1..]; + var t = value.Substring(0, 1); + var v = value.Substring(1); return t switch { "I" => int.Parse(v, NumberFormatInfo.InvariantInfo), @@ -386,9 +386,11 @@ private static object GetValue(string? value) private static byte[] Compress(byte[] data) { using var compressedStream = new MemoryStream(); - using var compressor = new GZipStream(compressedStream, CompressionMode.Compress); - compressor.Write(data, 0, data.Length); - compressor.Flush(); // It is critical to flush here + using (var compressor = new GZipStream(compressedStream, CompressionMode.Compress, false)) + { + compressor.Write(data, 0, data.Length); + compressor.Flush(); // It is critical to flush here + } return compressedStream.ToArray(); } @@ -396,9 +398,11 @@ private static byte[] Compress(byte[] data) private static byte[] Decompress(byte[] raw) { using var compressedStream = new MemoryStream(raw); - using var compressor = new GZipStream(compressedStream, CompressionMode.Decompress); using var uncompressedStream = new MemoryStream(); - compressor.CopyTo(uncompressedStream); + using (var compressor = new GZipStream(compressedStream, CompressionMode.Decompress, false)) + { + compressor.CopyTo(uncompressedStream); + } return uncompressedStream.ToArray(); } diff --git a/src/Akka.Serialization.TestKit/Akka.Serialization.TestKit.csproj b/src/Akka.Serialization.TestKit/Akka.Serialization.TestKit.csproj index 9779553..3819db9 100644 --- a/src/Akka.Serialization.TestKit/Akka.Serialization.TestKit.csproj +++ b/src/Akka.Serialization.TestKit/Akka.Serialization.TestKit.csproj @@ -1,22 +1,16 @@  - $(TestsNetCore);$(TestsNet) + $(TestsNetFx);$(TestsNet) false - - $(DefineConstants);RELEASE - - + + \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 834d2a6..e7f1207 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,34 +1,26 @@ + + Copyright © 2013-2023 Akka.NET Team Akka.NET Team - 0.3.0 - • Fixed bugs akkalogo.png https://github.com/akkadotnet/Akka.Serialization.Compressed Apache-2.0 $(NoWarn);CS1591 enable - 10.0 + latest - netstandard2.1 + netstandard2.0 net6.0 - netcoreapp3.1 - 2.5.1 - 2.5.1 - 17.8.0 - - 1.5.13 - 1.5.13 - 6.12.0 - 0.13.8 + net472 - + diff --git a/src/Directory.Generated.props b/src/Directory.Generated.props new file mode 100644 index 0000000..bcef6d9 --- /dev/null +++ b/src/Directory.Generated.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props new file mode 100644 index 0000000..e89f62b --- /dev/null +++ b/src/Directory.Packages.props @@ -0,0 +1,31 @@ + + + true + 1.5.25 + 1.5.25 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file