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?
The way that JetBrains suggests that you solve these issues is with their attributes (available from ReSharper -> Options -> Code Annotations). Add the attributes to your project/solution and then mark these properties with the UsedImplicitly attribute. ReSharper will now assume that the properties are used via Reflection or late bound or whatever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With