我已经写了醒目空的catch块,使用fxcop.But扔。我声明要编写一个规则,它抛出一个警告消息,空的catch块捕获块。规则
任何帮助将apprecited。
| bsb25public override ProblemCollection Check(Member member)
{
Method method = member as Method;
bool isCatchExists = false;
bool isThrowExists = false;
Instruction objInstr = null;
if (method != null)
{
InstructionList iList = method.Instructions;
for (int i = 0; i < iList.Length; i++)
{
if (iList[i].OpCode == OpCode._Catch)
{
isCatchExists = true;
}
if (isCatchExists)
{
}
if (isCatchExists)
{
//If the call is not made to HandleError method.
if (!isThrowExists)
{
Resolution resolu = GetResolution(new string[] { method.ToString() });
Problems.Add(new Problem(resolu));
}
}
}
}
return Problems;
}
}