Skip to content

Commit 0b268d6

Browse files
author
Christian Käser
committed
Use DocumentationCulture in PropertySummaryDocumentationAnalyzer
1 parent 0b6cbb3 commit 0b268d6

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace StyleCop.Analyzers.DocumentationRules
55
{
66
using System;
77
using System.Collections.Immutable;
8+
using System.Globalization;
9+
using System.Threading;
810
using Microsoft.CodeAnalysis;
911
using Microsoft.CodeAnalysis.CSharp;
1012
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -29,13 +31,6 @@ internal class PropertySummaryDocumentationAnalyzer : PropertyDocumentationBase
2931
private static readonly LocalizableString SA1623Description = new LocalizableResourceString(nameof(DocumentationResources.SA1623Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));
3032
private static readonly string SA1623HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md";
3133

32-
private static readonly string StartingTextGets = DocumentationResources.StartingTextGets;
33-
private static readonly string StartingTextSets = DocumentationResources.StartingTextSets;
34-
private static readonly string StartingTextGetsOrSets = DocumentationResources.StartingTextGetsOrSets;
35-
private static readonly string StartingTextGetsWhether = DocumentationResources.StartingTextGetsWhether;
36-
private static readonly string StartingTextSetsWhether = DocumentationResources.StartingTextSetsWhether;
37-
private static readonly string StartingTextGetsOrSetsWhether = DocumentationResources.StartingTextGetsOrSetsWhether;
38-
3934
private static readonly LocalizableString SA1624Title = new LocalizableResourceString(nameof(DocumentationResources.SA1624Title), DocumentationResources.ResourceManager, typeof(DocumentationResources));
4035
private static readonly LocalizableString SA1624MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1624MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources));
4136
private static readonly LocalizableString SA1624Description = new LocalizableResourceString(nameof(DocumentationResources.SA1624Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));
@@ -67,14 +62,31 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, XmlN
6762
{
6863
var propertyDeclaration = (PropertyDeclarationSyntax)context.Node;
6964
var propertyType = context.SemanticModel.GetTypeInfo(propertyDeclaration.Type);
65+
var settings = context.Options.GetStyleCopSettings(CancellationToken.None);
66+
var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture);
67+
var resourceManager = DocumentationResources.ResourceManager;
7068

7169
if (propertyType.Type.SpecialType == SpecialType.System_Boolean)
7270
{
73-
AnalyzeSummaryElement(context, syntax, diagnosticLocation, propertyDeclaration, StartingTextGetsWhether, StartingTextSetsWhether, StartingTextGetsOrSetsWhether);
71+
AnalyzeSummaryElement(
72+
context,
73+
syntax,
74+
diagnosticLocation,
75+
propertyDeclaration,
76+
resourceManager.GetString("StartingTextGetsWhether", culture),
77+
resourceManager.GetString("StartingTextSetsWhether", culture),
78+
resourceManager.GetString("StartingTextGetsOrSetsWhether", culture));
7479
}
7580
else
7681
{
77-
AnalyzeSummaryElement(context, syntax, diagnosticLocation, propertyDeclaration, StartingTextGets, StartingTextSets, StartingTextGetsOrSets);
82+
AnalyzeSummaryElement(
83+
context,
84+
syntax,
85+
diagnosticLocation,
86+
propertyDeclaration,
87+
resourceManager.GetString("StartingTextGets", culture),
88+
resourceManager.GetString("StartingTextSets", culture),
89+
resourceManager.GetString("StartingTextGetsOrSets", culture));
7890
}
7991
}
8092

0 commit comments

Comments
 (0)