Stop suppressing code analysis messages.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2020-04-29 13:15:15 +01:00
parent ec1aff6c82
commit 6dde286cc5
6 changed files with 3 additions and 47 deletions

View File

@ -32,7 +32,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Security.Permissions; using System.Security.Permissions;
@ -155,9 +154,6 @@ namespace XenAdmin.Controls
} }
[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters",
MessageId = "System.InvalidOperationException.#ctor(System.String)",
Justification = "Indicates a programming error - not user facing")]
internal ListViewItem AddSnapshot(SnapshotIcon snapshot) internal ListViewItem AddSnapshot(SnapshotIcon snapshot)
{ {
if (snapshot == null) if (snapshot == null)

View File

@ -152,8 +152,6 @@ namespace XenOvf
/// <param name="inputfile"></param> /// <param name="inputfile"></param>
/// <param name="outputfile"></param> /// <param name="outputfile"></param>
/// <param name="method"></param> /// <param name="method"></param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging only usage")]
public void UncompressFile(string inputfile, string outputfile, string method) public void UncompressFile(string inputfile, string outputfile, string method)
{ {
if (method.ToLower() == "gzip") if (method.ToLower() == "gzip")
@ -185,8 +183,7 @@ namespace XenOvf
#region PRIVATE #region PRIVATE
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging only usage")]
private void ProcessCompression(EnvelopeType env, string path, string method, bool compress) private void ProcessCompression(EnvelopeType env, string path, string method, bool compress)
{ {
if (env.References != null && env.References.File != null && env.References.File.Length > 0) if (env.References != null && env.References.File != null && env.References.File.Length > 0)

View File

@ -31,7 +31,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Management; using System.Management;
using System.Reflection; using System.Reflection;
@ -63,8 +62,6 @@ namespace XenOvf
#region CONVERSIONS #region CONVERSIONS
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope",
Justification = "Tar Object uses close not Dispose, it cleans up all streams used.")]
public static void ConvertOVFtoOVA(string pathToOvf, string ovfFileName, bool compress, bool cleanup = true) public static void ConvertOVFtoOVA(string pathToOvf, string ovfFileName, bool compress, bool cleanup = true)
{ {
// throws exception if any of the parameters is null (which we want) // throws exception if any of the parameters is null (which we want)
@ -1464,9 +1461,6 @@ namespace XenOvf
log.DebugFormat("OVF.TransformXvaOvf_SR completed {0}", vsId); log.DebugFormat("OVF.TransformXvaOvf_SR completed {0}", vsId);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging only usage")]
private void CollectInformation() private void CollectInformation()
{ {
Win32_ComputerSystem = null; Win32_ComputerSystem = null;
@ -1708,8 +1702,6 @@ namespace XenOvf
AddVssd(ovfEnv, vsId, vhsId, Properties.Settings.Default.Language); AddVssd(ovfEnv, vsId, vhsId, Properties.Settings.Default.Language);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private void AddVssd(EnvelopeType ovfEnv, string vsId, string vhsId, string lang) private void AddVssd(EnvelopeType ovfEnv, string vsId, string vhsId, string lang)
{ {
@ -1775,8 +1767,6 @@ namespace XenOvf
AddNetworks(ovfEnv, vsId, Properties.Settings.Default.Language); AddNetworks(ovfEnv, vsId, Properties.Settings.Default.Language);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private void AddNetworks(EnvelopeType ovfEnv, string vsId, string lang) private void AddNetworks(EnvelopeType ovfEnv, string vsId, string lang)
{ {
if (Win32_NetworkAdapter != null) if (Win32_NetworkAdapter != null)
@ -1875,8 +1865,6 @@ namespace XenOvf
AddCPUs(ovfEnv, vsId, Properties.Settings.Default.Language); AddCPUs(ovfEnv, vsId, Properties.Settings.Default.Language);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private void AddCPUs(EnvelopeType ovfEnv, string vsId, string lang) private void AddCPUs(EnvelopeType ovfEnv, string vsId, string lang)
{ {
UInt64 cpucount = 0; UInt64 cpucount = 0;
@ -1916,8 +1904,6 @@ namespace XenOvf
AddMemory(ovfEnv, vsId, Properties.Settings.Default.Language); AddMemory(ovfEnv, vsId, Properties.Settings.Default.Language);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private void AddMemory(EnvelopeType ovfEnv, string vsId, string lang) private void AddMemory(EnvelopeType ovfEnv, string vsId, string lang)
{ {
ulong divisor = 1024*1024; ulong divisor = 1024*1024;
@ -1955,8 +1941,6 @@ namespace XenOvf
CreateConnectedDevices(ovfEnv, vsId, Properties.Settings.Default.Language, vhdExports); CreateConnectedDevices(ovfEnv, vsId, Properties.Settings.Default.Language, vhdExports);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private void CreateConnectedDevices(EnvelopeType ovfEnv, string vsId, string lang, DiskInfo[] vhdExports) private void CreateConnectedDevices(EnvelopeType ovfEnv, string vsId, string lang, DiskInfo[] vhdExports)
{ {
//VirtualHardwareSection_Type vhs = FindVirtualHardwareSection(ovfEnv, vsId); //VirtualHardwareSection_Type vhs = FindVirtualHardwareSection(ovfEnv, vsId);

View File

@ -243,8 +243,6 @@ namespace XenOvf
/// <param name="cdId">InstanceID</param> /// <param name="cdId">InstanceID</param>
/// <param name="caption">string short description</param> /// <param name="caption">string short description</param>
/// <param name="description">string longer description</param> /// <param name="description">string longer description</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
public static string AddCDROM(EnvelopeType ovfObj, string vsId, string lang, string cdId, string caption, string description) public static string AddCDROM(EnvelopeType ovfObj, string vsId, string lang, string cdId, string caption, string description)
{ {
RASD_Type rasd = new RASD_Type(); RASD_Type rasd = new RASD_Type();
@ -289,8 +287,6 @@ namespace XenOvf
/// <param name="deviceId">String identifying the device to match to the controller</param> /// <param name="deviceId">String identifying the device to match to the controller</param>
/// <param name="iteration">which controller 0 = first, 1, 2, 3... (per type)</param> /// <param name="iteration">which controller 0 = first, 1, 2, 3... (per type)</param>
/// <returns>InstanceID of Controller</returns> /// <returns>InstanceID of Controller</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
public void AddController(EnvelopeType ovfObj, string vsId, string lang, DeviceType type, string deviceId, int iteration) public void AddController(EnvelopeType ovfObj, string vsId, string lang, DeviceType type, string deviceId, int iteration)
{ {
VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(ovfObj, vsId); VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(ovfObj, vsId);
@ -312,8 +308,6 @@ namespace XenOvf
/// <param name="deviceId">String identifying the device to match to the controller</param> /// <param name="deviceId">String identifying the device to match to the controller</param>
/// <param name="iteration">which controller 0 = first, 1, 2, 3... (per type)</param> /// <param name="iteration">which controller 0 = first, 1, 2, 3... (per type)</param>
/// <returns>InstanceID of Controller</returns> /// <returns>InstanceID of Controller</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
public void AddControllerToVHS(object vhsObj, string lang, DeviceType type, string deviceId, int iteration) public void AddControllerToVHS(object vhsObj, string lang, DeviceType type, string deviceId, int iteration)
{ {
VirtualHardwareSection_Type vhs = (VirtualHardwareSection_Type)vhsObj; VirtualHardwareSection_Type vhs = (VirtualHardwareSection_Type)vhsObj;
@ -429,8 +423,6 @@ namespace XenOvf
/// <param name="deviceInstanceId">instance ID of device</param> /// <param name="deviceInstanceId">instance ID of device</param>
/// <param name="controllerInstanceId">instance ID of controller</param> /// <param name="controllerInstanceId">instance ID of controller</param>
/// <param name="AddressOnController">where on controller 0...</param> /// <param name="AddressOnController">where on controller 0...</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
public void AddDeviceToController(EnvelopeType ovfObj, string vsId, string lang, string deviceInstanceId, string controllerInstanceId, string AddressOnController) public void AddDeviceToController(EnvelopeType ovfObj, string vsId, string lang, string deviceInstanceId, string controllerInstanceId, string AddressOnController)
{ {
VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(ovfObj, vsId); VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(ovfObj, vsId);
@ -474,8 +466,6 @@ namespace XenOvf
/// <param name="sysIdx">System Index in OVF to set memory value (0 = first VM)</param> /// <param name="sysIdx">System Index in OVF to set memory value (0 = first VM)</param>
/// <param name="idx">Section Index in Virtual Hardware Section (1 = VHS index)</param> /// <param name="idx">Section Index in Virtual Hardware Section (1 = VHS index)</param>
/// <returns>Instance ID of Disk</returns> /// <returns>Instance ID of Disk</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
public static void AddDisk(EnvelopeType ovfEnv, string vsId, string diskId, string lang, string vhdFileName, bool bootable, string name, string description, ulong filesize, ulong capacity) public static void AddDisk(EnvelopeType ovfEnv, string vsId, string diskId, string lang, string vhdFileName, bool bootable, string name, string description, ulong filesize, ulong capacity)
{ {
List<File_Type> files = new List<File_Type>(); List<File_Type> files = new List<File_Type>();
@ -5427,8 +5417,7 @@ namespace XenOvf
{ {
AddContent(systemColl, vsId, Properties.Settings.Default.Language, item); AddContent(systemColl, vsId, Properties.Settings.Default.Language, item);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private static void AddContent(VirtualSystemCollection_Type systemColl, string vsId, string lang, object item) private static void AddContent(VirtualSystemCollection_Type systemColl, string vsId, string lang, object item)
{ {
List<Section_Type> sections = new List<Section_Type>(); List<Section_Type> sections = new List<Section_Type>();

View File

@ -491,8 +491,6 @@ namespace XenOvfTransport
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
internal List<XenRef<VDI>> ImportFile(Session xenSession, string vmname, string pathToOvf, string filename, string compression, string version, string passcode, string sruuid, string description, string vdiuuid) internal List<XenRef<VDI>> ImportFile(Session xenSession, string vmname, string pathToOvf, string filename, string compression, string version, string passcode, string sruuid, string description, string vdiuuid)
{ {
List<XenRef<VDI>> vdiRef = new List<XenRef<VDI>>(); List<XenRef<VDI>> vdiRef = new List<XenRef<VDI>>();
@ -1982,8 +1980,7 @@ namespace XenOvfTransport
} }
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands",
Justification = "Logging mechanism")]
private string VerifyUserDevice(Session xenSession, XenRef<VM> vmRef, string device) private string VerifyUserDevice(Session xenSession, XenRef<VM> vmRef, string device)
{ {
log.DebugFormat("Import.VerifyUserDevice, checking device: {0} (99 = autoselect)", device); log.DebugFormat("Import.VerifyUserDevice, checking device: {0} (99 = autoselect)", device);

View File

@ -35,7 +35,6 @@ using System.IO;
using System.Threading; using System.Threading;
using DiscUtils.Iscsi; using DiscUtils.Iscsi;
using XenAPI; using XenAPI;
using SuppressMessage = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute;
namespace XenOvfTransport namespace XenOvfTransport
@ -89,7 +88,6 @@ namespace XenOvfTransport
} }
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Logging mechanism")]
public DiskStream Connect(XenAPI.Session xenSession, string vdiuuid, bool read_only) public DiskStream Connect(XenAPI.Session xenSession, string vdiuuid, bool read_only)
{ {
StartiScsiTarget(xenSession, vdiuuid, read_only); StartiScsiTarget(xenSession, vdiuuid, read_only);
@ -184,7 +182,6 @@ namespace XenOvfTransport
} }
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Logging mechanism")]
public void Disconnect(XenAPI.Session xenSession) public void Disconnect(XenAPI.Session xenSession)
{ {
try try
@ -212,7 +209,6 @@ namespace XenOvfTransport
StopiScsiTarget(xenSession); StopiScsiTarget(xenSession);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Logging mechanism")]
public void Copy(Stream source, Stream destination, string filename, bool shouldHash) public void Copy(Stream source, Stream destination, string filename, bool shouldHash)
{ {
log.InfoFormat("Started copying {0} bytes to {1} via iSCSI.", source.Length, filename); log.InfoFormat("Started copying {0} bytes to {1} via iSCSI.", source.Length, filename);
@ -295,7 +291,6 @@ namespace XenOvfTransport
log.InfoFormat("Finished copying {0} bytes to {1} via iSCSI.", source.Length, filename); log.InfoFormat("Finished copying {0} bytes to {1} via iSCSI.", source.Length, filename);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Logging mechanism")]
public void Verify(Stream target, string filename) public void Verify(Stream target, string filename)
{ {
log.InfoFormat("Started verifying {0} bytes in {1} after copy via iSCSI.", _bytescopied, filename); log.InfoFormat("Started verifying {0} bytes in {1} after copy via iSCSI.", _bytescopied, filename);
@ -479,7 +474,6 @@ namespace XenOvfTransport
UpdateHandler.Invoke(e); UpdateHandler.Invoke(e);
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Logging mechanism")]
private void StartiScsiTarget(XenAPI.Session xenSession, string vdiuuid, bool read_only) private void StartiScsiTarget(XenAPI.Session xenSession, string vdiuuid, bool read_only)
{ {
try try
@ -510,7 +504,6 @@ namespace XenOvfTransport
} }
} }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Logging mechanism")]
private void StopiScsiTarget(XenAPI.Session xenSession) private void StopiScsiTarget(XenAPI.Session xenSession)
{ {
try try