How can I get the backing Field for a property in a Action Follow
So from the class "Test" (), I can call .GetPropertyDeclarations(). Is there a way from the IPropertyDeclaration to get the IFieldDeclaration for that property (in the example below: "_name" for Property "Name")?
Example class:
public class Test { private string _name; public string Name { get { return _name; } set { _name = value; } } }
Please sign in to leave a comment.
You can use IPropertyBodyHelper.GetBackingField to return you back an IField, and then use GetDeclarations to get any IFieldDeclarations. This will only work for simple properties with backing fields - it's essentially looking for properties that can be converted to auto-properties.