THRIFT-5479 Add net 6 support
diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs b/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs
index 16dcc76..ae4d545 100644
--- a/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs
+++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs
@@ -28,8 +28,8 @@
[MemoryDiagnoser]
public class CompactProtocolBenchmarks
{
- private MemoryStream _Stream;
- private TProtocol _Protocol;
+ private MemoryStream? _Stream;
+ private TProtocol? _Protocol;
[Params(10000)]
public int NumberOfOperationsPerIteration { get; set; }
@@ -45,16 +45,18 @@
[GlobalCleanup]
public void GlobalCleanup()
{
- _Protocol.Dispose();
+ _Protocol?.Dispose();
}
[Benchmark]
public async Task WriteString()
{
+ if ((_Protocol is null) || (_Stream is null))
+ throw new System.Exception("unexpected internal state");
+
for (int i = 0; i < NumberOfOperationsPerIteration; i++)
{
await _Protocol.WriteStringAsync("Thrift String Benchmark");
-
_Stream.Seek(0, SeekOrigin.Begin);
}
}
@@ -62,12 +64,14 @@
[Benchmark]
public async Task ReadString()
{
+ if ((_Protocol is null) || (_Stream is null))
+ throw new System.Exception("unexpected internal state");
+
await _Protocol.WriteStringAsync("Thrift String Benchmark");
for (int i = 0; i < NumberOfOperationsPerIteration; i++)
{
_Stream.Seek(0, SeekOrigin.Begin);
-
await _Protocol.ReadStringAsync();
}
}
diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj
index 633850e..0e29b3b 100644
--- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj
+++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj
@@ -23,6 +23,7 @@
<TargetFramework>net6.0</TargetFramework>
<TieredCompilation>false</TieredCompilation>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>