diff --git a/.editorconfig b/.editorconfig
index 899395944..f92acc7da 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -620,12 +620,21 @@ dotnet_diagnostic.MA0112.severity = warning
# MA0165: Make interpolated string
dotnet_diagnostic.MA0165.severity = none
+# MA0173 - Use LazyInitializer.EnsureInitialize
+dotnet_diagnostic.MA0173.severity = none
+
# MA0182: Avoid unused internal types
dotnet_diagnostic.MA0182.severity = none
# MA0184: Do not use interpolated string without parameters
dotnet_diagnostic.MA0184.severity = none
+# MA0190 - Use partial property instead of partial method for GeneratedRegex
+dotnet_diagnostic.MA0190.severity = none
+
+# MA0192 - Use HasFlag instead of bitwise checks
+dotnet_diagnostic.MA0192.severity = none
+
#### MSTest rules ####
# MSTEST0015: Test method should not be ignored
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 8991d83e0..c03b54e08 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -6,22 +6,22 @@
-
-
-
-
+
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
diff --git a/src/Renci.SshNet/Abstractions/SocketAbstraction.cs b/src/Renci.SshNet/Abstractions/SocketAbstraction.cs
index 63dc2bf54..1dc992da5 100644
--- a/src/Renci.SshNet/Abstractions/SocketAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/SocketAbstraction.cs
@@ -8,6 +8,8 @@
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Transport;
+#pragma warning disable MA0204 // Remove unnecessary partial modifier; not true for all targets
+
namespace Renci.SshNet.Abstractions
{
internal static partial class SocketAbstraction
diff --git a/src/Renci.SshNet/Connection/HttpConnector.cs b/src/Renci.SshNet/Connection/HttpConnector.cs
index 063562f8a..07e713dcf 100644
--- a/src/Renci.SshNet/Connection/HttpConnector.cs
+++ b/src/Renci.SshNet/Connection/HttpConnector.cs
@@ -31,6 +31,7 @@ namespace Renci.SshNet.Connection
///
///
///
+#pragma warning disable MA0204 // Remove unnecessary partial modifier; not true for all targets
internal sealed partial class HttpConnector : ProxyConnector
{
private const string HttpResponsePattern = @"HTTP/(?\d[.]\d) (?\d{3}) (?.+)$";
diff --git a/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs b/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs
index a0c67a865..27ae098af 100644
--- a/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs
+++ b/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs
@@ -19,6 +19,7 @@ namespace Renci.SshNet.Connection
///
/// https://tools.ietf.org/html/rfc4253#section-4.2.
///
+#pragma warning disable MA0204 // Remove unnecessary partial modifier; not true for all targets
internal sealed partial class ProtocolVersionExchange : IProtocolVersionExchange
{
private const byte Null = 0x00;
diff --git a/src/Renci.SshNet/ForwardedPortLocal.cs b/src/Renci.SshNet/ForwardedPortLocal.cs
index b021ab736..9bf5c0583 100644
--- a/src/Renci.SshNet/ForwardedPortLocal.cs
+++ b/src/Renci.SshNet/ForwardedPortLocal.cs
@@ -12,7 +12,7 @@ namespace Renci.SshNet
///
/// Provides functionality for local port forwarding.
///
- public partial class ForwardedPortLocal : ForwardedPort
+ public class ForwardedPortLocal : ForwardedPort
{
private ForwardedPortStatus _status;
private bool _isDisposed;
diff --git a/src/Renci.SshNet/IServiceFactory.cs b/src/Renci.SshNet/IServiceFactory.cs
index 681d69da9..48ca70c87 100644
--- a/src/Renci.SshNet/IServiceFactory.cs
+++ b/src/Renci.SshNet/IServiceFactory.cs
@@ -14,7 +14,7 @@ namespace Renci.SshNet
///
/// Factory for creating new services.
///
- internal partial interface IServiceFactory
+ internal interface IServiceFactory
{
///
/// Creates an .
diff --git a/src/Renci.SshNet/Netconf/NetConfSession.cs b/src/Renci.SshNet/Netconf/NetConfSession.cs
index 60edc2d81..941d4959c 100644
--- a/src/Renci.SshNet/Netconf/NetConfSession.cs
+++ b/src/Renci.SshNet/Netconf/NetConfSession.cs
@@ -7,6 +7,8 @@
using Renci.SshNet.Common;
+#pragma warning disable MA0204 // Remove unnecessary partial modifier; not true for all targets
+
namespace Renci.SshNet.NetConf
{
internal sealed partial class NetConfSession : SubsystemSession, INetConfSession
@@ -129,7 +131,7 @@ protected override void OnDataReceived(ArraySegment data)
{
_ = _data.Append(chunk);
- if (!chunk.Contains(Prompt))
+ if (!chunk.Contains(Prompt, StringComparison.Ordinal))
{
return;
}
@@ -194,7 +196,7 @@ protected override void OnDataReceived(ArraySegment data)
{
_ = _data.Append(chunk);
- if (!chunk.Contains(Prompt))
+ if (!chunk.Contains(Prompt, StringComparison.Ordinal))
{
return;
}
diff --git a/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs b/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs
index 5bae05f20..f63c4390e 100644
--- a/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs
+++ b/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs
@@ -70,7 +70,7 @@ public Key Parse()
throw new SshException("Invalid passphrase.");
}
- if (keyType.Contains("rsa"))
+ if (keyType.Contains("rsa", StringComparison.Ordinal))
{
var exponent = ReadBigIntWithBits(keyReader);
var d = ReadBigIntWithBits(keyReader);
diff --git a/src/Renci.SshNet/ScpClient.cs b/src/Renci.SshNet/ScpClient.cs
index 1a63f3210..fffa96011 100644
--- a/src/Renci.SshNet/ScpClient.cs
+++ b/src/Renci.SshNet/ScpClient.cs
@@ -30,6 +30,7 @@ namespace Renci.SshNet
///
///
///
+#pragma warning disable MA0204 // Remove unnecessary partial modifier; not true for all targets
public partial class ScpClient : BaseClient
{
private const string FileInfoPattern = @"C(?\d{4}) (?\d+) (?.+)";
diff --git a/src/Renci.SshNet/ServiceFactory.cs b/src/Renci.SshNet/ServiceFactory.cs
index f9dbdc42b..937f4224d 100644
--- a/src/Renci.SshNet/ServiceFactory.cs
+++ b/src/Renci.SshNet/ServiceFactory.cs
@@ -16,7 +16,7 @@ namespace Renci.SshNet
///
/// Basic factory for creating new services.
///
- internal sealed partial class ServiceFactory : IServiceFactory
+ internal sealed class ServiceFactory : IServiceFactory
{
///
/// Defines the number of times an authentication attempt with any given
diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs
index 20106a2c5..839e4a03e 100644
--- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs
+++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs
@@ -8,7 +8,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
/// Provides SCP client functionality.
///
[TestClass]
- public partial class ScpClientTest : IntegrationTestBase
+ public class ScpClientTest : IntegrationTestBase
{
[TestMethod]
[TestCategory("Scp")]
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.cs
index 766dd23a6..b17cf0e0d 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.cs
@@ -11,7 +11,7 @@ namespace Renci.SshNet.Tests.Classes
/// Provides functionality for local port forwarding
///
[TestClass]
- public partial class ForwardedPortLocalTest : TestBase
+ public class ForwardedPortLocalTest : TestBase
{
[TestMethod]
public void ConstructorShouldThrowArgumentNullExceptionWhenBoundHostIsNull()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest.cs
index b18e4ab57..e72aff2c6 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest.cs
@@ -10,7 +10,7 @@ namespace Renci.SshNet.Tests.Classes
/// Provides functionality for remote port forwarding
///
[TestClass]
- public partial class ForwardedPortRemoteTest : TestBase
+ public class ForwardedPortRemoteTest : TestBase
{
[TestMethod]
public void Start_NotAddedToClient()
diff --git a/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs b/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs
index 03f6e3025..7004a9408 100644
--- a/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs
@@ -10,7 +10,7 @@ namespace Renci.SshNet.Tests.Classes
/// Provides functionality to perform keyboard interactive authentication.
///
[TestClass]
- public partial class KeyboardInteractiveAuthenticationMethodTest : TestBase
+ public class KeyboardInteractiveAuthenticationMethodTest : TestBase
{
[TestMethod]
public void Keyboard_Test_Pass_Null()
diff --git a/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs b/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs
index 820138f26..0e519ee2d 100644
--- a/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs
@@ -10,7 +10,7 @@ namespace Renci.SshNet.Tests.Classes
/// Provides functionality to perform password authentication.
///
[TestClass]
- public partial class PasswordAuthenticationMethodTest : TestBase
+ public class PasswordAuthenticationMethodTest : TestBase
{
[TestMethod]
public void Password_Test_Pass_Null_Username()
diff --git a/test/Renci.SshNet.Tests/Classes/ScpClientTest.cs b/test/Renci.SshNet.Tests/Classes/ScpClientTest.cs
index e85b0b536..35643adb0 100644
--- a/test/Renci.SshNet.Tests/Classes/ScpClientTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/ScpClientTest.cs
@@ -12,7 +12,7 @@ namespace Renci.SshNet.Tests.Classes
/// Provides SCP client functionality.
///
[TestClass]
- public partial class ScpClientTest : TestBase
+ public class ScpClientTest : TestBase
{
private Random _random;
diff --git a/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs b/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
index a18a63b3f..ec69a9572 100644
--- a/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
@@ -287,7 +287,7 @@ public void CertificateBadCASignature_VerifySignatureReturnsFalse()
"PD7/nXcyxnY3zALlPQTxb19EVx5lz58BS96gg=";
char[] chars = goodCertString.ToCharArray();
- chars[^10] = 'a';
+ chars[chars.Length - 10] = 'a';
string badCertString = new string(chars);
Assert.IsTrue(VerifySignature(goodCertString));
diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest.cs b/test/Renci.SshNet.Tests/Classes/SessionTest.cs
index 05c7f3428..62cc837bf 100644
--- a/test/Renci.SshNet.Tests/Classes/SessionTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/SessionTest.cs
@@ -14,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes
/// Provides functionality to connect and interact with SSH server.
///
[TestClass]
- public partial class SessionTest : TestBase
+ public class SessionTest : TestBase
{
private Mock _serviceFactoryMock;
private Mock _socketFactoryMock;
diff --git a/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs b/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs
index e677f4961..46910bafb 100644
--- a/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs
+++ b/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs
@@ -10,7 +10,7 @@ namespace Renci.SshNet.Tests.Classes
/// Represents SSH command that can be executed.
///
[TestClass]
- public partial class SshCommandTest : TestBase
+ public class SshCommandTest : TestBase
{
[TestMethod]
public void Test_Execute_SingleCommand_Without_Connecting()
diff --git a/test/Renci.SshNet.Tests/Classes/SubsystemSession_Connect_NeverConnected.cs b/test/Renci.SshNet.Tests/Classes/SubsystemSession_Connect_NeverConnected.cs
deleted file mode 100644
index 23bd273ed..000000000
--- a/test/Renci.SshNet.Tests/Classes/SubsystemSession_Connect_NeverConnected.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Renci.SshNet.Tests.Classes
-{
- class SubsystemSession_Connect_NeverConnected
- {
- }
-}
diff --git a/test/Renci.SshNet.Tests/Classes/SubsystemSession_SendData_Disconnected.cs b/test/Renci.SshNet.Tests/Classes/SubsystemSession_SendData_Disconnected.cs
deleted file mode 100644
index 92754621d..000000000
--- a/test/Renci.SshNet.Tests/Classes/SubsystemSession_SendData_Disconnected.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Renci.SshNet.Tests.Classes
-{
- class SubsystemSession_SendData_Disconnected
- {
- }
-}