Skip to content

Commit 1cbab39

Browse files
authored
Modernize solution (#80)
* Modernize solution * Fix build script * Add nuget.config * Fix directory.build.props * Make code compatible with .NET Standard 2.0
1 parent 5898469 commit 1cbab39

13 files changed

+91
-43
lines changed

Akka.Serialization.Compressed.sln

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
ProjectSection(SolutionItems) = preProject
1616
README.md = README.md
1717
RELEASE_NOTES.md = RELEASE_NOTES.md
18+
src\Directory.Build.props = src\Directory.Build.props
19+
src\Directory.Generated.props = src\Directory.Generated.props
20+
src\Directory.Packages.props = src\Directory.Packages.props
21+
NuGet.Config = NuGet.Config
1822
EndProjectSection
1923
EndProject
2024
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Json", "Json", "{25F8AE7C-D98B-41B1-A534-49E9603D8533}"

NuGet.Config

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
6+
</packageSources>
7+
8+
<packageSourceMapping>
9+
<packageSource key="nuget.org">
10+
<package pattern="*" />
11+
</packageSource>
12+
</packageSourceMapping>
13+
</configuration>

build/Build.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ IEnumerable<Project> GetProjects()
330330
.After(Restore)
331331
.Executes(() =>
332332
{
333-
XmlTasks.XmlPoke(SourceDirectory / "Directory.Build.props", "//Project/PropertyGroup/PackageReleaseNotes", GetNuGetReleaseNotes(ChangelogFile));
334-
XmlTasks.XmlPoke(SourceDirectory / "Directory.Build.props", "//Project/PropertyGroup/VersionPrefix", ReleaseVersion);
333+
XmlTasks.XmlPoke(SourceDirectory / "Directory.Generated.props", "//Project/PropertyGroup/PackageReleaseNotes", GetNuGetReleaseNotes(ChangelogFile));
334+
XmlTasks.XmlPoke(SourceDirectory / "Directory.Generated.props", "//Project/PropertyGroup/VersionPrefix", ReleaseVersion);
335335

336336
});
337337

build/_build.csproj.DotSettings

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
1717
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
1818
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
19+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
20+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
1921
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
2022
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
2123
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
@@ -24,4 +26,5 @@
2426
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
2527
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
2628
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
27-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
29+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
30+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/Akka.Serialization.Compressed.Json.Tests.Performance/Akka.Serialization.Compressed.Json.Tests.Performance.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>$(TestsNetCore);$(TestsNet)</TargetFrameworks>
5+
<TargetFrameworks>$(TestsNetFx);$(TestsNet)</TargetFrameworks>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetVersion)" />
10+
<PackageReference Include="BenchmarkDotNet" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/Akka.Serialization.Compressed.Json.Tests/Akka.Serialization.Compressed.Json.Tests.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>$(TestsNetCore);$(TestsNet)</TargetFrameworks>
3+
<TargetFrameworks>$(TestsNetFx);$(TestsNet)</TargetFrameworks>
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
9-
<PackageReference Include="xunit" Version="$(XunitVersion)" />
10-
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualstudio)">
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
9+
<PackageReference Include="xunit" />
10+
<PackageReference Include="xunit.runner.visualstudio" >
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>

src/Akka.Serialization.Compressed.Json/Akka.Serialization.Compressed.Json.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Akka" Version="$(AkkaVersion)" />
12-
<PackageReference Include="Akka.Hosting" Version="$(AkkaHostingVersion)" />
11+
<PackageReference Include="Akka" />
12+
<PackageReference Include="Akka.Hosting" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

src/Akka.Serialization.Compressed.Json/AkkaHostingExtensions.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// -----------------------------------------------------------------------
77

88
using System;
9+
using System.Collections.Immutable;
910
using System.Linq;
1011
using Akka.Hosting;
1112

@@ -23,8 +24,8 @@ public static AkkaConfigurationBuilder WithCompressedJsonSerializer(this AkkaCon
2324

2425
public static AkkaConfigurationBuilder WithCompressedJsonSerializer(this AkkaConfigurationBuilder builder, params Type[] boundTypes)
2526
{
26-
var typeHash = boundTypes.ToHashSet();
27-
typeHash.Add(typeof(IShouldCompress));
27+
var typeHash = boundTypes.ToImmutableHashSet();
28+
typeHash = typeHash.Add(typeof(IShouldCompress));
2829

2930
return builder.WithCustomSerializer(
3031
serializerIdentifier: "json-gzip",

src/Akka.Serialization.Compressed.Json/CompressedJsonSerializer.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ private static object GetValue(string? value)
371371
if(value is null)
372372
throw new NotSupportedException("Null is not supported");
373373

374-
var t = value[..1];
375-
var v = value[1..];
374+
var t = value.Substring(0, 1);
375+
var v = value.Substring(1);
376376
return t switch
377377
{
378378
"I" => int.Parse(v, NumberFormatInfo.InvariantInfo),
@@ -386,19 +386,23 @@ private static object GetValue(string? value)
386386
private static byte[] Compress(byte[] data)
387387
{
388388
using var compressedStream = new MemoryStream();
389-
using var compressor = new GZipStream(compressedStream, CompressionMode.Compress);
390-
compressor.Write(data, 0, data.Length);
391-
compressor.Flush(); // It is critical to flush here
389+
using (var compressor = new GZipStream(compressedStream, CompressionMode.Compress, false))
390+
{
391+
compressor.Write(data, 0, data.Length);
392+
compressor.Flush(); // It is critical to flush here
393+
}
392394
return compressedStream.ToArray();
393395
}
394396

395397
[MethodImpl(MethodImplOptions.AggressiveInlining)]
396398
private static byte[] Decompress(byte[] raw)
397399
{
398400
using var compressedStream = new MemoryStream(raw);
399-
using var compressor = new GZipStream(compressedStream, CompressionMode.Decompress);
400401
using var uncompressedStream = new MemoryStream();
401-
compressor.CopyTo(uncompressedStream);
402+
using (var compressor = new GZipStream(compressedStream, CompressionMode.Decompress, false))
403+
{
404+
compressor.CopyTo(uncompressedStream);
405+
}
402406
return uncompressedStream.ToArray();
403407
}
404408

Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>$(TestsNetCore);$(TestsNet)</TargetFrameworks>
3+
<TargetFrameworks>$(TestsNetFx);$(TestsNet)</TargetFrameworks>
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66

7-
<!--
8-
<ItemGroup>
9-
<ProjectReference Include="..\..\..\core\Akka.Tests.Shared.Internals\Akka.Tests.Shared.Internals.csproj" />
10-
</ItemGroup>
11-
-->
12-
137
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
148
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
159
</PropertyGroup>
1610

1711
<ItemGroup>
18-
<PackageReference Include="Akka.TestKit.Xunit2" Version="$(AkkaVersion)" />
19-
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
12+
<PackageReference Include="Akka.TestKit.Xunit2" />
13+
<PackageReference Include="FluentAssertions" />
2014
</ItemGroup>
2115

2216
</Project>

src/Directory.Build.props

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Generated.props', '$(MSBuildThisFileDirectory)'))" />
3+
24
<PropertyGroup>
35
<Copyright>Copyright © 2013-2023 Akka.NET Team</Copyright>
46
<Authors>Akka.NET Team</Authors>
5-
<VersionPrefix>0.3.0</VersionPrefix>
6-
<PackageReleaseNotes>• Fixed bugs</PackageReleaseNotes>
77
<PackageIconUrl>akkalogo.png</PackageIconUrl>
88
<PackageProjectUrl>https://github.com/akkadotnet/Akka.Serialization.Compressed</PackageProjectUrl>
99
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1010
<NoWarn>$(NoWarn);CS1591</NoWarn>
1111
<Nullable>enable</Nullable>
12-
<LangVersion>10.0</LangVersion>
12+
<LangVersion>latest</LangVersion>
1313
</PropertyGroup>
1414

1515
<PropertyGroup>
16-
<LibraryFramework>netstandard2.1</LibraryFramework>
16+
<LibraryFramework>netstandard2.0</LibraryFramework>
1717
<TestsNet>net6.0</TestsNet>
18-
<TestsNetCore>netcoreapp3.1</TestsNetCore>
19-
<XunitVersion>2.5.1</XunitVersion>
20-
<XunitRunnerVisualstudio>2.5.1</XunitRunnerVisualstudio>
21-
<TestSdkVersion>17.8.0</TestSdkVersion>
22-
23-
<AkkaVersion>1.5.13</AkkaVersion>
24-
<AkkaHostingVersion>1.5.13</AkkaHostingVersion>
25-
<FluentAssertionsVersion>6.12.0</FluentAssertionsVersion>
26-
<BenchmarkDotNetVersion>0.13.8</BenchmarkDotNetVersion>
18+
<TestsNetFx>net472</TestsNetFx>
2719
</PropertyGroup>
2820

2921
<!-- SourceLink support for all Akka.NET projects -->
3022
<ItemGroup>
31-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
23+
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
3224
</ItemGroup>
3325

3426
<ItemGroup>

src/Directory.Generated.props

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionPrefix/>
4+
<PackageReleaseNotes/>
5+
</PropertyGroup>
6+
</Project>

src/Directory.Packages.props

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<AkkaVersion>1.5.25</AkkaVersion>
5+
<AkkaHostingVersion>1.5.25</AkkaHostingVersion>
6+
</PropertyGroup>
7+
<!-- Akka dependencies -->
8+
<ItemGroup>
9+
<PackageVersion Include="Akka" Version="$(AkkaVersion)" />
10+
<PackageVersion Include="Akka.Hosting" Version="$(AkkaHostingVersion)" />
11+
</ItemGroup>
12+
<!-- App dependencies -->
13+
<ItemGroup>
14+
</ItemGroup>
15+
<!-- Test dependencies -->
16+
<ItemGroup>
17+
<PackageVersion Include="Akka.TestKit.Xunit2" Version="$(AkkaVersion)" />
18+
<PackageVersion Include="Akka.Hosting.TestKit" Version="$(AkkaHostingVersion)" />
19+
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
20+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
21+
<PackageVersion Include="Docker.DotNet" Version="3.125.15" />
22+
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
23+
<PackageVersion Include="xunit" Version="2.8.1" />
24+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
25+
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
26+
</ItemGroup>
27+
<!-- SourceLink support for all Akka.NET projects -->
28+
<ItemGroup>
29+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
30+
</ItemGroup>
31+
</Project>

0 commit comments

Comments
 (0)