Skip to content

Commit 1b4f061

Browse files
committed
Update after review
1 parent cd41cc2 commit 1b4f061

5 files changed

Lines changed: 26 additions & 25 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1629UnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ public async Task TestConfigurationSettingsAsync()
767767
{
768768
""settings"": {
769769
""documentationRules"": {
770-
""excludedFromEndWithAPeriod"": ""typeparam,example, exception ,permission,author""
770+
""excludeFromPunctuationCheck"": [ ""typeparam"",""example"",""exception"",""permission"",""author"" ]
771771
}
772772
}
773773
}
@@ -817,7 +817,7 @@ public async Task TestConfigurationSettingsEmptyAsync()
817817
{
818818
""settings"": {
819819
""documentationRules"": {
820-
""excludedFromEndWithAPeriod"": """"
820+
""excludeFromPunctuationCheck"": [ ]
821821
}
822822
}
823823
}

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1629DocumentationTextMustEndWithAPeriod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co
105105
private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext context, StyleCopSettings settings, XmlElementSyntax xmlElement, bool startingWithFinalParagraph)
106106
{
107107
var startTag = xmlElement.StartTag?.Name?.LocalName.ValueText;
108-
if (settings.DocumentationRules.ExcludedFromEndWithAPeriod.Contains(startTag))
108+
if (settings.DocumentationRules.ExcludeFromPunctuationCheck.Contains(startTag))
109109
{
110110
return;
111111
}

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ internal class DocumentationSettings
2828
internal const string DefaultDocumentationCulture = "en-US";
2929

3030
/// <summary>
31-
/// The default value for the <see cref="ExcludedFromEndWithAPeriod"/> property.
31+
/// The default value for the <see cref="ExcludeFromPunctuationCheck"/> property.
3232
/// </summary>
33-
internal const string DefaultExcludedFromEndWithAPeriod = "seealso";
33+
internal static readonly ImmutableArray<string> DefaultExcludeFromPunctuationCheck = ImmutableArray.Create("seealso");
3434

3535
/// <summary>
3636
/// This is the backing field for the <see cref="CompanyName"/> property.
@@ -93,9 +93,9 @@ internal class DocumentationSettings
9393
private readonly string documentationCulture;
9494

9595
/// <summary>
96-
/// This is the backing field for the <see cref="ExcludedFromEndWithAPeriod"/> property.
96+
/// This is the backing field for the <see cref="ExcludeFromPunctuationCheck"/> property.
9797
/// </summary>
98-
private readonly string excludedFromEndWithAPeriod;
98+
private readonly ImmutableArray<string> excludeFromPunctuationCheck;
9999

100100
/// <summary>
101101
/// This is the cache for the <see cref="GetCopyrightText(string)"/> method.
@@ -123,7 +123,7 @@ protected internal DocumentationSettings()
123123

124124
this.documentationCulture = DefaultDocumentationCulture;
125125

126-
this.excludedFromEndWithAPeriod = DefaultExcludedFromEndWithAPeriod;
126+
this.excludeFromPunctuationCheck = DefaultExcludeFromPunctuationCheck;
127127
}
128128

129129
/// <summary>
@@ -198,8 +198,15 @@ protected internal DocumentationSettings(JsonObject documentationSettingsObject)
198198
this.documentationCulture = kvp.ToStringValue();
199199
break;
200200

201-
case "excludedFromEndWithAPeriod":
202-
this.excludedFromEndWithAPeriod = kvp.ToStringValue();
201+
case "excludeFromPunctuationCheck":
202+
kvp.AssertIsArray();
203+
var excludedTags = ImmutableArray.CreateBuilder<string>();
204+
foreach (var value in kvp.Value.AsJsonArray)
205+
{
206+
excludedTags.Add(value.AsString);
207+
}
208+
209+
this.excludeFromPunctuationCheck = excludedTags.ToImmutable();
203210
break;
204211

205212
default:
@@ -261,16 +268,8 @@ public bool XmlHeader
261268
public string DocumentationCulture =>
262269
this.documentationCulture;
263270

264-
public ImmutableArray<string> ExcludedFromEndWithAPeriod
265-
{
266-
get
267-
{
268-
return this.excludedFromEndWithAPeriod
269-
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
270-
.Select(s => s.Trim())
271-
.ToImmutableArray();
272-
}
273-
}
271+
public ImmutableArray<string> ExcludeFromPunctuationCheck
272+
=> this.excludeFromPunctuationCheck;
274273

275274
public string GetCopyrightText(string fileName)
276275
{

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,12 @@
248248
"description": "The culture that should be used for documentation comments.",
249249
"default": "en-US"
250250
},
251-
"excludedFromEndWithAPeriod": {
252-
"type": "string",
253-
"description": "Specifies the comma separated list of top-level tags within XML documentation that will be excluded from analysis for text ending with a period.",
254-
"default": "seealso"
251+
"excludeFromPunctuationCheck": {
252+
"type": "array",
253+
"description": "Specifies the top-level tags within XML documentation that will be excluded from punctuation analysis.",
254+
"default": [
255+
"seealso"
256+
]
255257
}
256258
}
257259
}

documentation/Configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ The [SA1629 Documentation Text Must End With A Period](SA1629.md) analyzer check
596596

597597
| Property | Default Value | Minimum Version | Summary |
598598
| --- | --- | --- | --- |
599-
| `excludedFromEndWithAPeriod` | `"seealso"` | 1.1.0 | Specifies the comma separated list of top-level tags within XML documentation that will be excluded from analysis. |
599+
| `excludeFromPunctuationCheck` | `[ "seealso" ]` | 1.1.0 | Specifies the top-level tags within XML documentation that will be excluded from analysis. |
600600

601601
## Sharing configuration among solutions
602602

0 commit comments

Comments
 (0)