On my job I work with a v2.0 project.
I need know which is the private field that is related to each property
class Foo {
private string _bar;
public string BigBar
{
get { return _bar; }
}}
Someone know how can I check this relation with reflection
If you’re looking for backing fields of auto-like-properties, then the only way is to look at the generated IL, with a tool like Mono.Cecil, for example.
You’ll have to look for a specific IL pattern, and also have to check if the backing field is only used in the property, and nowhere else.
The pattern would be the generated IL for this chunk of code:
(
getandsetare optional, but at least one must be present)