THRIFT-5479 Add net 6 support
Client: netstd
Patch: Jens Geyer
diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj
index d55074f..633850e 100644
--- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj
+++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj
@@ -20,17 +20,21 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
<TieredCompilation>false</TieredCompilation>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
+ <PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Thrift\Thrift.csproj" />
</ItemGroup>
+ <ItemGroup>
+ <PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
+ </ItemGroup>
+
</Project>
diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj
index b47017e..6d473e4 100644
--- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj
+++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj
@@ -19,7 +19,7 @@
-->
<PropertyGroup>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
<AssemblyName>Thrift.IntegrationTests</AssemblyName>
<PackageId>Thrift.IntegrationTests</PackageId>
<Version>0.16.0.0</Version>
@@ -33,11 +33,11 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="CompareNETObjects" Version="4.72.0" />
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
- <PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
- <PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
- <PackageReference Include="System.ServiceModel.Primitives" Version="4.8.1" />
+ <PackageReference Include="CompareNETObjects" Version="4.74.0" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
+ <PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
+ <PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
+ <PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Thrift\Thrift.csproj" />
@@ -45,5 +45,8 @@
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
+ <ItemGroup>
+ <PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
index 126635d..1511274 100644
--- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
+++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
@@ -21,7 +21,7 @@
<PropertyGroup>
<ThriftVersion>0.16.0</ThriftVersion>
<ThriftVersionOutput>Thrift version $(ThriftVersion)</ThriftVersionOutput>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
<Version>$(ThriftVersion).0</Version>
<AssemblyName>Thrift.PublicInterfaces.Compile.Tests</AssemblyName>
<PackageId>Thrift.PublicInterfaces.Compile.Tests</PackageId>
@@ -36,7 +36,11 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="System.ServiceModel.Primitives" Version="4.8.1" />
+ <PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="_GenerateRestoreProjectSpec;Restore;Compile">
@@ -55,22 +59,13 @@
<CreateProperty Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" Value="$(ProjectDir)/../../../../compiler/cpp/thrift">
<Output TaskParameter="Value" PropertyName="PathToThrift" />
</CreateProperty>
- <Error
- Condition="!Exists('$(PathToThrift)')"
- Text="Thrift executable could not be found."
- />
+ <Error Condition="!Exists('$(PathToThrift)')" Text="Thrift executable could not be found." />
<!-- Make sure the thrift version found is the same as the projects version -->
<Exec Command="$(PathToThrift) -version" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ThriftBinaryVersion" />
</Exec>
- <Error
- Condition="$('$(ThriftBinaryVersion)'::StartsWith('$(ThriftVersionOutput)')) == true"
- Text="Thrift version returned: '$(ThriftBinaryVersion)' is not equal to the projects version '$(ThriftVersionOutput)'."
- />
- <Message
- Importance="high"
- Text="Generating tests with thrift binary: '$(PathToThrift)'"
- />
+ <Error Condition="$('$(ThriftBinaryVersion)'::StartsWith('$(ThriftVersionOutput)')) == true" Text="Thrift version returned: '$(ThriftBinaryVersion)' is not equal to the projects version '$(ThriftVersionOutput)'." />
+ <Message Importance="high" Text="Generating tests with thrift binary: '$(PathToThrift)'" />
<!-- Generate the thrift test files -->
<Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r ./CassandraTest.thrift" />
<Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r ./optional_required_default.thrift" />
diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj
index f1dc731..18fce01 100644
--- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj
+++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj
@@ -19,15 +19,15 @@
-->
<PropertyGroup>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
<Version>0.16.0.0</Version>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="CompareNETObjects" Version="4.72.0" />
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
- <PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
- <PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
+ <PackageReference Include="CompareNETObjects" Version="4.74.0" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
+ <PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
+ <PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
</ItemGroup>
@@ -39,4 +39,8 @@
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/lib/netstd/Thrift/Collections/THashSet.cs b/lib/netstd/Thrift/Collections/THashSet.cs
index 25fcf10..1c060e5 100644
--- a/lib/netstd/Thrift/Collections/THashSet.cs
+++ b/lib/netstd/Thrift/Collections/THashSet.cs
@@ -32,7 +32,7 @@
public THashSet(int capacity)
{
- #if NET5_0
+ #if NET5_0_OR_GREATER
Items = new HashSet<T>(capacity);
#elif NETFRAMEWORK || NETSTANDARD
Items = new HashSet<T>(/*capacity not supported*/);
diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj
index 2454ffd..16e64a1 100644
--- a/lib/netstd/Thrift/Thrift.csproj
+++ b/lib/netstd/Thrift/Thrift.csproj
@@ -19,7 +19,7 @@
-->
<PropertyGroup>
- <TargetFrameworks>netstandard2.1;netstandard2.0;net5.0</TargetFrameworks>
+ <TargetFrameworks>netstandard2.1;netstandard2.0;net5.0;net6.0</TargetFrameworks>
<AssemblyName>Thrift</AssemblyName>
<PackageId>ApacheThrift</PackageId>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -56,18 +56,22 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
- <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
- <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
- <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="System.IO.Pipes" Version="[4.3,)" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="5.0.0" />
- <PackageReference Include="System.Net.Http.WinHttpHandler" Version="5.0.0" />
+ <PackageReference Include="System.Net.Http.WinHttpHandler" Version="6.0.0" />
<PackageReference Include="System.Net.NameResolution" Version="[4.3,)" />
<PackageReference Include="System.Net.Requests" Version="[4.3,)" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>
+ <ItemGroup>
+ <PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
+ </ItemGroup>
+
<Target Name="SetTFMAssemblyAttributesPath" BeforeTargets="GenerateTargetFrameworkMonikerAttribute">
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributesPath>$(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)</TargetFrameworkMonikerAssemblyAttributesPath>
diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs
index 35a037d..e985a29 100644
--- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs
+++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs
@@ -329,7 +329,7 @@
var nBytes = Math.Min(15 * 4096, length); // 16 would exceed the limit
while (nBytes > 0)
{
-#if NET5_0
+#if NET5_0_OR_GREATER
await PipeStream.WriteAsync(buffer.AsMemory(offset, nBytes), cancellationToken);
#else
await PipeStream.WriteAsync(buffer, offset, nBytes, cancellationToken);