I am developing a WindowsForms application, using the PropertyGrid and new .NET Framework 4.6. My custom control has the PrepareReadOnlyBrowsableProperty method to modify 'Readonly' and 'Browsable' atrributes of its properties:
protected void PrepareReadOnlyBrowsableProperty(string propertyName,
bool readOnly, bool browsable)
{
PropertyDescriptor descr = TypeDescriptor.GetProperties(this.GetType())[propertyName];
var attr = (ReadOnlyAttribute)descr.Attributes[typeof(ReadOnlyAttribute)];
FieldInfo field = attr.GetType().GetField("isReadOnly",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
field.SetValue(attr, readOnly);
var attr3 = (BrowsableAttribute)descr.Attributes[typeof(BrowsableAttribute)];
FieldInfo field3 = attr3.GetType().GetField("browsable",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
field3.SetValue(attr3, browsable);
}
The problem is the following. When I try to debug by steps (
operands instructions) the above-mentioned method, the debugger stops at the first line, and then jumps to the line “var attr3 = ...”. Why does it happen (several
operands instructions are skipped)?
In the Build page of my application, the configuration is set as “Active (Debug)”, the checkbox "Define DEBUG constant" is checked, the checkbox "Define TRACE constant" is checked, and the checkbox 'Optimize code' is UNCHECKED (turned off).
Thank you in advance.