Poushali

Hi,

I was creating a rule to check the naming convention , but I cannot access the local variable name. My code is like this:

LocalList locals = null;

if (method.Instructions.Length > 0)

{

locals = method.Instructions[0].Value as LocalList;

}

if (locals != null)

{

for (int i=0; i<locals.Length; i++)

{

Local localTest = localsIdea;

if(localTest.Type.Name.ToString().ToLower() == "String" &&

!localTest.Name.Name.ToString().StartsWith("str"))

{

string strMsg = "Variable of type'"+localTest.Type.Name.ToString()+

"' should have str"

" as prefix, but in method "+ RuleUtilities.Format(method)+

", variable " +localTest.Name.Name +" is used";

AddProblem(strMsg);

}

}

}

The localTest.Name.Name value is displayed as local0, local1.... How do I get the name of the local variable,



Re: Visual Studio Code Analysis and Code Metrics FxCop 1.32 Local variable name

Poushali

Well, I got the answer, I missed to place the PDB at the same location where the DLL was present.