Skip to content

Commit cce12c9

Browse files
committed
Merge pull request #1579 from vweijsters/fix-1358
2 parents 9b67feb + 2ee95c2 commit cce12c9

2 files changed

Lines changed: 72 additions & 10 deletions

File tree

documentation/SA1636.md

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,79 @@ The file header at the top of a C# code file does not contain the appropriate co
2121

2222
## Rule description
2323

24-
A violation of this rule occurs when the file header at the top of a C# file does not contain the copyright text that has been specified for the project. To enable this rule, navigate to the StyleCop settings for the project and change to the Company Information tab, as shown below:
24+
A violation of this rule occurs when the file header at the top of a C# file does not contain the copyright text that has been specified for the project.
2525

26-
![](Images/CompanyInformationSettings.JPG)
26+
In order to enable this rule, the `copyrightText` property must have been specified. See the [configuration](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md) section for details on how to set this up.
2727

28-
Check the checkbox at the top of the settings page, and fill in the required copyright text for your company. Click OK to save the settings. With these settings in place, every file within the project must contain the required copyright text within its file header copyright tag, as shown in the example below:
28+
The value of the `xmlHeader` property will influence the behavior of this rule. When the `xmlHeader` property is **true** (the default), StyleCop Analyzers expects file headers to conform to the following standard StyleCop format.
2929

3030
```csharp
31-
//-----------------------------------------------------------------------
32-
// <copyright file="Widget.cs" company="My Company">
33-
// Custom company copyright tag.
31+
// <copyright file="{fileName}" company="{companyName}">
32+
// {copyrightText}
3433
// </copyright>
35-
//-----------------------------------------------------------------------
34+
```
35+
36+
When the `xmlHeader` property is explicitly set to **false**, StyleCop Analyzers expects file headers to conform to the following customizable format.
37+
38+
```csharp
39+
// {copyrightText}
40+
```
41+
42+
With these settings in place, every file within the project must contain the required copyright text in the format described above.
43+
44+
### Comment styles
45+
This rule will accept several comment styles. The examples below give an overview of accepted styles.
46+
47+
Examples with the `xmlHeader` property set to **true**
48+
```csharp
49+
// <copyright file="{fileName}" company="{companyName}">
50+
// {copyrightText}
51+
// </copyright>
52+
```
53+
54+
```csharp
55+
// ----------------------------------------------------------------------
56+
// <copyright file="{fileName}" company="{companyName}">
57+
// {copyrightText}
58+
// </copyright>
59+
// ----------------------------------------------------------------------
60+
```
61+
62+
```csharp
63+
/* <copyright file="{fileName}" company="{companyName}">
64+
* {copyrightText}
65+
* </copyright>
66+
*/
67+
```
68+
69+
```csharp
70+
/*
71+
<copyright file="{fileName}" company="{companyName}">
72+
{copyrightText}
73+
</copyright>
74+
*/
75+
```
76+
77+
Examples with the `xmlHeader` property set to **false**
78+
79+
```csharp
80+
// {copyrightText}
81+
```
82+
83+
```csharp
84+
/* {copyrightText} */
85+
```
86+
87+
```csharp
88+
/*
89+
* {copyrightText}
90+
*/
91+
```
92+
93+
```csharp
94+
/*
95+
{copyrightText}
96+
*/
3697
```
3798

3899
## How to fix violations

documentation/SA1641.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ The file header at the top of a C# code file does not contain the appropriate co
2121

2222
## Rule description
2323

24-
A violation of this rule occurs when the file header at the top of a C# file does not contain the company name text that has been specified for the project. To enable this rule, navigate to the StyleCop settings for the project and change to the Company Information tab, as shown below:
24+
A violation of this rule occurs when the file header at the top of a C# file does not contain the company name text that has been specified for the project.
2525

26-
![](Images/CompanyInformationSettings.JPG)
26+
In order to enable this rule, the `companyName` property must have been specified. In addition to that, the `xmlHeader` property must be either omitted or have a value of **true**.
27+
See the [configuration](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md) section for details on how to set this up.
2728

28-
Check the checkbox at the top of the settings page, and fill in the required company name text for your company. Click OK to save the settings. With these settings in place, every file within the project must contain the required company name text within its file header copyright tag, as shown in the example below:
29+
With these settings in place, every file within the project must contain the required company name text within its file header copyright tag, as shown in the example below:
2930

3031
```csharp
3132
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)