Skip to content

Commit 3ed63ac

Browse files
committed
Add corrected ID and name to SA1314TypeParameterNamesMustBeginWithT
1 parent d0fab43 commit 3ed63ac

11 files changed

Lines changed: 83 additions & 83 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1654CodeFixProvider.cs renamed to StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1314CodeFixProvider.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ namespace StyleCop.Analyzers.NamingRules
1313
using Microsoft.CodeAnalysis.CodeFixes;
1414

1515
/// <summary>
16-
/// Implements a code fix for <see cref="SA1654GenericParameterNamesMustBeginWithT"/>.
16+
/// Implements a code fix for <see cref="SA1314TypeParameterNamesMustBeginWithT"/>.
1717
/// </summary>
1818
/// <remarks>
19-
/// <para>To fix a violation of this rule, add the capital letter T to the front of the generic parameter name.</para>
19+
/// <para>To fix a violation of this rule, add the capital letter T to the front of the type parameter name.</para>
2020
/// </remarks>
21-
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1654CodeFixProvider))]
21+
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1314CodeFixProvider))]
2222
[Shared]
23-
internal class SA1654CodeFixProvider : CodeFixProvider
23+
internal class SA1314CodeFixProvider : CodeFixProvider
2424
{
2525
/// <inheritdoc/>
2626
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
27-
ImmutableArray.Create(SA1654GenericParameterNamesMustBeginWithT.DiagnosticId);
27+
ImmutableArray.Create(SA1314TypeParameterNamesMustBeginWithT.DiagnosticId);
2828

2929
/// <inheritdoc/>
3030
public override Task RegisterCodeFixesAsync(CodeFixContext context)
@@ -33,9 +33,9 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
3333
{
3434
context.RegisterCodeFix(
3535
CodeAction.Create(
36-
NamingResources.SA1654CodeFix,
36+
NamingResources.SA1314CodeFix,
3737
cancellationToken => CreateChangedSolutionAsync(context.Document, diagnostic, cancellationToken),
38-
nameof(SA1654CodeFixProvider)),
38+
nameof(SA1314CodeFixProvider)),
3939
diagnostic);
4040
}
4141

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<Compile Include="NamingRules\SA1308CodeFixProvider.cs" />
102102
<Compile Include="NamingRules\SA1309CodeFixProvider.cs" />
103103
<Compile Include="NamingRules\SA1310CodeFixProvider.cs" />
104-
<Compile Include="NamingRules\SA1654CodeFixProvider.cs" />
104+
<Compile Include="NamingRules\SA1314CodeFixProvider.cs" />
105105
<Compile Include="NamingRules\SX1309CodeFixProvider.cs" />
106106
<Compile Include="OrderingRules\ElementOrderCodeFixProvider.cs" />
107107
<Compile Include="OrderingRules\SA1205CodeFixProvider.cs" />

StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1654UnitTests.cs renamed to StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1314UnitTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace StyleCop.Analyzers.Test.NamingRules
1212
using TestHelper;
1313
using Xunit;
1414

15-
public class SA1654UnitTests : CodeFixVerifier
15+
public class SA1314UnitTests : CodeFixVerifier
1616
{
1717
[Fact]
1818
public async Task TestGenericParameterDoesNotStartWithTAsync()
@@ -210,12 +210,12 @@ public class Foo<TKey1>
210210

211211
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
212212
{
213-
yield return new SA1654GenericParameterNamesMustBeginWithT();
213+
yield return new SA1314TypeParameterNamesMustBeginWithT();
214214
}
215215

216216
protected override CodeFixProvider GetCSharpCodeFixProvider()
217217
{
218-
return new SA1654CodeFixProvider();
218+
return new SA1314CodeFixProvider();
219219
}
220220
}
221221
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
<Compile Include="NamingRules\SA1311UnitTests.cs" />
267267
<Compile Include="NamingRules\SA1312UnitTests.cs" />
268268
<Compile Include="NamingRules\SA1313UnitTests.cs" />
269-
<Compile Include="NamingRules\SA1654UnitTests.cs" />
269+
<Compile Include="NamingRules\SA1314UnitTests.cs" />
270270
<Compile Include="NamingRules\SX1309SUnitTests.cs" />
271271
<Compile Include="NamingRules\SX1309UnitTests.cs" />
272272
<Compile Include="OrderingRules\SA1200OutsideNamespaceUnitTests.cs" />

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.Designer.cs

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.resx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@
141141
<data name="SA1313Title" xml:space="preserve">
142142
<value>Parameter names must begin with lower-case letter</value>
143143
</data>
144-
<data name="SA1654CodeFix" xml:space="preserve">
145-
<value>Prefix generic parameter name with 'T'</value>
144+
<data name="SA1314CodeFix" xml:space="preserve">
145+
<value>Prefix type parameter name with 'T'</value>
146146
</data>
147-
<data name="SA1654Description" xml:space="preserve">
148-
<value>The name of a C# generic parameter does not begin with the capital letter T.</value>
147+
<data name="SA1314Description" xml:space="preserve">
148+
<value>The name of a C# type parameter does not begin with the capital letter T.</value>
149149
</data>
150-
<data name="SA1654MessageFormat" xml:space="preserve">
151-
<value>Generic parameter names must begin with T</value>
150+
<data name="SA1314MessageFormat" xml:space="preserve">
151+
<value>Type parameter names must begin with T</value>
152152
</data>
153-
<data name="SA1654Title" xml:space="preserve">
154-
<value>Generic parameter names must begin with T</value>
153+
<data name="SA1314Title" xml:space="preserve">
154+
<value>Type parameter names must begin with T</value>
155155
</data>
156156
</root>

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1654GenericParameterNamesMustBeginWithT.cs renamed to StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1314TypeParameterNamesMustBeginWithT.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ namespace StyleCop.Analyzers.NamingRules
1111
using Microsoft.CodeAnalysis.Diagnostics;
1212

1313
/// <summary>
14-
/// The name of a C# generic parameter does not begin with the capital letter T.
14+
/// The name of a C# type parameter does not begin with the capital letter T.
1515
/// </summary>
1616
/// <remarks>
17-
/// A violation of this rule occurs when the name of a generic parameter does not begin with the capital letter T.
18-
/// Generic parameter names should always begin with T. For example, <c>T</c> or <c>TKey</c>.
17+
/// A violation of this rule occurs when the name of a C# type parameter does not begin with the capital letter T.
18+
/// Type parameter names should always begin with T. For example, <c>T</c> or <c>TKey</c>.
1919
/// </remarks>
2020
[DiagnosticAnalyzer(LanguageNames.CSharp)]
21-
internal class SA1654GenericParameterNamesMustBeginWithT : DiagnosticAnalyzer
21+
internal class SA1314TypeParameterNamesMustBeginWithT : DiagnosticAnalyzer
2222
{
2323
/// <summary>
24-
/// The ID for diagnostics produced by the <see cref="SA1654GenericParameterNamesMustBeginWithT"/> analyzer.
24+
/// The ID for diagnostics produced by the <see cref="SA1314TypeParameterNamesMustBeginWithT"/> analyzer.
2525
/// </summary>
26-
public const string DiagnosticId = "SA1654";
27-
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1654Title), NamingResources.ResourceManager, typeof(NamingResources));
28-
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1654MessageFormat), NamingResources.ResourceManager, typeof(NamingResources));
29-
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1654Description), NamingResources.ResourceManager, typeof(NamingResources));
30-
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1654.md";
26+
public const string DiagnosticId = "SA1314";
27+
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1314Title), NamingResources.ResourceManager, typeof(NamingResources));
28+
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1314MessageFormat), NamingResources.ResourceManager, typeof(NamingResources));
29+
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1314Description), NamingResources.ResourceManager, typeof(NamingResources));
30+
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1314.md";
3131

3232
private static readonly DiagnosticDescriptor Descriptor =
3333
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink);

StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
<Compile Include="NamingRules\SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter.cs" />
205205
<Compile Include="NamingRules\SA1312VariableNamesMustBeginWithLowerCaseLetter.cs" />
206206
<Compile Include="NamingRules\SA1313ParameterNamesMustBeginWithLowerCaseLetter.cs" />
207-
<Compile Include="NamingRules\SA1654GenericParameterNamesMustBeginWithT.cs" />
207+
<Compile Include="NamingRules\SA1314TypeParameterNamesMustBeginWithT.cs" />
208208
<Compile Include="NamingRules\SX1309FieldNamesMustBeginWithUnderscore.cs" />
209209
<Compile Include="NamingRules\SX1309SStaticFieldNamesMustBeginWithUnderscore.cs" />
210210
<Compile Include="NoCodeFixAttribute.cs" />

StyleCopAnalyzers.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat
132132
documentation\SA1311.md = documentation\SA1311.md
133133
documentation\SA1312.md = documentation\SA1312.md
134134
documentation\SA1313.md = documentation\SA1313.md
135+
documentation\SA1314.md = documentation\SA1314.md
135136
documentation\SA1400.md = documentation\SA1400.md
136137
documentation\SA1401.md = documentation\SA1401.md
137138
documentation\SA1402.md = documentation\SA1402.md
@@ -219,7 +220,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat
219220
documentation\SA1650.md = documentation\SA1650.md
220221
documentation\SA1651.md = documentation\SA1651.md
221222
documentation\SA1652.md = documentation\SA1652.md
222-
documentation\SA1654.md = documentation\SA1654.md
223223
documentation\SX1101.md = documentation\SX1101.md
224224
documentation\SX1309.md = documentation\SX1309.md
225225
documentation\SX1309S.md = documentation\SX1309S.md

documentation/SA1314.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## SA1314
2+
3+
<table>
4+
<tr>
5+
<td>TypeName</td>
6+
<td>SA1314TypeParameterNamesMustBeginWithT</td>
7+
</tr>
8+
<tr>
9+
<td>CheckId</td>
10+
<td>SA1314</td>
11+
</tr>
12+
<tr>
13+
<td>Category</td>
14+
<td>Naming Rules</td>
15+
</tr>
16+
</table>
17+
18+
## Cause
19+
20+
The name of a C# type parameter does not begin with the capital letter T.
21+
22+
## Rule description
23+
24+
A violation of this rule occurs when the name of a C# type parameter does not begin with the capital letter T. Type parameter names should always begin with T. For example, *T* or *TKey*.
25+
26+
## How to fix violations
27+
28+
To fix a violation of this rule, add the capital letter T to the front of the type parameter name.
29+
30+
## How to suppress violations
31+
32+
```csharp
33+
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1314:TypeParameterNamesMustBeginWithT", Justification = "Reviewed.")]
34+
```
35+
36+
```csharp
37+
#pragma warning disable SA1314 // Type parameter names must begin with T
38+
#pragma warning restore SA1314 // Type parameter names must begin with T
39+
```

0 commit comments

Comments
 (0)