I was creating a rule in fxcop to check the naming convention , but I cannot access the local variable name. the field name access only instatc variable.
my code like this.. pls help me how to access local variable name also.
public override ProblemCollection Check(Member member)
{
//if (member == null)
//{
// return base.Problems;
//}
//get field name
Field field = member as Field;
if (field == null)
{
return base.Problems;
}
string name = field.Name.Name;
if (name == null)
{
return base.Problems;
}
}
Loading
AlanPosted Jan 5, 2008, 12:48 PM
It's not possible to do this with a tool such as FxCop because it analyzes the compiled IL code, not the original source code.
When a method is compiled to IL, the names of local variables are discarded and replaced by numbered storage locations. Consequently, there are no readable names in the IL or metadata for FxCop to analyze.
This doesn't apply to fields which is why FxCop can analyze their names.