سؤال

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