Hi, 

I am reading a ldloc instruction and trying to retrieve the name (or index) 
of the referenced variable: 

var ldlocInstruction = body.Instructions.FirstOrDefault(i => i.OpCode == 
OpCodes.LdLoc); 
var ldlocVariable = body.Variables.Single(v => v.Name == 
ldlocInstruction.Operand.ToString()); 

In most cases, it works fine. However some methods (typically the ones that 
show the variable name as V_0, V_1, etc) will return an empty string ("") 
for v.Name. The weird thing though, is that v.ToString() will correctly 
give me V_0, V_1! 

As it stands now, my issue is fixed when using .ToString() on the 
VariableDefinition instead of looking up the .Name(). I am posting here in 
case this is a bug in Cecil. 

Something else that I found weird, is that the method is shown as 
"specialname" in ILSpy, but the MethodDefinition from Cecil has 
.IsSpecialName set to false. 

My target assembly was compiled using Microsoft .NET and not mono, in case 
it changes anything. 

Thanks! 

Joe

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to