如何解决ReSharper的的"未使用的财产和QUOT;性能上完全的警告显示为/值会员? [英] How to resolve Resharper's "unused property" warning on properties solely for Display/Value Members?

查看:177
本文介绍了如何解决ReSharper的的"未使用的财产和QUOT;性能上完全的警告显示为/值会员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了两个属性名称和ID的对象,我用了一个的BindingList数据源组合框的的DisplayMember和ValueMember。

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.

我最近安装 ReSharper的来评价它。 。ReSharper的是给我的警告,这两个属性是未使用的对象。

I recently installed Resharper to evaluate it. Resharper is giving me warnings on the object that the two properties are unused.

示例代码:

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;
    }
}



我做得不对或ReSharper的无能这个特殊用途

Am I doing something wrong or is Resharper clueless about this particular usage?

推荐答案

这JetBrains公司建议您解决这些问题的方法是用它们的属性(可从ReSharper的? - >选项 - >代码注释)。属性添加到项目/解决方案,然后标记这些属性与UsedImplicitly属性。 ReSharper的现在假设属性通过反射使用或后期绑定或什么的。

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.

这篇关于如何解决ReSharper的的&QUOT;未使用的财产和QUOT;性能上完全的警告显示为/值会员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆