diff options
author | Jens Geyer <jensg@apache.org> | 2022-01-09 16:50:52 +0100 |
---|---|---|
committer | Jens Geyer <Jens-G@users.noreply.github.com> | 2022-01-09 21:57:30 +0100 |
commit | 98a232577fa56bb703ea96b88cc6c5b9391178f0 (patch) | |
tree | 916efb58623cd23042ed192961ac4df9387c221c /lib/netstd | |
parent | 39d7278ddffce27d45380c483a84d013f6db4d7b (diff) | |
download | thrift-98a232577fa56bb703ea96b88cc6c5b9391178f0.tar.gz |
THRIFT-5479 Add net 6 support
Diffstat (limited to 'lib/netstd')
8 files changed, 40 insertions, 27 deletions
diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs b/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs index 16dcc766e..ae4d54537 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs @@ -28,8 +28,8 @@ namespace Thrift.Benchmarks [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 @@ namespace Thrift.Benchmarks [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 @@ namespace Thrift.Benchmarks [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 633850e0a..0e29b3b78 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> diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Protocols/ProtocolsOperationsTests.cs b/lib/netstd/Tests/Thrift.IntegrationTests/Protocols/ProtocolsOperationsTests.cs index 62ab31780..dd9646ad9 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Protocols/ProtocolsOperationsTests.cs +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Protocols/ProtocolsOperationsTests.cs @@ -25,13 +25,15 @@ using Thrift.Protocol; using Thrift.Protocol.Entities; using Thrift.Transport.Client; +#pragma warning disable IDE0063 // using + namespace Thrift.IntegrationTests.Protocols { [TestClass] public class ProtocolsOperationsTests { - private readonly CompareLogic _compareLogic = new CompareLogic(); - private static readonly TConfiguration Configuration = null; // or new TConfiguration() if needed + private readonly CompareLogic _compareLogic = new(); + private static readonly TConfiguration Configuration = new(); [DataTestMethod] [DataRow(typeof(TBinaryProtocol), TMessageType.Call)] @@ -496,8 +498,9 @@ namespace Thrift.IntegrationTests.Protocols { var memoryStream = new MemoryStream(); var streamClientTransport = new TStreamTransport(memoryStream, memoryStream,Configuration); - var protocol = (TProtocol) Activator.CreateInstance(protocolType, streamClientTransport); - return new Tuple<Stream, TProtocol>(memoryStream, protocol); + if( Activator.CreateInstance(protocolType, streamClientTransport) is TProtocol protocol) + return new Tuple<Stream, TProtocol>(memoryStream, protocol); + throw new Exception("Unexpected"); } } } diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 6d473e44f..56123dd84 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -30,6 +30,7 @@ <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute> + <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> 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 15112747f..0d2770d36 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 @@ -29,6 +29,7 @@ <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute> + <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> diff --git a/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs b/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs index 061032ae0..778d24c80 100644 --- a/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs +++ b/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs @@ -216,9 +216,9 @@ namespace Thrift.Tests.Collections public int X { get; set; } // all Thrift-generated classes override Equals(), we do just the same - public override bool Equals(object that) + public override bool Equals(object? that) { - if (!(that is ExampleClass other)) return false; + if (that is not ExampleClass other) return false; if (ReferenceEquals(this, other)) return true; return this.X == other.X; diff --git a/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs b/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs index f717b4dda..84fcab85c 100644 --- a/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs +++ b/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs @@ -24,6 +24,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using OptReqDefTest; using Thrift.Collections; +#nullable disable // this is just test code, we leave it at that + namespace Thrift.Tests.DataModel { // ReSharper disable once InconsistentNaming @@ -289,7 +291,7 @@ namespace Thrift.Tests.DataModel return value; } - private List<Dictionary<sbyte, THashSet<Distance>>> ModifyValue(List<Dictionary<sbyte, THashSet<Distance>>> value) + private static List<Dictionary<sbyte, THashSet<Distance>>> ModifyValue(List<Dictionary<sbyte, THashSet<Distance>>> value) { if (value == null) value = new List<Dictionary<sbyte, THashSet<Distance>>>(); @@ -325,7 +327,7 @@ namespace Thrift.Tests.DataModel return value; } - private THashSet<List<Distance>> ModifyValue(THashSet<List<Distance>> value) + private static THashSet<List<Distance>> ModifyValue(THashSet<List<Distance>> value) { if (value == null) value = new THashSet<List<Distance>>(); @@ -342,7 +344,7 @@ namespace Thrift.Tests.DataModel return value; } - private Dictionary<Distance, Distance> ModifyValue(Dictionary<Distance, Distance> value) + private static Dictionary<Distance, Distance> ModifyValue(Dictionary<Distance, Distance> value) { if (value == null) value = new Dictionary<Distance, Distance>(); @@ -352,7 +354,7 @@ namespace Thrift.Tests.DataModel return value; } - private THashSet<Distance> ModifyValue(THashSet<Distance> value) + private static THashSet<Distance> ModifyValue(THashSet<Distance> value) { if (value == null) value = new THashSet<Distance>(); @@ -375,7 +377,7 @@ namespace Thrift.Tests.DataModel return value; } - private List<Distance> ModifyValue(List<Distance> value) + private static List<Distance> ModifyValue(List<Distance> value) { if (value == null) value = new List<Distance>(); @@ -385,12 +387,12 @@ namespace Thrift.Tests.DataModel return value; } - private bool ModifyValue(bool value) + private static bool ModifyValue(bool value) { return !value; } - private Dictionary<sbyte, short> ModifyValue(Dictionary<sbyte, short> value) + private static Dictionary<sbyte, short> ModifyValue(Dictionary<sbyte, short> value) { if (value == null) value = new Dictionary<sbyte, short>(); @@ -398,7 +400,7 @@ namespace Thrift.Tests.DataModel return value; } - private THashSet<long> ModifyValue(THashSet<long> value) + private static THashSet<long> ModifyValue(THashSet<long> value) { if (value == null) value = new THashSet<long>(); @@ -406,7 +408,7 @@ namespace Thrift.Tests.DataModel return value; } - private List<int> ModifyValue(List<int> value) + private static List<int> ModifyValue(List<int> value) { if (value == null) value = new List<int>(); @@ -414,7 +416,7 @@ namespace Thrift.Tests.DataModel return value; } - private byte[] ModifyValue(byte[] value) + private static byte[] ModifyValue(byte[] value) { if (value == null) value = new byte[1] { 0 }; @@ -423,27 +425,27 @@ namespace Thrift.Tests.DataModel return value; } - private string ModifyValue(string value) + private static string ModifyValue(string value) { return value + "1"; } - private double ModifyValue(double value) + private static double ModifyValue(double value) { return value + 1.1; } - private short ModifyValue(short value) + private static short ModifyValue(short value) { return ++value; } - private Distance ModifyValue(Distance value) + private static Distance ModifyValue(Distance value) { return ++value; } - private void VerifyDifferentContent(RaceDetails first, RaceDetails second) + private static void VerifyDifferentContent(RaceDetails first, RaceDetails second) { Assert.AreNotEqual(first, second); @@ -521,7 +523,7 @@ namespace Thrift.Tests.DataModel Assert.AreNotEqual(first.Triplesix, second.Triplesix); } - private void VerifyIdenticalContent(RaceDetails first, RaceDetails second) + private static void VerifyIdenticalContent(RaceDetails first, RaceDetails second) { Assert.AreEqual(first, second); diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 18fce0177..38a6a5c3a 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -21,6 +21,7 @@ <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <Version>0.16.0.0</Version> + <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> |