summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2022-01-09 16:50:52 +0100
committerJens Geyer <Jens-G@users.noreply.github.com>2022-01-09 21:57:30 +0100
commit98a232577fa56bb703ea96b88cc6c5b9391178f0 (patch)
tree916efb58623cd23042ed192961ac4df9387c221c
parent39d7278ddffce27d45380c483a84d013f6db4d7b (diff)
downloadthrift-98a232577fa56bb703ea96b88cc6c5b9391178f0.tar.gz
THRIFT-5479 Add net 6 support
-rw-r--r--compiler/cpp/src/thrift/generate/t_netstd_generator.cc5
-rw-r--r--compiler/cpp/src/thrift/generate/t_netstd_generator.h12
-rw-r--r--lib/netstd/Benchmarks/Thrift.Benchmarks/CompactProtocolBenchmarks.cs14
-rw-r--r--lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj1
-rw-r--r--lib/netstd/Tests/Thrift.IntegrationTests/Protocols/ProtocolsOperationsTests.cs11
-rw-r--r--lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj1
-rw-r--r--lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj1
-rw-r--r--lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs4
-rw-r--r--lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs34
-rw-r--r--lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj1
-rw-r--r--test/netstd/Client/Client.csproj1
-rw-r--r--test/netstd/Client/Performance/PerformanceTests.cs52
-rw-r--r--test/netstd/Client/Performance/TestDataFactory.cs25
-rw-r--r--test/netstd/Client/TestClient.cs11
-rw-r--r--test/netstd/Server/Server.csproj1
-rw-r--r--test/netstd/Server/TestServer.cs15
16 files changed, 110 insertions, 79 deletions
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
index 88f8da417..1f8e169da 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
@@ -304,7 +304,8 @@ void t_netstd_generator::reset_indent() {
void t_netstd_generator::start_netstd_namespace(ostream& out)
{
- out << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << endl
+ out << "#nullable disable // suppress C# 8.0 nullable contexts (we still support earlier versions)" << endl
+ << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << endl
<< "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << endl
<< "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << endl
<< endl;
@@ -862,7 +863,7 @@ void t_netstd_generator::generate_netstd_struct(t_struct* tstruct, bool is_excep
f_struct.open(f_struct_name.c_str());
- reset_indent();
+ reset_indent();
f_struct << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl;
generate_netstd_struct_definition(f_struct, tstruct, is_exception);
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.h b/compiler/cpp/src/thrift/generate/t_netstd_generator.h
index 47a704280..31226f245 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.h
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.h
@@ -150,6 +150,18 @@ public:
string convert_to_pascal_case(const string& str);
string get_enum_class_name(t_type* type);
+protected:
+ std::string autogen_comment() override {
+ return std::string("/**\n")
+ + " * <auto-generated>\n"
+ + " * " + autogen_summary() + "\n"
+ + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+ + " * </auto-generated>\n"
+ " */\n"
+ ;
+ }
+
+
private:
string namespace_name_;
string namespace_dir_;
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>
diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj
index c7d53493e..859297f97 100644
--- a/test/netstd/Client/Client.csproj
+++ b/test/netstd/Client/Client.csproj
@@ -31,6 +31,7 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
diff --git a/test/netstd/Client/Performance/PerformanceTests.cs b/test/netstd/Client/Performance/PerformanceTests.cs
index f9eb9e4e4..c1f00ddf8 100644
--- a/test/netstd/Client/Performance/PerformanceTests.cs
+++ b/test/netstd/Client/Performance/PerformanceTests.cs
@@ -34,10 +34,10 @@ namespace Client.Tests
{
public class PerformanceTests
{
- private CancellationTokenSource Cancel;
- private CrazyNesting Testdata;
- private TMemoryBufferTransport MemBuffer;
- private TTransport Transport;
+ private CancellationTokenSource Cancel = new();
+ private CrazyNesting? Testdata;
+ private TMemoryBufferTransport? MemBuffer;
+ private TTransport? Transport;
private LayeredChoice Layered;
private readonly TConfiguration Configuration = new();
@@ -76,52 +76,49 @@ namespace Client.Tests
}
}
- private Task<TProtocol> GenericProtocolFactory<T>(bool forWrite)
+ private async Task<TProtocol> GenericProtocolFactory<T>(bool forWrite)
where T : TProtocol
{
var oldTrans = Transport;
try
{
+ Transport = null;
+
// read happens after write here, so let's take over the written bytes
if (forWrite)
MemBuffer = new TMemoryBufferTransport(Configuration);
else
- MemBuffer = new TMemoryBufferTransport(MemBuffer.GetBuffer(), Configuration);
+ MemBuffer = new TMemoryBufferTransport(MemBuffer?.GetBuffer(), Configuration);
// layered transports anyone?
- switch (Layered)
+ Transport = Layered switch
{
- case LayeredChoice.None:
- Transport = MemBuffer;
- break;
- case LayeredChoice.Framed:
- Transport = new TFramedTransport(MemBuffer);
- break;
- case LayeredChoice.Buffered:
- Transport = new TBufferedTransport(MemBuffer);
- break;
- default:
- Debug.Assert(false);
- break;
- }
+ LayeredChoice.None => MemBuffer,
+ LayeredChoice.Framed => new TFramedTransport(MemBuffer),
+ LayeredChoice.Buffered => new TBufferedTransport(MemBuffer),
+ _ => throw new Exception("Unhandled case " + Layered.ToString()),
+ };
+ ;
if (!Transport.IsOpen)
Transport.OpenAsync().Wait();
- var instance = (T)Activator.CreateInstance(typeof(T), Transport);
- return Task.FromResult<TProtocol>(instance);
+ if (Activator.CreateInstance(typeof(T), Transport) is T instance)
+ return instance;
+
+ throw new Exception("Unexpected.");
}
finally
{
- if (oldTrans is IDisposable)
- (oldTrans as IDisposable).Dispose();
+ oldTrans?.Dispose();
}
}
private string GetProtocolTransportName(TProtocol proto)
{
- var name = Transport.GetType().Name;
- if (name.Equals(MemBuffer.GetType().Name))
+ var name = Transport?.GetType().Name;
+ var bufnm = MemBuffer?.GetType().Name;
+ if ((name is null) || name.Equals(bufnm))
name = string.Empty;
else
name = " + " + name;
@@ -135,6 +132,9 @@ namespace Client.Tests
{
var stop = new Stopwatch();
+ if ((Testdata is null) || (Transport is null))
+ throw new Exception("unexpected internal state");
+
var proto = await factory(true);
stop.Start();
await Testdata.WriteAsync(proto, Cancel.Token);
diff --git a/test/netstd/Client/Performance/TestDataFactory.cs b/test/netstd/Client/Performance/TestDataFactory.cs
index 98962857c..833947c25 100644
--- a/test/netstd/Client/Performance/TestDataFactory.cs
+++ b/test/netstd/Client/Performance/TestDataFactory.cs
@@ -26,7 +26,7 @@ namespace Client.Tests
static class TestDataFactory
{
- public static CrazyNesting CreateCrazyNesting(int count = 10)
+ public static CrazyNesting? CreateCrazyNesting(int count = 10)
{
if (count <= 0)
return null;
@@ -78,13 +78,15 @@ namespace Client.Tests
private static Dictionary<Numberz, long> CreateUserMap(int count)
{
- var retval = new Dictionary<Numberz, long>();
- retval.Add(Numberz.ONE, count);
- retval.Add(Numberz.TWO, count);
- retval.Add(Numberz.THREE, count);
- retval.Add(Numberz.FIVE, count);
- retval.Add(Numberz.SIX, count);
- retval.Add(Numberz.EIGHT, count);
+ var retval = new Dictionary<Numberz, long>
+ {
+ { Numberz.ONE, count },
+ { Numberz.TWO, count },
+ { Numberz.THREE, count },
+ { Numberz.FIVE, count },
+ { Numberz.SIX, count },
+ { Numberz.EIGHT, count }
+ };
return retval;
}
@@ -138,9 +140,10 @@ namespace Client.Tests
private static Dictionary<Insanity, string> CreateListFieldDataDictValueListDict(int count)
{
- var retval = new Dictionary<Insanity, string>();
- retval.Add(CreateInsanity(count), string.Format("data level {0}", count));
- return retval;
+ return new Dictionary<Insanity, string>
+ {
+ { CreateInsanity(count), string.Format("data level {0}", count) }
+ };
}
private static byte[] CreateBytesArray(int count)
diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index 38bccf1f5..0a7fa003b 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -71,12 +71,12 @@ namespace ThriftTest
public string host = "localhost";
public int port = 9090;
public int numThreads = 1;
- public string url;
- public string pipe;
+ public string url = string.Empty;
+ public string pipe = string.Empty;
public LayeredChoice layered = LayeredChoice.None;
public ProtocolChoice protocol = ProtocolChoice.Binary;
public TransportChoice transport = TransportChoice.Socket;
- private readonly TConfiguration Configuration = null; // or new TConfiguration() if needed
+ private readonly TConfiguration Configuration = new();
internal void Parse(List<string> args)
{
@@ -210,7 +210,7 @@ namespace ThriftTest
"keys/",
};
- string existingPath = null;
+ var existingPath = string.Empty;
foreach (var possiblePath in possiblePaths)
{
var path = Path.GetFullPath(possiblePath + clientCertName);
@@ -234,8 +234,7 @@ namespace ThriftTest
public TTransport CreateTransport()
{
// endpoint transport
- TTransport trans = null;
-
+ TTransport trans;
switch (transport)
{
case TransportChoice.Http:
diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj
index 7d5eb1742..cda1dff9f 100644
--- a/test/netstd/Server/Server.csproj
+++ b/test/netstd/Server/Server.csproj
@@ -31,6 +31,7 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs
index 65458d60a..515a299f8 100644
--- a/test/netstd/Server/TestServer.cs
+++ b/test/netstd/Server/TestServer.cs
@@ -36,6 +36,7 @@ using Thrift.Transport.Server;
#pragma warning disable IDE0063 // using can be simplified, we don't
#pragma warning disable IDE0057 // substr can be simplified, we don't
+#pragma warning disable CS1998 // await missing
namespace ThriftTest
{
@@ -74,7 +75,7 @@ namespace ThriftTest
internal TransportChoice transport = TransportChoice.Socket;
internal ServerChoice server = ServerChoice.Simple;
internal int port = 9090;
- internal string pipe = null;
+ internal string pipe = string.Empty;
internal void Parse(List<string> args)
{
@@ -166,7 +167,7 @@ namespace ThriftTest
public static int _clientID = -1; // use with Interlocked only!
#pragma warning restore CA2211
- private static readonly TConfiguration Configuration = null; // or new TConfiguration() if needed
+ private static readonly TConfiguration Configuration = new();
public delegate void TestLogDelegate(string msg, params object[] values);
@@ -180,10 +181,10 @@ namespace ThriftTest
return Task.CompletedTask;
}
- public Task<object> CreateContextAsync(TProtocol input, TProtocol output, CancellationToken cancellationToken)
+ public async Task<object?> CreateContextAsync(TProtocol input, TProtocol output, CancellationToken cancellationToken)
{
callCount++;
- return Task.FromResult<object>(null);
+ return null;
}
public Task DeleteContextAsync(object serverContext, TProtocol input, TProtocol output, CancellationToken cancellationToken)
@@ -201,7 +202,7 @@ namespace ThriftTest
public class TestHandlerAsync : ThriftTest.IAsync
{
- public TServer Server { get; set; }
+ //public TServer Server { get; set; }
private readonly int handlerID;
private readonly StringBuilder sb = new();
private readonly TestLogDelegate logger;
@@ -520,7 +521,7 @@ namespace ThriftTest
"keys/",
};
- string existingPath = null;
+ var existingPath = string.Empty;
foreach (var possiblePath in possiblePaths)
{
var path = Path.GetFullPath(possiblePath + serverCertName);
@@ -595,7 +596,7 @@ namespace ThriftTest
}
// Layered transport (mandatory)
- TTransportFactory transFactory = null;
+ TTransportFactory? transFactory;
switch (param.buffering)
{
case BufferChoice.Framed: