I have these enums:

    private enum FontSizeType
    {
        XSmall, //9
        Small,  //12 
        Medium, //18
        Large,  //24
        XLarge, //36
        XXLarge //47
    }

    private enum AlignOptions
    {
        Left,
        Center,
        Right
    }

    private enum ValueType
    {
        Text,
        Barcode
    }

And Resharper's inspection tells me about all of them that "Enum member 'XSmall' [etc.] is never used"

Yet I am using them in my combo boxes, like so:

   comboBoxType1.DataSource = Enum.GetNames(typeof(ValueType));

...so why is Resharper fooled? Or is it?

有帮助吗?

解决方案

ReSharper doesn't detect implicit usages. You can use [UsedImplicitly] to tell it that your type member is used implicitly, and then it should stop complaining.

In order to use UsedImplicitlyAttribute in your code, you should either include reference to JetBrains.Annotations.dll or include some copy-pasted source code in your project, see http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Annotations_in_Source_Code.html for details.

You should add [UsedImplicitly] on each enum value.

其他提示

You can as well disable the complaints itself by using this directive: [SuppressMessage("ReSharper", "UnusedMember.Global")] public enum ComplianceStatus { Notcompliant, Unknown, Warning, Compliant, Pendingrestart, Pendinglogoff }

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top