Pulizia di vari warnings x IOB

This commit is contained in:
Samuele E. Locatelli
2020-02-21 18:45:15 +01:00
parent e44366df44
commit 785a691219
9 changed files with 102 additions and 43 deletions
+4
View File
@@ -0,0 +1,4 @@
[*.cs]
# CA1051: Non dichiarare campi di istanza visibili
dotnet_diagnostic.CA1051.severity = none
+48
View File
@@ -0,0 +1,48 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.btnMaximixeAll_Click(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.btnMinimizeAll_Click(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.checkIstance(IOB_MAN.iobAdapt,System.Collections.Generic.List{IOB_MAN.iobAdapt},System.Diagnostics.Process[])~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.chiudiChildSel")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.closeAllChild(System.Boolean)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.dgvManagedItems_CellDoubleClick(System.Object,System.Windows.Forms.DataGridViewCellEventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.forceCheckTimer_Tick(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.IOBManPanel.MainTimer_Tick(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.deserializeVal(System.String)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.getRCnt(System.String)~System.Int32")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.getRedisInfoData~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.getRKeys(StackExchange.Redis.RedisKey[])~StackExchange.Redis.RedisValue[]")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.getRSV(System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redCountKey(System.String)~System.Int32")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redDelKey(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redFlushKey(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redGetCounterByKey(System.String,IOB_MAN.RedisIobCache.kvpOrderBy)~System.Collections.Generic.List{System.Collections.Generic.KeyValuePair{System.String,System.Int32}}")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redGetHash(System.String)~System.Collections.Generic.KeyValuePair{System.String,System.String}[]")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redGetHashDict(System.String)~System.Collections.Generic.Dictionary{System.String,System.String}")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redGetHashField(System.String,System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redHash(System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redHashPresent(StackExchange.Redis.RedisKey)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redHashPresentSz(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redKeyPresent(StackExchange.Redis.RedisKey)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redKeyPresentSz(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redSaveHash(System.String,System.Collections.Generic.KeyValuePair{System.String,System.String}[])~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redSaveHash(System.String,System.Collections.Generic.KeyValuePair{System.String,System.String}[],System.Double)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redSaveHashDict(System.String,System.Collections.Generic.Dictionary{System.String,System.String})~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redSaveHashDict(System.String,System.Collections.Generic.Dictionary{System.String,System.String},System.Double)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redSaveHashList(System.String,System.Collections.Generic.List{System.Collections.Generic.KeyValuePair{System.String,System.String}})~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.redServInfo~StackExchange.Redis.IServer[]")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.resetRCnt(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.serializeVal(System.Object)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.setRCntD(System.String)~System.Int64")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.setRCntI(System.String)~System.Int64")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.setRKeys(System.Collections.Generic.KeyValuePair{StackExchange.Redis.RedisKey,StackExchange.Redis.RedisValue}[])~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.setRSV(System.String,System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.RedisIobCache.setRSV(System.String,System.String,System.Int32)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.utils.CRB(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.utils.CRC(System.String)~System.Char")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.utils.CRI(System.String)~System.Int32")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_MAN.utils.CRS(System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_MAN.RedisIobCache.numRecRedis")]
+1
View File
@@ -148,6 +148,7 @@
<Compile Include="..\VersGen\VersGen.cs">
<Link>VersGen.cs</Link>
</Compile>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="iobAdapt.cs" />
<Compile Include="IOBManPanel.cs">
<SubType>Form</SubType>
+4 -8
View File
@@ -28,10 +28,6 @@ namespace IOB_MAN
#endregion
/// <summary>
/// Token x cancellazione thread
/// </summary>
private CancellationTokenSource _cts;
/// <summary>
/// Context x sync thread
/// </summary>
@@ -245,7 +241,7 @@ namespace IOB_MAN
if (!chkAutoRestart.Checked)
{
tOutAutocheck--;
txtTOutAutoCheck.Text = (tOutAutocheck / (1000 / (utils.CRI("checkPeriod")))).ToString();
txtTOutAutoCheck.Text = $"{(tOutAutocheck / (1000 / (utils.CRI("checkPeriod"))))}";
}
}
else
@@ -352,7 +348,7 @@ namespace IOB_MAN
foreach (DataGridViewRow riga in dgvManagedItems.SelectedRows)
{
// chiudo!
int.TryParse(riga.Cells["pID"].Value.ToString(), out pid);
_ = int.TryParse(riga.Cells["pID"].Value.ToString(), out pid);
if (pid >= 0)
{
@@ -380,7 +376,7 @@ namespace IOB_MAN
/// <param name="processlist"></param>
/// <param name="id"></param>
/// <returns></returns>
public Process myGetProcByID(Process[] processlist, int id)
public static Process myGetProcByID(Process[] processlist, int id)
{
return processlist.FirstOrDefault(pr => pr.Id == id);
}
@@ -602,7 +598,7 @@ namespace IOB_MAN
closeAllChild(true);
closeTimers();
}
private void closeTimers()
{
MainTimer.Dispose();
+1 -1
View File
@@ -68,7 +68,7 @@ namespace IOB_MAN
/// <summary>
/// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da funzionalita' DbConfig) + keyName richiesto...
/// </summary>
public string redHash(string keyName)
public static string redHash(string keyName)
{
keyName = keyName.Replace("\\", "_");
string answ = keyName;
+5
View File
@@ -18,6 +18,11 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CVCncLib", "CVCncLib\CVCncL
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IOB-MAN", "IOB-MAN\IOB-MAN.csproj", "{8DFE2AC9-611D-44D5-8E8F-204DCF01EDF8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B52E3E86-1B82-4F4D-982C-0C8909CD2A28}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CMS-FANUC|Any CPU = CMS-FANUC|Any CPU
+9 -9
View File
@@ -265,7 +265,7 @@ namespace IOB_WIN
/// <summary>
/// Verifica se sia in modalità DEMO avanzata (campionamento da set di valori ammessi...)
/// </summary>
public bool DemoInSample
public static bool DemoInSample
{
get
{
@@ -291,7 +291,7 @@ namespace IOB_WIN
/// <summary>
/// Verifica se sia in modalità DEMO x dati OUTPUT
/// </summary>
public bool DemoOut
public static bool DemoOut
{
get
{
@@ -1712,10 +1712,10 @@ namespace IOB_WIN
/// <summary>
/// processa dataLayer e se necessario salva/mostra
/// </summary>
public void checkSavePersDataLayer()
public static void checkSavePersDataLayer()
{
}
public void resetDebugConsole()
public static void resetDebugConsole()
{
}
@@ -2090,7 +2090,7 @@ namespace IOB_WIN
/// <param name="memSize">dimensione singolo slot in byte</param>
/// <param name="BitNum">indirizzo bit: numero riga x calcolo indice bit</param>
/// <returns></returns>
protected otherData decodeBitData(string linea, char separator, int ByteNum, int memSize, int BitNum)
protected static otherData decodeBitData(string linea, char separator, int ByteNum, int memSize, int BitNum)
{
string[] valori = linea.Split(separator);
int shift = 0;
@@ -2158,7 +2158,7 @@ namespace IOB_WIN
/// <summary>
/// Valore del num max invii consecutivi da coda...
/// </summary>
protected int nMaxSend
protected static int nMaxSend
{
get
{
@@ -2668,7 +2668,7 @@ namespace IOB_WIN
/// <summary>
/// Reset dei webclients
/// </summary>
public void resetwebClients()
public static void resetWebClients()
{
utils.resetWebClients();
}
@@ -2804,7 +2804,7 @@ namespace IOB_WIN
// se NON OK riprovo ANCORA 1 volta...
if (!answ)
{
resetwebClients();
resetWebClients();
Thread.Sleep(rand.Next(500, 1000));
callResp = callUrl(urlAlive, false);
answ = (callResp == "OK");
@@ -2901,7 +2901,7 @@ namespace IOB_WIN
// se NON OK riprovo ANCORA 1 volta...
if (!answ)
{
resetwebClients();
resetWebClients();
Thread.Sleep(rand.Next(250, 1000));
callResp = callUrl(urlIobEnabled, false);
answ = (callResp == "OK");
+27 -22
View File
@@ -43,24 +43,29 @@ namespace IOB_WIN
pzCountDelay = utils.CRI("pzCountDelay");
lastPzCountSend = DateTime.Now;
lastWarnODL = DateTime.Now;
// inizializzo correttamente aree memoria secondo CONF - iniFileName
IniFile fIni = new IniFile(IOBConf.iniFileName);
// fix enable prgName
enablePrgName = fIni.ReadBoolean("CNC", "GETPRGNAME", true);
// effettuo lettura della conf sigLUT... cercando 1:1 i bit...
string currBit = "";
string memArea = "";
for (int i = 0; i < 8; i++)
if (IOBConf != null)
{
currBit = string.Format("BIT{0}", i);
memArea = fIni.ReadString("MEMORY", currBit, "");
// se trovo un valore...
if (memArea != "")
// inizializzo correttamente aree memoria secondo CONF - iniFileName
if (!string.IsNullOrEmpty(IOBConf.iniFileName))
{
signLUT.Add(currBit, memArea);
IniFile fIni = new IniFile(IOBConf.iniFileName);
// fix enable prgName
enablePrgName = fIni.ReadBoolean("CNC", "GETPRGNAME", true);
// effettuo lettura della conf sigLUT... cercando 1:1 i bit...
string currBit = "";
string memArea = "";
for (int i = 0; i < 8; i++)
{
currBit = string.Format("BIT{0}", i);
memArea = fIni.ReadString("MEMORY", currBit, "");
// se trovo un valore...
if (!string.IsNullOrEmpty(memArea))
{
signLUT.Add(currBit, memArea);
}
}
}
}
@@ -84,13 +89,13 @@ namespace IOB_WIN
}
parentForm.commPlcActive = false;
if (isVerboseLog)
if (isVerboseLog)
{
lgInfo(string.Format("INIT OSAI_ref da CncLib come {0}", IOBConf.tipoIob));
}
// disconnetto e connetto...
if (isVerboseLog)
if (isVerboseLog)
{
lgInfo("OSAI: tryDisconnect");
}
@@ -124,7 +129,7 @@ namespace IOB_WIN
try
{
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
if (cIobConf.optPar.Count > 0 && getOptPar("PZCOUNT_MODE") != "")
if (cIobConf.optPar.Count > 0 && !string.IsNullOrEmpty(getOptPar("PZCOUNT_MODE")))
{
if (getOptPar("PZCOUNT_MODE").StartsWith("OVAR"))
{
@@ -339,7 +344,7 @@ namespace IOB_WIN
{
currODL = utils.callUrl(urlGetCurrODL);
// solo SE HO un ODL...
if (currODL == "" || currODL == "0")
if (string.IsNullOrEmpty(currODL) || currODL == "0")
{
if (periodicLog)
{
@@ -361,7 +366,7 @@ namespace IOB_WIN
lastWarnODL = DateTime.Now;
}
}
if (currODL != null && currODL != "" && currODL != "0")
if (!string.IsNullOrEmpty(currODL) && currODL != "0")
{
// controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x distanziare invio e ridurre letture
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
@@ -467,7 +472,7 @@ namespace IOB_WIN
try
{
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
if (cIobConf.optPar.Count > 0 && getOptPar("PZCOUNT_MODE") != "")
if (cIobConf.optPar.Count > 0 && !string.IsNullOrEmpty(getOptPar("PZCOUNT_MODE")))
{
string memAddr = getOptPar("PZCOUNT_MODE");
if (memAddr.StartsWith("STD"))
+3 -3
View File
@@ -72,11 +72,11 @@ namespace IOB_WIN
lgInfo("BEGIN reloadAdapterConf");
// inizializzo LUT decodifica
string jsonConf = getOptPar("LUT_CONF");
if (jsonConf != "")
if (!string.IsNullOrEmpty(jsonConf))
{
StreamReader reader = new StreamReader($"DATA/CONF/{jsonConf}");
string jsonData = reader.ReadToEnd();
if (jsonData != "")
if (!string.IsNullOrEmpty(jsonData))
{
try
{
@@ -246,7 +246,7 @@ namespace IOB_WIN
element = driver.FindElement(By.Id(item.val));
cVal = element.Text;
// verifico nome o key...
if (item.name != "")
if (!string.IsNullOrEmpty(item.name))
{
cKey = item.name;
}