Skip to content

Commit 8880025

Browse files
committed
add file header decoration comments if configured
1 parent d6344b6 commit 8880025

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,20 @@ private static string WrapInXmlComment(string prefixWithLeadingSpaces, string co
365365
string encodedCompanyName = new XAttribute("t", settings.DocumentationRules.CompanyName).ToString().Substring(2).Trim('"');
366366
string encodedCopyrightText = new XText(copyrightText).ToString();
367367

368-
return
368+
string copyrightString =
369369
$"{prefixWithLeadingSpaces} <copyright file=\"{encodedFilename}\" company=\"{encodedCompanyName}\">" + newLineText
370370
+ encodedCopyrightText + newLineText
371371
+ prefixWithLeadingSpaces + " </copyright>";
372+
373+
if (!string.IsNullOrEmpty(settings.DocumentationRules.HeaderDecoration))
374+
{
375+
return
376+
$"{prefixWithLeadingSpaces} {settings.DocumentationRules.HeaderDecoration}" + newLineText
377+
+ copyrightString + newLineText
378+
+ $"{prefixWithLeadingSpaces} {settings.DocumentationRules.HeaderDecoration}";
379+
}
380+
381+
return copyrightString;
372382
}
373383

374384
private static string GetCopyrightText(string prefixWithLeadingSpaces, string copyrightText, string newLineText)

StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/DocumentationSettings.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ internal class DocumentationSettings
3232
[JsonProperty("copyrightText", DefaultValueHandling = DefaultValueHandling.Ignore)]
3333
private string copyrightText;
3434

35+
/// <summary>
36+
/// This is the backing field for the <see cref="CompanyName"/> property.
37+
/// </summary>
38+
[JsonProperty("headerDecoration", DefaultValueHandling = DefaultValueHandling.Ignore)]
39+
private string headerDecoration;
40+
3541
/// <summary>
3642
/// This is the cache for the <see cref="CopyrightText"/> property.
3743
/// </summary>
@@ -94,6 +100,7 @@ protected internal DocumentationSettings()
94100
this.companyName = DefaultCompanyName;
95101
this.copyrightText = DefaultCopyrightText;
96102
this.variables = ImmutableDictionary<string, string>.Empty.ToBuilder();
103+
this.headerDecoration = null;
97104
this.xmlHeader = true;
98105

99106
this.documentExposedElements = true;
@@ -126,6 +133,14 @@ public string CopyrightText
126133
}
127134
}
128135

136+
public string HeaderDecoration
137+
{
138+
get
139+
{
140+
return this.headerDecoration;
141+
}
142+
}
143+
129144
public ImmutableDictionary<string, string> Variables
130145
{
131146
get

0 commit comments

Comments
 (0)