I am currently using Mono Cecil to extract data from C# projects. Now I need to check whether a field is read or written to in each method.
How can tell from the CIL instruction that a field is being read or written to?
Because I doubt there a library in Mono Cecil similar to Assignment in Eclipse’s JDT that allows me to extract the left hand side and right hand side. If there is, then I can just work from there.
The instruction for direct field stores is
stfld, so you’ll have to look out for that.Note that fields can also be indirectly written to via pointers (both
*and&kind), which is impossible to detect in the most general case (as pointer can come from the outside).