diff --git a/mRemoteNGTests/UI/Controls/SecureTextBoxTests.cs b/mRemoteNGTests/UI/Controls/SecureTextBoxTests.cs
index 4ae5a32d..b3d5da7d 100644
--- a/mRemoteNGTests/UI/Controls/SecureTextBoxTests.cs
+++ b/mRemoteNGTests/UI/Controls/SecureTextBoxTests.cs
@@ -29,7 +29,7 @@ namespace mRemoteNGTests.UI.Controls
var textBox = new SecureTextBoxTester(_testForm.secureTextBox1.Name);
const string textToSend = "abc123";
textBox.Properties.Text = textToSend;
- Assert.That(textBox.Properties.SecureString.ConvertToUnsecureString(), Is.EqualTo(textToSend));
+ Assert.That(textBox.Properties.SecString.ConvertToUnsecureString(), Is.EqualTo(textToSend));
}
}
}
\ No newline at end of file
diff --git a/mRemoteV1/UI/Controls/ExternalToolsToolStrip.cs b/mRemoteV1/UI/Controls/ExternalToolsToolStrip.cs
index 9c2d31b8..e7ba9d37 100644
--- a/mRemoteV1/UI/Controls/ExternalToolsToolStrip.cs
+++ b/mRemoteV1/UI/Controls/ExternalToolsToolStrip.cs
@@ -116,13 +116,14 @@ namespace mRemoteNG.UI.Controls
}
#endregion
-
+ // CodeAyalysis doesn't like null propagation
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "components")]
protected override void Dispose(bool disposing)
{
try
{
- if (disposing)
- components?.Dispose();
+ if (!disposing) return;
+ components?.Dispose();
}
finally
{
diff --git a/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs b/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs
index d62df7ff..48f74b8e 100644
--- a/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs
+++ b/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs
@@ -220,12 +220,14 @@ namespace mRemoteNG.UI.Controls
}
#endregion
+ // CodeAyalysis doesn't like null propagation
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "components")]
protected override void Dispose(bool disposing)
{
try
{
- if (disposing)
- components?.Dispose();
+ if (!disposing) return;
+ components?.Dispose();
}
finally
{
diff --git a/mRemoteV1/UI/Controls/SecureTextBox.Designer.cs b/mRemoteV1/UI/Controls/SecureTextBox.Designer.cs
index 67bdcf78..c0e72fce 100644
--- a/mRemoteV1/UI/Controls/SecureTextBox.Designer.cs
+++ b/mRemoteV1/UI/Controls/SecureTextBox.Designer.cs
@@ -11,13 +11,21 @@
/// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
+ // CodeAnalysis doesn't like null propagation, and possibly IDisposable auto properties (like SecString).
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "components")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "k__BackingField")]
protected override void Dispose(bool disposing)
{
- if (disposing && (components != null))
+ try
{
- components.Dispose();
+ if (!disposing) return;
+ components?.Dispose();
+ SecString?.Dispose();
+ }
+ finally
+ {
+ base.Dispose(disposing);
}
- base.Dispose(disposing);
}
#region Component Designer generated code
diff --git a/mRemoteV1/UI/Controls/SecureTextBox.cs b/mRemoteV1/UI/Controls/SecureTextBox.cs
index 10ec694d..3af29b64 100644
--- a/mRemoteV1/UI/Controls/SecureTextBox.cs
+++ b/mRemoteV1/UI/Controls/SecureTextBox.cs
@@ -7,7 +7,7 @@ namespace mRemoteNG.UI.Controls
{
public partial class SecureTextBox : TextBox
{
- public SecureString SecureString { get; private set; } = new SecureString();
+ public SecureString SecString { get; private set; } = new SecureString();
public SecureTextBox()
{
@@ -17,7 +17,7 @@ namespace mRemoteNG.UI.Controls
private void SecureTextBox_TextChanged(object sender, System.EventArgs e)
{
- SecureString = Text.ConvertToSecureString();
+ SecString = Text.ConvertToSecureString();
}
}
}
\ No newline at end of file