Upon further investigation, I notice that the OnAdd method in the
VariableDefinitionCollection tries to fix up the index field.

Therefore the reason I’m getting the wrong variable index in the
output is because I’m using the same VariableDefinition instance in
several collections. I admit this is unusual, and I can fix my code to
make copies of the instances instead, but I think it would still make
sense to fix this bug because it potentially outputs broken assemblies
for a very hard-to-debug reason. Would it be desirable to compute the
indexes at the time the method body is written, and not store them in
the VariableDefinition instance itself?

-- 
--
mono-cecil

Reply via email to