Fxcop

Feb 28 2008 12:50 AM

hi

now im developing a rule using fxcop. i made 5 rules in one perticular .dll package.

My prooblem is whn i checked the rule the warning number line not apear corectly.. which is not work whn i used ProblemCollection check (TypeNode type) method. other methods ProblemCollection check (Member member) thats perfectly working. 

is there any problem in my coding?

and another big problem is if i chk my rule package it also mak one crazy error. which is 

:

Error 15 CA0001 : Rule=Microsoft.Usage#CA2241, Target=VirtusaCodeAnalysisRules.PropertNamingConvention.Check(Microsoft.Cci.TypeNode):Microsoft.FxCop.Sdk.Introspection.ProblemCollection : StartIndex cannot be less than zero.
Parameter name: startIndex VirtusaCodeAnalysisRules

any one can explain why is this error cam or is that wrong to check .dll rule class.?

my Coding :

private MemberList GetNodeOfType(TypeNode type, NodeType nodesOfType)

{

MemberList nodeOfTypeList = new MemberList();

for (int j = 0; j < type.Members.Length; j++)

{

if ((type.Members[j].NodeType == nodesOfType))

{

nodeOfTypeList.Add(type.Members[j]);

}

}

return nodeOfTypeList;

}

public override ProblemCollection Check(TypeNode type)

{

// Get the list of properties on this class.

MemberList ListOfProperties = GetNodeOfType(type, NodeType.Property);

// Get the list of Fields on this class.

MemberList ListOfFields = GetNodeOfType(type, NodeType.Field);

// For all the properties found above

for (int currentPropertyIndex = 0; currentPropertyIndex < ListOfProperties.Length; currentPropertyIndex++)

{

// Iterate on all the fields to see, any of which matches the property name

for (int currentFieldIndex = 0; currentFieldIndex < ListOfFields.Length; currentFieldIndex++)

{

if (string.Compare(ListOfProperties[currentPropertyIndex].Name.Name, ListOfFields[currentFieldIndex].Name.Name, true) == 0)

{

// Whether the field is of Camel case.

//Have a method that confirm whether the case is in camel-case and not having hungarian notation.

if (!(NamingRuleUtilities.IsCamel(ListOfFields[currentFieldIndex].Name.Name)))

{

//if the above gets violated then add a problem

//Problems.Add(new Problem(new Resolution(ListOfFields[currentFieldIndex].Name.Name)));

Problem problem = new Problem(base.GetNamedResolution("Type", new string[] { (ListOfFields[currentFieldIndex].Name.Name) }));

base.Problems.Add(problem);

break;

}

}

}

}

return base.Problems;

 

}

}

}

Regards...