CA1000:DoNotDeclareStaticMembersOnGenericTypes for public constant

Locked CA1000:DoNotDeclareStaticMembersOnGenericTypes for public constant

  • Wednesday, April 25, 2012 3:37 AM
     
     

    Hi,

    I've got the warning CA1000:DoNotDeclareStaticMembersOnGenericTypes for a code something like as follows.

     public abstract class ClassName<T> : IinterfaceName<T>
        {

            ...

            public const string GetBodyMethodName = "GetBody";  // CA1000: rule violation

            ...

    }

    Is this possible? Because this warning is for calling static members on generic types. Here it gives for declaring public constant variable in generic type class.

All Replies

  • Friday, April 27, 2012 4:47 AM
    Moderator
     
     

    Hi watzr,

    Thank you for posting in the MSDN forum.

    Based on your description, it is related to your code. We know that it will generate this issue when an externally visible generic type contains a static member here. But it seems that it is not the whole code in your project.

    Would you mind sharing this project to us? Please also attach your Visual Studio project, you can upload it to the sky driver, and then share the download link in your post. We will try to check it.

    If there's any concern, please feel free to let me know.

    Sincerely,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us