{
Method method = member as Method; bool problem = false; if (method != null)
{
//引数のMemberを定義しているクラスが、分析対象かどうか判定します。
InstructionList instructions = method.Instructions;
if (instructions.Length == 0)
return null;
//メンッド内で定義されたローカル変数のリスト取得
LocalList localList = instructions[0].Value as LocalList;
if (localList == null)
return null; Local localTemp; string strName = String.Empty;
string strType = String.Empty; for (int index = 0, length = localList.Length; index < length; index++)
{
localTemp = localList[index];
strName = localTemp.Name.Name;
strType = localTemp.Type.FullName.ToString();
//“$”のを含むのは系統的な変数です。
if (!((strName.IndexOf('$') > -1) || (strName.IndexOf("local") > -1)))
{
if (strType.Equals(strTypeName))
{
problem = (strName.Length < 3 || !strName.Substring(0, 3).Equals(strPrefix));
}
if (problem)
{
Problems.Add(new Problem(GetResolution(strName)));
}
}
problem = false;
}
}
return Problems;
上面是我的代码,效验字符串前缀的正确性。
问题是:当某一个方法体内,多个变量定义错误时。这些错误提示的行号始终是第一个错误变量所在的行。例如:
方法A
{
String aaa;
string bbb;
}aaa的行号是3,bbb的行号是4。当编译后提示的信息是:
aaa的行号是 3
bbb的行号是 3都是3,请问这是怎么回事?如何解决呢?
我感觉是 Problems.Add(new Problem(GetResolution(strName)));有问题,但不知道如何解决。我用的fxcop1.32
Method method = member as Method; bool problem = false; if (method != null)
{
//引数のMemberを定義しているクラスが、分析対象かどうか判定します。
InstructionList instructions = method.Instructions;
if (instructions.Length == 0)
return null;
//メンッド内で定義されたローカル変数のリスト取得
LocalList localList = instructions[0].Value as LocalList;
if (localList == null)
return null; Local localTemp; string strName = String.Empty;
string strType = String.Empty; for (int index = 0, length = localList.Length; index < length; index++)
{
localTemp = localList[index];
strName = localTemp.Name.Name;
strType = localTemp.Type.FullName.ToString();
//“$”のを含むのは系統的な変数です。
if (!((strName.IndexOf('$') > -1) || (strName.IndexOf("local") > -1)))
{
if (strType.Equals(strTypeName))
{
problem = (strName.Length < 3 || !strName.Substring(0, 3).Equals(strPrefix));
}
if (problem)
{
Problems.Add(new Problem(GetResolution(strName)));
}
}
problem = false;
}
}
return Problems;
上面是我的代码,效验字符串前缀的正确性。
问题是:当某一个方法体内,多个变量定义错误时。这些错误提示的行号始终是第一个错误变量所在的行。例如:
方法A
{
String aaa;
string bbb;
}aaa的行号是3,bbb的行号是4。当编译后提示的信息是:
aaa的行号是 3
bbb的行号是 3都是3,请问这是怎么回事?如何解决呢?
我感觉是 Problems.Add(new Problem(GetResolution(strName)));有问题,但不知道如何解决。我用的fxcop1.32
没有人会吗?