fix CA2213 warnings

This commit is contained in:
Sean Kaim
2019-02-20 23:15:26 -05:00
parent 1bb18abf5a
commit a512465d07
9 changed files with 40 additions and 16 deletions

View File

@@ -335,7 +335,8 @@ namespace mRemoteNG.Connection.Protocol
{
if (!disposing) return;
tmrReconnect?.Dispose();
if(tmrReconnect != null)
tmrReconnect.Dispose();
}
public void Dispose()

View File

@@ -61,8 +61,11 @@ namespace mRemoteNG.Security
{
if (!disposing) return;
_machineKey?.Dispose();
_secureString?.Dispose();
if(_machineKey != null)
_machineKey.Dispose();
if(_secureString != null)
_secureString.Dispose();
}
public void Dispose()

View File

@@ -168,7 +168,8 @@ namespace mRemoteNG.Tools
{
if (!disposing) return;
Process?.Dispose();
if(Process != null)
Process.Dispose();
Handle = IntPtr.Zero;
}

View File

@@ -69,8 +69,11 @@ namespace mRemoteNG.UI.Controls
{
if (disposing)
{
components?.Dispose();
_statusImageList?.Dispose();
if(components != null)
components.Dispose();
if(_statusImageList != null)
_statusImageList.Dispose();
}
base.Dispose(disposing);

View File

@@ -63,7 +63,8 @@ namespace mRemoteNG.UI.Controls
{
if (disposing)
{
components?.Dispose();
if(components != null)
components.Dispose();
}
base.Dispose(disposing);

View File

@@ -1,4 +1,4 @@
using TextBox = mRemoteNG.UI.Forms.TextBox;
using TextBox = mRemoteNG.UI.Forms.TextBox;
namespace mRemoteNG.UI.Forms
{
@@ -12,9 +12,13 @@ namespace mRemoteNG.UI.Forms
{
try
{
if (disposing && components != null)
if (disposing)
{
components.Dispose();
if(components != null)
components.Dispose();
if(_password != null)
_password.Dispose();
}
}
finally

View File

@@ -1,4 +1,4 @@
namespace mRemoteNG.UI.Forms
namespace mRemoteNG.UI.Forms
{
public partial class FrmMain : System.Windows.Forms.Form
{
@@ -9,10 +9,15 @@ namespace mRemoteNG.UI.Forms
{
try
{
if (disposing && components != null)
if (disposing)
{
components.Dispose();
}
if(components != null)
components.Dispose();
if(_screenSystemMenu != null)
_screenSystemMenu.Dispose();
}
}
finally
{

View File

@@ -60,7 +60,8 @@ namespace mRemoteNG.UI.Menu
{
if (!disposing) return;
_systemMenu?.Dispose();
if(_systemMenu != null)
_systemMenu.Dispose();
}
public void Dispose()

View File

@@ -357,16 +357,21 @@ namespace mRemoteNG.UI.Tabs
ResumeLayout();
}
// This seems like a bogus warning - suppressing since Components is being disposed...
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "<Components>k__BackingField")]
protected override void Dispose(bool disposing)
{
if (disposing)
{
Components.Dispose();
if(Components != null)
Components.Dispose();
if (m_boldFont != null)
{
m_boldFont.Dispose();
m_boldFont = null;
}
}
base.Dispose(disposing);