How to resolve Resharper's "unused property" warning on properties solely for Display/Value Members?
        Posted  
        
            by JYelton
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by JYelton
        
        
        
        Published on 2010-06-17T17:03:37Z
        Indexed on 
            2010/06/17
            17:13 UTC
        
        
        Read the original article
        Hit count: 324
        
I have defined two properties "Name" and "ID" for an object which I use for the DisplayMember and ValueMember of a ComboBox with a BindingList datasource.
I recently installed Resharper to evaluate it. Resharper is giving me warnings on the object that the two properties are unused.
Sample code:
BindingList<ClassSample> SampleList = new BindingList<ClassSample>();
// populate SampleList
cmbSampleSelector.DisplayMember = "Name";
cmdSampleSelector.ValueMember = "ID";
cmbSampleSelector.DataSource = SampleList;
private class ClassSample
{
    private string _name;
    private string _id;
    public string Name // Resharper believes this property is unused
    {
        get { return _name; }
    }
    public string ID // Resharper believes this property is unused
    {
        get {return _id; }
    }
    public ClassSample(string Name, string ID)
    {
        _name = Name;
        _id = ID;
    }
}
Am I doing something wrong or is Resharper clueless about this particular usage?
© Stack Overflow or respective owner