Skip to content

Commit 5142c0e

Browse files
author
Christian Käser
committed
Support languages with different sentence structure
In some languages like Spanish the "type kind" must be inserted before the reference to the class/structure name.
1 parent b6415a2 commit 5142c0e

3 files changed

Lines changed: 40 additions & 38 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
103103
if (declarationSyntax.Modifiers.Any(SyntaxKind.StaticKeyword))
104104
{
105105
standardText = ImmutableArray.Create(
106-
resourceManager.GetString("StaticConstructorStandardTextFirstPart", culture),
106+
string.Format(resourceManager.GetString("StaticConstructorStandardTextFirstPart", culture), typeKindText),
107107
string.Format(resourceManager.GetString("StaticConstructorStandardTextSecondPart", culture), typeKindText));
108108
}
109109
else
@@ -112,7 +112,7 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
112112
// acceptable for private constructors by the diagnostic.
113113
// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/413
114114
standardText = ImmutableArray.Create(
115-
resourceManager.GetString("NonPrivateConstructorStandardTextFirstPart", culture),
115+
string.Format(resourceManager.GetString("NonPrivateConstructorStandardTextFirstPart", culture), typeKindText),
116116
string.Format(resourceManager.GetString("NonPrivateConstructorStandardTextSecondPart", culture), typeKindText));
117117
}
118118
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task TestNonPrivateConstructorCorrectDocumentationSimpleAsync(strin
6969
await this.TestConstructorCorrectDocumentationSimpleAsync(
7070
typeKind,
7171
"public",
72-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
72+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
7373
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
7474
false).ConfigureAwait(false);
7575
}
@@ -82,7 +82,7 @@ public async Task TestNonPrivateConstructorCorrectDocumentationCustomizedAsync(s
8282
await this.TestConstructorCorrectDocumentationCustomizedAsync(
8383
typeKind,
8484
"public",
85-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
85+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
8686
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
8787
false).ConfigureAwait(false);
8888
}
@@ -95,7 +95,7 @@ public async Task TestNonPrivateConstructorCorrectDocumentationGenericSimpleAsyn
9595
await this.TestConstructorCorrectDocumentationSimpleAsync(
9696
typeKind,
9797
"public",
98-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
98+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
9999
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
100100
true).ConfigureAwait(false);
101101
}
@@ -108,7 +108,7 @@ public async Task TestNonPrivateConstructorCorrectDocumentationGenericCustomized
108108
await this.TestConstructorCorrectDocumentationCustomizedAsync(
109109
typeKind,
110110
"public",
111-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
111+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
112112
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
113113
true).ConfigureAwait(false);
114114
}
@@ -121,7 +121,7 @@ public async Task TestPrivateConstructorCorrectDocumentationAsync(string typeKin
121121
await this.TestConstructorCorrectDocumentationAsync(
122122
typeKind,
123123
"private",
124-
DocumentationResources.PrivateConstructorStandardTextFirstPart,
124+
string.Format(DocumentationResources.PrivateConstructorStandardTextFirstPart, typeKind),
125125
string.Format(DocumentationResources.PrivateConstructorStandardTextSecondPart, typeKind),
126126
string.Empty,
127127
false).ConfigureAwait(false);
@@ -135,7 +135,7 @@ public async Task TestPrivateConstructorCorrectExtendedDocumentationAsync(string
135135
await this.TestConstructorCorrectDocumentationAsync(
136136
typeKind,
137137
"private",
138-
DocumentationResources.PrivateConstructorStandardTextFirstPart,
138+
string.Format(DocumentationResources.PrivateConstructorStandardTextFirstPart, typeKind),
139139
string.Format(DocumentationResources.PrivateConstructorStandardTextSecondPart, typeKind) + " externally",
140140
string.Empty,
141141
false).ConfigureAwait(false);
@@ -149,7 +149,7 @@ public async Task TestPrivateConstructorCorrectDocumentation_NonPrivateSimpleAsy
149149
await this.TestConstructorCorrectDocumentationSimpleAsync(
150150
typeKind,
151151
"private",
152-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
152+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
153153
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
154154
false).ConfigureAwait(false);
155155
}
@@ -162,7 +162,7 @@ public async Task TestPrivateConstructorCorrectDocumentation_NonPrivateCustomize
162162
await this.TestConstructorCorrectDocumentationCustomizedAsync(
163163
typeKind,
164164
"private",
165-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
165+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
166166
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
167167
false).ConfigureAwait(false);
168168
}
@@ -175,7 +175,7 @@ public async Task TestPrivateConstructorCorrectDocumentationGenericAsync(string
175175
await this.TestConstructorCorrectDocumentationAsync(
176176
typeKind,
177177
"private",
178-
DocumentationResources.PrivateConstructorStandardTextFirstPart,
178+
string.Format(DocumentationResources.PrivateConstructorStandardTextFirstPart, typeKind),
179179
string.Format(DocumentationResources.PrivateConstructorStandardTextSecondPart, typeKind),
180180
string.Empty,
181181
true).ConfigureAwait(false);
@@ -189,7 +189,7 @@ public async Task TestPrivateConstructorCorrectExtendedDocumentationGenericAsync
189189
await this.TestConstructorCorrectDocumentationAsync(
190190
typeKind,
191191
"private",
192-
DocumentationResources.PrivateConstructorStandardTextFirstPart,
192+
string.Format(DocumentationResources.PrivateConstructorStandardTextFirstPart, typeKind),
193193
string.Format(DocumentationResources.PrivateConstructorStandardTextSecondPart, typeKind) + " externally",
194194
string.Empty,
195195
true).ConfigureAwait(false);
@@ -203,7 +203,7 @@ public async Task TestPrivateConstructorCorrectDocumentationGeneric_NonPrivateSi
203203
await this.TestConstructorCorrectDocumentationSimpleAsync(
204204
typeKind,
205205
"private",
206-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
206+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
207207
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
208208
true).ConfigureAwait(false);
209209
}
@@ -216,7 +216,7 @@ public async Task TestPrivateConstructorCorrectDocumentationGeneric_NonPrivateCu
216216
await this.TestConstructorCorrectDocumentationCustomizedAsync(
217217
typeKind,
218218
"private",
219-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
219+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
220220
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
221221
true).ConfigureAwait(false);
222222
}
@@ -229,7 +229,7 @@ public async Task TestStaticConstructorCorrectDocumentationAsync(string typeKind
229229
await this.TestConstructorCorrectDocumentationAsync(
230230
typeKind,
231231
"static",
232-
DocumentationResources.StaticConstructorStandardTextFirstPart,
232+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
233233
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
234234
string.Empty,
235235
false).ConfigureAwait(false);
@@ -243,7 +243,7 @@ public async Task TestStaticConstructorCorrectDocumentationGenericAsync(string t
243243
await this.TestConstructorCorrectDocumentationAsync(
244244
typeKind,
245245
"static",
246-
DocumentationResources.StaticConstructorStandardTextFirstPart,
246+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
247247
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
248248
string.Empty,
249249
true).ConfigureAwait(false);
@@ -257,7 +257,7 @@ public async Task TestNonPrivateConstructorMissingDocumentationAsync(string type
257257
await this.TestConstructorMissingDocumentationAsync(
258258
typeKind,
259259
"public",
260-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
260+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
261261
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
262262
false).ConfigureAwait(false);
263263
}
@@ -270,7 +270,7 @@ public async Task TestNonPrivateConstructorMissingDocumentationGenericAsync(stri
270270
await this.TestConstructorMissingDocumentationAsync(
271271
typeKind,
272272
"public",
273-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
273+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
274274
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
275275
true).ConfigureAwait(false);
276276
}
@@ -283,7 +283,7 @@ public async Task TestPrivateConstructorMissingDocumentationAsync(string typeKin
283283
await this.TestConstructorMissingDocumentationAsync(
284284
typeKind,
285285
"private",
286-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
286+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
287287
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
288288
false).ConfigureAwait(false);
289289
}
@@ -296,7 +296,7 @@ public async Task TestPrivateConstructorMissingDocumentationGenericAsync(string
296296
await this.TestConstructorMissingDocumentationAsync(
297297
typeKind,
298298
"private",
299-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
299+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
300300
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
301301
true).ConfigureAwait(false);
302302
}
@@ -309,7 +309,7 @@ public async Task TestStaticConstructorMissingDocumentationAsync(string typeKind
309309
await this.TestConstructorMissingDocumentationAsync(
310310
typeKind,
311311
"static",
312-
DocumentationResources.StaticConstructorStandardTextFirstPart,
312+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
313313
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
314314
false).ConfigureAwait(false);
315315
}
@@ -322,7 +322,7 @@ public async Task TestStaticConstructorMissingDocumentationGenericAsync(string t
322322
await this.TestConstructorMissingDocumentationAsync(
323323
typeKind,
324324
"static",
325-
DocumentationResources.StaticConstructorStandardTextFirstPart,
325+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
326326
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
327327
true).ConfigureAwait(false);
328328
}
@@ -335,7 +335,7 @@ public async Task TestNonPrivateConstructorSimpleDocumentationAsync(string typeK
335335
await this.TestConstructorSimpleDocumentationAsync(
336336
typeKind,
337337
"public",
338-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
338+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
339339
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
340340
false).ConfigureAwait(false);
341341
}
@@ -348,7 +348,7 @@ public async Task TestNonPrivateConstructorSimpleDocumentationGenericAsync(strin
348348
await this.TestConstructorSimpleDocumentationAsync(
349349
typeKind,
350350
"public",
351-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
351+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
352352
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
353353
true).ConfigureAwait(false);
354354
}
@@ -361,7 +361,7 @@ public async Task TestPrivateConstructorSimpleDocumentationAsync(string typeKind
361361
await this.TestConstructorSimpleDocumentationAsync(
362362
typeKind,
363363
"private",
364-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
364+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
365365
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
366366
false).ConfigureAwait(false);
367367
}
@@ -374,7 +374,7 @@ public async Task TestPrivateConstructorSimpleDocumentationGenericAsync(string t
374374
await this.TestConstructorSimpleDocumentationAsync(
375375
typeKind,
376376
"private",
377-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
377+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
378378
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
379379
true).ConfigureAwait(false);
380380
}
@@ -387,7 +387,7 @@ public async Task TestStaticConstructorSimpleDocumentationAsync(string typeKind)
387387
await this.TestConstructorSimpleDocumentationAsync(
388388
typeKind,
389389
"static",
390-
DocumentationResources.StaticConstructorStandardTextFirstPart,
390+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
391391
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
392392
false).ConfigureAwait(false);
393393
}
@@ -400,7 +400,7 @@ public async Task TestStaticConstructorSimpleDocumentationGenericAsync(string ty
400400
await this.TestConstructorSimpleDocumentationAsync(
401401
typeKind,
402402
"static",
403-
DocumentationResources.StaticConstructorStandardTextFirstPart,
403+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
404404
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
405405
true).ConfigureAwait(false);
406406
}
@@ -413,7 +413,7 @@ public async Task TestNonPrivateConstructorSimpleDocumentationWrongTypeNameAsync
413413
await this.TestConstructorSimpleDocumentationWrongTypeNameAsync(
414414
typeKind,
415415
"public",
416-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
416+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
417417
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
418418
false).ConfigureAwait(false);
419419
}
@@ -426,7 +426,7 @@ public async Task TestNonPrivateConstructorSimpleDocumentationGenericWrongTypeNa
426426
await this.TestConstructorSimpleDocumentationWrongTypeNameAsync(
427427
typeKind,
428428
"public",
429-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
429+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
430430
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
431431
true).ConfigureAwait(false);
432432
}
@@ -439,7 +439,7 @@ public async Task TestPrivateConstructorSimpleDocumentationWrongTypeNameAsync(st
439439
await this.TestConstructorSimpleDocumentationWrongTypeNameAsync(
440440
typeKind,
441441
"private",
442-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
442+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
443443
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
444444
false).ConfigureAwait(false);
445445
}
@@ -452,7 +452,7 @@ public async Task TestPrivateConstructorSimpleDocumentationGenericWrongTypeNameA
452452
await this.TestConstructorSimpleDocumentationWrongTypeNameAsync(
453453
typeKind,
454454
"private",
455-
DocumentationResources.NonPrivateConstructorStandardTextFirstPart,
455+
string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind),
456456
string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind),
457457
true).ConfigureAwait(false);
458458
}
@@ -465,7 +465,7 @@ public async Task TestStaticConstructorSimpleDocumentationWrongTypeNameAsync(str
465465
await this.TestConstructorSimpleDocumentationWrongTypeNameAsync(
466466
typeKind,
467467
"static",
468-
DocumentationResources.StaticConstructorStandardTextFirstPart,
468+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
469469
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
470470
false).ConfigureAwait(false);
471471
}
@@ -478,7 +478,7 @@ public async Task TestStaticConstructorSimpleDocumentationGenericWrongTypeNameAs
478478
await this.TestConstructorSimpleDocumentationWrongTypeNameAsync(
479479
typeKind,
480480
"static",
481-
DocumentationResources.StaticConstructorStandardTextFirstPart,
481+
string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind),
482482
string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind),
483483
true).ConfigureAwait(false);
484484
}

0 commit comments

Comments
 (0)