SA1649: FileHeaderFileNameDocumentationMustMatchTypeName

StyleCop

TypeName

FileHeaderFileNameDocumentationMustMatchTypeName

CheckId

SA1649

Category

Documentation Rules

Cause

The file tag within the file header at the top of a C# code file does not match the first type declared in the file. For generics that are defined as Class1<T> the name of the file needs to be Class1{T}.cs and this should appear in the header also. Partial classes are ignored.

Rule Description

A violation of this rule occurs when the file tag within the file header at the top of a C# file does not contain the name of the first type in the file. For example, consider a C# source file named Class1.cs, with the following header:

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

// <copyright file="ThisIsNotTheCorrectTypeName.cs" company="My Company">

//     Custom company copyright tag.

// </copyright>

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

    public class Class1

    {

    }

 

A violation of this rule would occur, since the file tag does not contain the correct name of the first type in the file. The header should be written as:

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

// <copyright file="Class1.cs" company="My Company">

//     Custom company copyright tag.

// </copyright>

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

    public class Class1

    {

    }

 

 

A generic class should be written as:

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

// <copyright file="Class1{T}.cs" company="My Company">

//     Custom company copyright tag.

// </copyright>

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

    public class Class1<T>

    {

    }

 

How to Fix Violations

To fix a violation of this rule, add the name of the first type from the file to the file tag.