File Attribute in File Header/File Name with Enums

Apr 13, 2011 at 2:39 PM

Say I have a class, MyClass, that uses an enum, MyEnum.  Both are defined in the MyClass.cs file.  Per StyleCop, the enum is placed above the class, so we have something like:

//<copyright file="MyClass.cs" company="My Company">
// Copyright (c) My Company.  All rights reserved.
//</copyright>

namespace MyCompany.MyObjects
{
    public enum MyEnum
    {
        //...
    }

    public class MyClass
    {
        //...
        public MyEnum Example {get; set;}
       //...
    }
}

 Clearly the focus of this file is MyClass, and as such it makes sense to me that the filename should be MyClass.cs.  However, when I run StyleCop on this file, I get the error: SA1649: The file attribute in the file header's copyright tag must contain the name of the first type in the file.

So it seems to me that StyleCop wants me to rename the file to MyEnum.cs, and then replace the file attribute value with MyEnum.cs, since MyEnum is the first type in the file.

Does this seems wrong to anyone else?  Or am I misunderstanding what StyleCop wants me to do in this situation?

Coordinator
Apr 13, 2011 at 2:42 PM

Ah sorry. I'd missed that. I'll make the rule check for the first non-enum, delegate etc. type name.

Coordinator
Apr 13, 2011 at 2:42 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Apr 13, 2011 at 5:23 PM

fixed in 4.5.11.0