I want to verify if the access to a ViewState has been verified before it is not null.
Is this method correct :
private bool IsWellMetodo(Method metodo)
.OpCode == OpCode.Callvirt)
{
bool valido = true; // Se recuperan todos las instrucciones del metodoInstructionList metodoInstrucciones = metodo.Instructions;
ArrayList listParamAcceso =
new ArrayList(); string val; bool encontrado; for (int i=0; i < metodoInstrucciones.Length; i++){
if(metodoInstrucciones{
// Ver si el metodo llamado es del tipo deseadoMethod calledMethod = metodoInstrucciones
.Value
{
//System.Web.SessionState.HttpSessionState if(calledMethod.FullName.StartsWith("System.Web.UI.StateBag.get_Item")){
val = metodoInstrucciones[i-1].Value.ToString();
if (metodoInstrucciones[i+1].OpCode == OpCode.Brtrue_S || metodoInstrucciones[i+1].OpCode == OpCode.Brfalse_S){
listParamAcceso.Add(val);
}
else{
encontrado =
false; for (int i2=0; i2 < listParamAcceso.Count; i2++){
if (val == listParamAcceso[i2].ToString()){
encontrado =
true; break;}
}
if (encontrado == false){
valido =
false; break;}
}
}
}
}
}
return valido;}

I want to verify if the access to a ViewState ...
dsaniket
Unfortunately, the problem that you are trying to solve is very difficult and requires sophisticated data flow analysis to implement correctly. It is basically impossible to walk the instructions as a flat list in one pass and get it right. The code above basically targets specific code generation for specific high-level constructs, but won't work in the general case. That might be ok for you if it finds most of the bugs that you're looking for and you can tolerate the noise.
We are working on providing extensible data flow analysis for these sorts of problems in a future release, but we can't really help you do a better job with the current FxCop bits.
Nick