Skip to content
ptittof57 edited this page Aug 15, 2015 · 6 revisions
<title>SA1649: FileHeaderFileNameDocumentationMustMatchTypeName</title> <script src="script/helpstudio.js" type="text/javascript"></script> <script src="script/StandardText.js" type="text/jscript"></script>
<script type="text/jscript">WritePageTop(document.title);</script>

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

{

}

            <P>A generic class should be written as:</P>                
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">//-----------------------------------------------------------------------</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">// &lt;copyright file=&quot;Class1{T}.cs" company="My Company"&gt;</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">//<SPAN style="mso-spacerun: yes"> </SPAN>Custom company copyright tag.</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">// &lt;/copyright&gt;</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">//-----------------------------------------------------------------------</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"> </SPAN><SPAN style="COLOR: blue">public</SPAN>
                <SPAN style="COLOR: blue">class</SPAN> 
                 <SPAN style="COLOR: #2b91af">Class1</SPAN><SPAN style="COLOR: #000000">&lt;T&gt;</SPAN></SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"> </SPAN>{</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none">
                </P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"> </SPAN>}</SPAN></P>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-vertical-align-alt: auto; mso-layout-grid-align: none"><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes"></SPAN></P>
            
            
            <P></P>
            <H2>How to Fix Violations</H2>
            <P>To fix a violation of this rule, add the name of the first type from the file to the file tag.</P>
            <h2>How to Suppress Violations</h2>
            <pre>[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:FileHeaderFileNameDocumentationMustMatchTypeName", Justification = "Reviewed.")]</pre>
        </div></div>
</body>
Clone this wiki locally