THRIFT-5746 Upgrade to net8
Client: netstd
Patch: Jens Geyer
diff --git a/lib/netstd/Thrift/.editorconfig b/lib/netstd/Thrift/.editorconfig
index 54b698c..82ff4a3 100644
--- a/lib/netstd/Thrift/.editorconfig
+++ b/lib/netstd/Thrift/.editorconfig
@@ -2,3 +2,8 @@
# CS1591: missing XML comment for public element
dotnet_diagnostic.CS1591.severity = silent
+
+# silence certain yet unfixed false positives for net8
+dotnet_diagnostic.IDE0290.severity = silent
+dotnet_diagnostic.CA1510.severity = silent
+dotnet_diagnostic.CA1513.severity = silent
diff --git a/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs b/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs
index 9759058..5fc1fda 100644
--- a/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs
+++ b/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs
@@ -23,6 +23,11 @@
using Thrift.Protocol;
using Thrift.Protocol.Entities;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0028 // net8 - simplified collection init
+#pragma warning disable IDE0300 // net8 - simplified collection init
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Processor
{
// ReSharper disable once InconsistentNaming
@@ -30,8 +35,7 @@
{
//TODO: Localization
- private readonly Dictionary<string, ITAsyncProcessor> _serviceProcessorMap =
- new Dictionary<string, ITAsyncProcessor>();
+ private readonly Dictionary<string, ITAsyncProcessor> _serviceProcessorMap = new Dictionary<string, ITAsyncProcessor>();
public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot)
{
diff --git a/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs b/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs
index 97ecff6..568a50c 100644
--- a/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs
+++ b/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation(ASF) under one
+// Licensed to the Apache Software Foundation(ASF) under one
// or more contributor license agreements.See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.The ASF licenses this file
@@ -18,6 +18,9 @@
using Thrift.Server;
using Thrift.Transport;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Processor
{
// ReSharper disable once InconsistentNaming
@@ -35,4 +38,4 @@
return _asyncProcessor;
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Entities/TField.cs b/lib/netstd/Thrift/Protocol/Entities/TField.cs
index 4e29bb5..92fd41a 100644
--- a/lib/netstd/Thrift/Protocol/Entities/TField.cs
+++ b/lib/netstd/Thrift/Protocol/Entities/TField.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol.Entities
{
// ReSharper disable once InconsistentNaming
@@ -34,4 +37,4 @@
// ReSharper disable once InconsistentNaming - do not rename - it used for generation
public short ID { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Entities/TList.cs b/lib/netstd/Thrift/Protocol/Entities/TList.cs
index f599225..7e5c545 100644
--- a/lib/netstd/Thrift/Protocol/Entities/TList.cs
+++ b/lib/netstd/Thrift/Protocol/Entities/TList.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol.Entities
{
// ReSharper disable once InconsistentNaming
@@ -30,4 +33,4 @@
public int Count { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Entities/TMap.cs b/lib/netstd/Thrift/Protocol/Entities/TMap.cs
index 1efebe7..fba5780 100644
--- a/lib/netstd/Thrift/Protocol/Entities/TMap.cs
+++ b/lib/netstd/Thrift/Protocol/Entities/TMap.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol.Entities
{
// ReSharper disable once InconsistentNaming
@@ -33,4 +36,4 @@
public int Count { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Entities/TMessage.cs b/lib/netstd/Thrift/Protocol/Entities/TMessage.cs
index 08d741d..2e586ea 100644
--- a/lib/netstd/Thrift/Protocol/Entities/TMessage.cs
+++ b/lib/netstd/Thrift/Protocol/Entities/TMessage.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol.Entities
{
// ReSharper disable once InconsistentNaming
@@ -34,4 +37,4 @@
// ReSharper disable once InconsistentNaming - do not rename - it used for generation
public int SeqID { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Entities/TSet.cs b/lib/netstd/Thrift/Protocol/Entities/TSet.cs
index 692d564..d29cc0d 100644
--- a/lib/netstd/Thrift/Protocol/Entities/TSet.cs
+++ b/lib/netstd/Thrift/Protocol/Entities/TSet.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol.Entities
{
// ReSharper disable once InconsistentNaming
@@ -35,4 +38,4 @@
public int Count { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Entities/TStruct.cs b/lib/netstd/Thrift/Protocol/Entities/TStruct.cs
index d876087..b2fd000 100644
--- a/lib/netstd/Thrift/Protocol/Entities/TStruct.cs
+++ b/lib/netstd/Thrift/Protocol/Entities/TStruct.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol.Entities
{
// ReSharper disable once InconsistentNaming
diff --git a/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs b/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs
index 7feb698..6389184 100644
--- a/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs
+++ b/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs
@@ -24,6 +24,8 @@
using Thrift.Protocol.Utilities;
using Thrift.Transport;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
namespace Thrift.Protocol
{
@@ -33,8 +35,8 @@
protected const uint VersionMask = 0xffff0000;
protected const uint Version1 = 0x80010000;
- protected bool StrictRead;
- protected bool StrictWrite;
+ protected readonly bool StrictRead;
+ protected readonly bool StrictWrite;
// minimize memory allocations by means of an preallocated bytes buffer
// The value of 128 is arbitrarily chosen, the required minimum size must be sizeof(long)
@@ -470,15 +472,10 @@
public class Factory : TProtocolFactory
{
- protected bool StrictRead;
- protected bool StrictWrite;
+ protected readonly bool StrictRead;
+ protected readonly bool StrictWrite;
- public Factory()
- : this(false, true)
- {
- }
-
- public Factory(bool strictRead, bool strictWrite)
+ public Factory(bool strictRead = false, bool strictWrite = true)
{
StrictRead = strictRead;
StrictWrite = strictWrite;
diff --git a/lib/netstd/Thrift/Protocol/TCompactProtocol.cs b/lib/netstd/Thrift/Protocol/TCompactProtocol.cs
index dd38f48..8e5d00d 100644
--- a/lib/netstd/Thrift/Protocol/TCompactProtocol.cs
+++ b/lib/netstd/Thrift/Protocol/TCompactProtocol.cs
@@ -27,6 +27,8 @@
using Thrift.Protocol.Utilities;
using Thrift.Transport;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0301 // net8 - simplified collection init
namespace Thrift.Protocol
{
diff --git a/lib/netstd/Thrift/Protocol/TJSONProtocol.cs b/lib/netstd/Thrift/Protocol/TJSONProtocol.cs
index 9f761ae..64308d6 100644
--- a/lib/netstd/Thrift/Protocol/TJSONProtocol.cs
+++ b/lib/netstd/Thrift/Protocol/TJSONProtocol.cs
@@ -27,6 +27,8 @@
using Thrift.Protocol.Utilities;
using Thrift.Transport;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
namespace Thrift.Protocol
{
diff --git a/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs b/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs
index fbc8c05..510dc28 100644
--- a/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs
+++ b/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs
@@ -19,6 +19,9 @@
using System.Threading.Tasks;
using Thrift.Protocol.Entities;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Protocol
{
/**
diff --git a/lib/netstd/Thrift/Protocol/ToString.cs b/lib/netstd/Thrift/Protocol/ToString.cs
index ae69d1c..9a94c08 100644
--- a/lib/netstd/Thrift/Protocol/ToString.cs
+++ b/lib/netstd/Thrift/Protocol/ToString.cs
@@ -34,16 +34,16 @@
sb.Append(", ");
bool first_child = true;
- if (self is string) // string is IEnumerable
+ if (self is string str) // string is IEnumerable
{
sb.Append('"');
- sb.Append(self);
+ sb.Append(str);
sb.Append('"');
}
- else if (self is IDictionary)
+ else if (self is IDictionary dict)
{
sb.Append("{ ");
- foreach (DictionaryEntry pair in (self as IDictionary))
+ foreach (DictionaryEntry pair in dict)
{
if (first_child)
first_child = false;
@@ -58,23 +58,23 @@
}
sb.Append('}');
}
- else if (self is IEnumerable)
+ else if (self is IEnumerable enumerable)
{
sb.Append("{ ");
- foreach (var elm in (self as IEnumerable))
+ foreach (var elm in enumerable)
{
elm.ToString(sb, first_child);
first_child = false;
}
sb.Append('}');
}
- else if (self is TBase)
+ else if (self is TBase tbase)
{
- sb.Append((self as TBase).ToString());
+ sb.Append(tbase.ToString());
}
- else if (self is double)
+ else if (self is double dbVal)
{
- sb.Append(((double)self).ToString(CultureInfo.InvariantCulture));
+ sb.Append(dbVal.ToString(CultureInfo.InvariantCulture));
}
else
{
diff --git a/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs b/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs
index 90b8f88..15ef04f 100644
--- a/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs
+++ b/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs
@@ -17,6 +17,12 @@
using System;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0300 // net8 - simplified collection init
+#pragma warning disable IDE0028 // net8 - simplified collection init
+#pragma warning disable CA1510 // net8 - use ThrowIfNull
+#pragma warning disable CA1513 // net8 - use ThrowIfNull
+
namespace Thrift.Protocol.Utilities
{
// ReSharper disable once InconsistentNaming
@@ -98,4 +104,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs b/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs
index 190ddbb..ecc0263 100644
--- a/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs
+++ b/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs
@@ -42,9 +42,7 @@
private static void SwapBytes(ref byte one, ref byte two)
{
- var tmp = one;
- one = two;
- two = tmp;
+ (two, one) = (one, two);
}
#region SelfTest
diff --git a/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs b/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs
index f8c261a..6e248db 100644
--- a/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs
+++ b/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0300 // net8 - simplified collection init
+
namespace Thrift.Protocol.Utilities
{
// ReSharper disable once InconsistentNaming
diff --git a/lib/netstd/Thrift/Server/TServer.cs b/lib/netstd/Thrift/Server/TServer.cs
index 3d4f3fc..5f5bc49 100644
--- a/lib/netstd/Thrift/Server/TServer.cs
+++ b/lib/netstd/Thrift/Server/TServer.cs
@@ -65,8 +65,7 @@
// Log delegation? deprecated, use ILogger
protected void LogError( string msg)
{
- if (Logger != null)
- Logger.LogError("{Msg}",msg); // NOTE: Log message template, not string interpolation!
+ Logger?.LogError("{Msg}",msg); // NOTE: Log message template, not string interpolation!
}
public abstract void Stop();
diff --git a/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs b/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs
index f1f6277..ffa3b88 100644
--- a/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs
+++ b/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs
@@ -23,6 +23,8 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
namespace Thrift.Server
{
diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj
index 2ebfb06..c7b2a82 100644
--- a/lib/netstd/Thrift/Thrift.csproj
+++ b/lib/netstd/Thrift/Thrift.csproj
@@ -19,7 +19,7 @@
-->
<PropertyGroup>
- <TargetFrameworks>netstandard2.1;netstandard2.0;net6.0;net7.0</TargetFrameworks>
+ <TargetFrameworks>netstandard2.1;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<AssemblyName>Thrift</AssemblyName>
<PackageId>ApacheThrift</PackageId>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
diff --git a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs
index bda1290..0a51c9a 100644
--- a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs
+++ b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs
@@ -25,6 +25,9 @@
using System.Threading;
using System.Threading.Tasks;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0028 // net8 - simplified collection init
+
namespace Thrift.Transport.Client
{
//TODO: check for correct work
diff --git a/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs b/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs
index 694ea0f..5e67f10 100644
--- a/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs
+++ b/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs
@@ -21,6 +21,10 @@
using System.Threading;
using System.Threading.Tasks;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable CA1510 // net8 - use ThrowIfNull
+#pragma warning disable CA1513 // net8 - use ThrowIfNull
+
namespace Thrift.Transport
{
// ReSharper disable once InconsistentNaming
diff --git a/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs b/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs
index 98fbd22..3d855a4 100644
--- a/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs
+++ b/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation(ASF) under one
+// Licensed to the Apache Software Foundation(ASF) under one
// or more contributor license agreements.See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.The ASF licenses this file
@@ -16,8 +16,9 @@
// under the License.
using System;
-using System.Collections.Generic;
-using System.Text;
+
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
namespace Thrift.Transport
{
diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs
index b1ed91e..138c7fd 100644
--- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs
+++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs
@@ -28,6 +28,11 @@
using System.IO;
using System.Diagnostics;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0028 // net8 - simplified collection init
+#pragma warning disable IDE0300 // net8 - simplified collection init
+#pragma warning disable IDE0290 // net8 - primary CTOR
+#pragma warning disable SYSLIB1054 // net8 - use LibraryImport attribute
#pragma warning disable CS1998 // async no await
namespace Thrift.Transport.Server
@@ -46,7 +51,7 @@
// to manage incoming connections, we set up a task for each stream to listen on
private struct TaskStreamPair
{
- public NamedPipeServerStream Stream;
+ public readonly NamedPipeServerStream Stream;
public Task Task;
public TaskStreamPair(NamedPipeServerStream stream, Task task)
@@ -321,8 +326,9 @@
// there must be an exact mapping between task index and stream index
Debug.Assert(_streams.Count == tasks.Count);
+ #pragma warning disable IDE0305 // see https://github.com/dotnet/roslyn/issues/70656 - yet unsolved
var index = Task.WaitAny(tasks.ToArray(), cancellationToken);
-
+ #pragma warning restore IDE0305
var trans = new ServerTransport(_streams[index].Stream, Configuration);
_streams.RemoveAt(index); // pass stream ownership to ServerTransport
diff --git a/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs b/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs
index 31ecef3..43663c3 100644
--- a/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs
+++ b/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs
@@ -22,6 +22,9 @@
using System.Threading.Tasks;
using Thrift.Transport.Client;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Transport.Server
{
diff --git a/lib/netstd/Thrift/Transport/Server/TServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TServerTransport.cs
index 5366114..70857c5 100644
--- a/lib/netstd/Thrift/Transport/Server/TServerTransport.cs
+++ b/lib/netstd/Thrift/Transport/Server/TServerTransport.cs
@@ -18,6 +18,9 @@
using System.Threading;
using System.Threading.Tasks;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable IDE0290 // net8 - primary CTOR
+
namespace Thrift.Transport
{
// ReSharper disable once InconsistentNaming
@@ -40,14 +43,8 @@
public async ValueTask<TTransport> AcceptAsync(CancellationToken cancellationToken = default)
{
- var transport = await AcceptImplementationAsync(cancellationToken);
-
- if (transport == null)
- {
- throw new TTransportException($"{nameof(AcceptImplementationAsync)} should not return null");
- }
-
- return transport;
+ return await AcceptImplementationAsync(cancellationToken)
+ ?? throw new TTransportException($"{nameof(AcceptImplementationAsync)} should not return null");
}
}
}
diff --git a/lib/netstd/Thrift/Transport/TTransport.cs b/lib/netstd/Thrift/Transport/TTransport.cs
index 2f87ca0..4420224 100644
--- a/lib/netstd/Thrift/Transport/TTransport.cs
+++ b/lib/netstd/Thrift/Transport/TTransport.cs
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation(ASF) under one
+// Licensed to the Apache Software Foundation(ASF) under one
// or more contributor license agreements.See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.The ASF licenses this file
@@ -21,6 +21,10 @@
using System.Threading;
using System.Threading.Tasks;
+#pragma warning disable IDE0079 // net20 - unneeded suppression
+#pragma warning disable CA1510 // net8 - use ThrowIfNull
+#pragma warning disable CA1513 // net8 - use ThrowIfNull
+
namespace Thrift.Transport
{
//TODO: think about client info