I have the following code:
public interface IMyInterface
{
DataGrid ItemsInGrid { get; set; }
}
partial public class MyClass: Window, IMyInterface
{
public DataGrid ItemsInGrid
{
get { return grdItemsInGrid}
set { grdItemsInGrid= value; }
}
}
In a Different file:
partial public class MyClass: Window
{
private System.Windows.Forms.DataGrid grdItemsInGrid;
// Reference to private variable here
// This is the designer portion that actually sets up the
// private variable to be shown on the form.
}
Now resharper wants me to convert ItemsInGrid to an autoproperty (public DataGrid ItemsInGrid{ get; set; })
How can this be an equal transformation? An autoproperty would create a hidden backing variable that would not match up to the private grdItemsInGrid right?
Is resharper broken? or is there something in C#.NET that I am not aware of?
EDIT:
I am sensing a common miss-communication here. grdItemsInGrid is a grid that is displayed on a form (MyClass actually implements Window). The idea is to grant access to grdItemsInGrid to scenarios where MyClass is passed as an IMyInterface to a method.
As far as I can see this is a bug in resharper. The private variable in question is a element on a form. I did not show this because I did not realize it was relevant. Because the form stuff is in a different file (it is a partial class). Resharper does not realize that the private variable is being referenced and thinks I can just go to an auto property.
Once I referenced the private variable in the same file then ReSharper stopped hinting that I should convert to an auto property. (But it did not realize that it was referenced in the partial class for purposes of this refactor.)