SA1633: FileMustHaveHeader

StyleCop

TypeName

FileMustHaveHeader

CheckId

SA1633

Category

Documentation Rules

Cause

A C# code file is missing a standard file header.

Rule Description

A violation of this rule occurs when a C# source file is missing a file header. The file header must begin on the first line of the file, and must be formatted as a block of comments containing Xml, as follows:

//-----------------------------------------------------------------------

// <copyright file="NameOfFile.cs" company="CompanyName">

//     Company copyright tag.

// </copyright>

//-----------------------------------------------------------------------

For example, a file called Widget.cs from a fictional company called Sprocket Enterprises should contain a file header similar to the following:

//-----------------------------------------------------------------------

// <copyright file="Widget.cs" company="Sprocket Enterprises">

//     Copyright (c) Sprocket Enterprises. All rights reserved.

// </copyright>

//-----------------------------------------------------------------------

The dashed lines at the top and bottom of the header are not strictly necessary, so the header could be written as:

// <copyright file="Widget.cs" company="Sprocket Enterprises">

//     Copyright (c) Sprocket Enterprises. All rights reserved.

// </copyright>

It is possible to add additional tags, although they will not be checked or enforced by StyleCop:

//-----------------------------------------------------------------------

// <copyright file="Widget.cs" company="Sprocket Enterprises">

//     Copyright (c) Sprocket Enterprises. All rights reserved.

// </copyright>

// <author>John Doe</author>

//-----------------------------------------------------------------------

A file that is completely auto-generated by a tool, and which should not be checked or enforced by StyleCop, can include an “auto-generated” header rather than the standard file header. This will cause StyleCop to ignore the file. This type of header should never be placed on top of a manually written code file.

// <auto-generated />

namespace Sample.Something

{

    // The contents of this file are completely auto-generated by a tool.

}

How to Fix Violations

To fix a violation of this rule, add a standard file header at the top of the file.