Skip to content

Commit cc191fe

Browse files
committed
documentation for header decoration
1 parent f471f87 commit cc191fe

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@
194194
"description": "Determines whether the file header should be wrapped in the StyleCop-standard XML structure.",
195195
"default": true
196196
},
197+
"headerDecoration": {
198+
"type": "boolean",
199+
"description": "The text used as decoration for the copyright header comment.",
200+
"default": null
201+
}
197202
"fileNamingConvention": {
198203
"type": "string",
199204
"description": "Specifies the preferred naming convention for files. The default value \"stylecop\" uses the naming convention defined by StyleCop Classic, while \"metadata\" uses a file naming convention that matches the metadata names of types.",

documentation/Configuration.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ The following properties are used to configure copyright headers in StyleCop Ana
324324
| `copyrightText` | `"Copyright (c) {companyName}. All rights reserved."` | Specifies the default copyright text which should appear in copyright headers |
325325
| `xmlHeader` | **true** | Specifies whether file headers should use standard StyleCop XML format, where the copyright notice is wrapped in a `<copyright>` element |
326326
| `variables` | n/a | Specifies replacement variables which can be referenced in the `copyrightText` value |
327+
| `headerDecoration` | n/a | This value can be set to add a decoration for the header comment so that the headers look similar to the ones generated by the StyleCop classic R# fix |
327328

328329
#### Configuring Copyright Text
329330

@@ -373,6 +374,35 @@ When the `xmlHeader` property is explicitly set to **false**, StyleCop Analyzers
373374
// {copyrightText}
374375
```
375376

377+
#### Configuring Copyright Text Header Decoration
378+
379+
The `headerDecoration` property is a string which can contain a string that's used for decorating the generated header so that the headers look similar to the ones generated by the StyleCop classic R# fix.
380+
381+
The default value for the `headerDecoration` property is empty, so no decoration will be added.
382+
> The header decoration is not checked, it's only used for fixing the header.
383+
384+
```json
385+
{
386+
"settings": {
387+
"documentationRules": {
388+
"companyName": "FooCorp",
389+
"copyrightText": "Copyright (c) {companyName}. All rights reserved.",
390+
"headerDecoration": "-----------------------------------------------------------------------"
391+
}
392+
}
393+
}
394+
```
395+
396+
With the above configuration, the fix for a file **TypeName.cs** would look like the following header.
397+
398+
```csharp
399+
// -----------------------------------------------------------------------
400+
// <copyright file="TypeName.cs" company="FooCorp">
401+
// Copyright (c) FooCorp. All rights reserved.
402+
// </copyright>
403+
// -----------------------------------------------------------------------
404+
```
405+
376406
### Documentation Requirements
377407

378408
StyleCop Analyzers includes rules which require developers to document the majority of a code base by default. This requirement can easily overwhelm a team which did not use StyleCop for the entire development process. To help guide developers towards a properly documented code base, several properties are available in **stylecop.json** to progressively increase the documentation requirements.

0 commit comments

Comments
 (0)