mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
refactor and fix compiler warning
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
14
mRemoteV1/UI/Controls/SecureTextBox.Designer.cs
generated
14
mRemoteV1/UI/Controls/SecureTextBox.Designer.cs
generated
@@ -11,13 +11,21 @@
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
// 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 = "<SecString>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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user