JYe*_*ton 13 c# resharper visual-studio
我为一个对象定义了两个属性"Name"和"ID",我将其用于具有BindingList数据源的ComboBox的DisplayMember和ValueMember.
我最近安装了Resharper来评估它.Resharper正在向我发出关于两个属性未使用的对象的警告.
示例代码:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么或者Resharper对这种特殊用法一无所知?
Dav*_*ams 17
JetBrains建议你解决这些问题的方式是它们的属性(可从Resharper - > Options - > Code Annotations获得).将属性添加到项目/解决方案,然后使用UsedImplicitly属性标记这些属性.Resharper现在假设通过Reflection或后期绑定或其他任何方式使用属性.
| 归档时间: |
|
| 查看次数: |
5954 次 |
| 最近记录: |