Skip to content

Commit 7ffe55d

Browse files
committed
Fixed build and did some more renaming
1 parent 5eced6b commit 7ffe55d

8 files changed

Lines changed: 100 additions & 100 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1316CodeFixProvider.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ namespace StyleCop.Analyzers.NamingRules
1414
using StyleCop.Analyzers.Helpers;
1515

1616
/// <summary>
17-
/// Implements a code fix for <see cref="SA1316TupleFieldNamesMustUseCorrectCasing"/>.
17+
/// Implements a code fix for <see cref="SA1316TupleElementNamesMustUseCorrectCasing"/>.
1818
/// </summary>
1919
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1316CodeFixProvider))]
2020
[Shared]
2121
internal class SA1316CodeFixProvider : CodeFixProvider
2222
{
2323
/// <inheritdoc/>
2424
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
25-
ImmutableArray.Create(SA1316TupleFieldNamesMustUseCorrectCasing.DiagnosticId);
25+
ImmutableArray.Create(SA1316TupleElementNamesMustUseCorrectCasing.DiagnosticId);
2626

2727
/// <inheritdoc/>
2828
public override Task RegisterCodeFixesAsync(CodeFixContext context)
2929
{
3030
foreach (var diagnostic in context.Diagnostics)
3131
{
32-
if (diagnostic.Properties.TryGetValue(SA1316TupleFieldNamesMustUseCorrectCasing.ExpectedTupleFieldNameKey, out string fixedTupleFieldName))
32+
if (diagnostic.Properties.TryGetValue(SA1316TupleElementNamesMustUseCorrectCasing.ExpectedTupleElementNameKey, out string fixedTupleElementName))
3333
{
3434
context.RegisterCodeFix(
3535
CodeAction.Create(
3636
NamingResources.SA1316CodeFix,
37-
cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, fixedTupleFieldName, cancellationToken),
37+
cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, fixedTupleElementName, cancellationToken),
3838
nameof(SA1316CodeFixProvider)),
3939
diagnostic);
4040
}
@@ -43,13 +43,13 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
4343
return SpecializedTasks.CompletedTask;
4444
}
4545

46-
private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, string fixedTupleFieldName, CancellationToken cancellationToken)
46+
private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, string fixedTupleElementName, CancellationToken cancellationToken)
4747
{
4848
var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
4949

5050
var identifierToken = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start);
5151

52-
var newSyntaxRoot = syntaxRoot.ReplaceToken(identifierToken, SyntaxFactory.Identifier(fixedTupleFieldName).WithTriviaFrom(identifierToken));
52+
var newSyntaxRoot = syntaxRoot.ReplaceToken(identifierToken, SyntaxFactory.Identifier(fixedTupleElementName).WithTriviaFrom(identifierToken));
5353
return document.WithSyntaxRoot(newSyntaxRoot);
5454
}
5555
}

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1142CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class SA1142CodeFixProvider : CodeFixProvider
2424
{
2525
/// <inheritdoc/>
2626
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
27-
ImmutableArray.Create(SA1142ReferToTupleFieldsByName.DiagnosticId);
27+
ImmutableArray.Create(SA1142ReferToTupleElementsByName.DiagnosticId);
2828

2929
public override FixAllProvider GetFixAllProvider() => FixAll.Instance;
3030

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1316CSharp7UnitTests.cs

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ namespace StyleCop.Analyzers.Test.CSharp7.NamingRules
1010
using StyleCop.Analyzers.NamingRules;
1111
using Xunit;
1212
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
13-
StyleCop.Analyzers.NamingRules.SA1316TupleFieldNamesMustUseCorrectCasing,
13+
StyleCop.Analyzers.NamingRules.SA1316TupleElementNamesMustUseCorrectCasing,
1414
StyleCop.Analyzers.NamingRules.SA1316CodeFixProvider>;
1515

1616
/// <summary>
1717
/// This class contains the CSharp 7.x unit tests for SA1316.
1818
/// </summary>
19-
/// <seealso cref="SA1316TupleFieldNamesMustUseCorrectCasing"/>
19+
/// <seealso cref="SA1316TupleElementNamesMustUseCorrectCasing"/>
2020
/// <seealso cref="SA1316CodeFixProvider"/>
2121
public class SA1316CSharp7UnitTests
2222
{
@@ -31,7 +31,7 @@ public class SA1316CSharp7UnitTests
3131
{
3232
""settings"": {
3333
""namingRules"": {
34-
""tupleFieldNameCasing"": ""camelCase""
34+
""tupleElementNameCasing"": ""camelCase""
3535
}
3636
}
3737
}
@@ -41,7 +41,7 @@ public class SA1316CSharp7UnitTests
4141
{
4242
""settings"": {
4343
""namingRules"": {
44-
""tupleFieldNameCasing"": ""pascalCase""
44+
""tupleElementNameCasing"": ""PascalCase""
4545
}
4646
}
4747
}
@@ -51,8 +51,8 @@ public class SA1316CSharp7UnitTests
5151
{
5252
""settings"": {
5353
""namingRules"": {
54-
""includeInferredTupleFieldNames"" : true,
55-
""tupleFieldNameCasing"": ""camelCase""
54+
""includeInferredTupleElementNames"" : true,
55+
""tupleElementNameCasing"": ""camelCase""
5656
}
5757
}
5858
}
@@ -62,8 +62,8 @@ public class SA1316CSharp7UnitTests
6262
{
6363
""settings"": {
6464
""namingRules"": {
65-
""includeInferredTupleFieldNames"" : true,
66-
""tupleFieldNameCasing"": ""pascalCase""
65+
""includeInferredTupleElementNames"" : true,
66+
""tupleElementNameCasing"": ""PascalCase""
6767
}
6868
}
6969
}
@@ -73,8 +73,8 @@ public class SA1316CSharp7UnitTests
7373
{
7474
""settings"": {
7575
""namingRules"": {
76-
""includeInferredTupleFieldNames"" : false,
77-
""tupleFieldNameCasing"": ""camelCase""
76+
""includeInferredTupleElementNames"" : false,
77+
""tupleElementNameCasing"": ""camelCase""
7878
}
7979
}
8080
}
@@ -84,30 +84,30 @@ public class SA1316CSharp7UnitTests
8484
{
8585
""settings"": {
8686
""namingRules"": {
87-
""includeInferredTupleFieldNames"" : false,
88-
""tupleFieldNameCasing"": ""pascalCase""
87+
""includeInferredTupleElementNames"" : false,
88+
""tupleElementNameCasing"": ""PascalCase""
8989
}
9090
}
9191
}
9292
";
9393

9494
/// <summary>
95-
/// Validates the properly named tuple field names will not produce diagnostics.
95+
/// Validates the properly named tuple element names will not produce diagnostics.
9696
/// </summary>
9797
/// <param name="settings">The test settings to use.</param>
98-
/// <param name="tupleFieldName1">The expected tuple field name for the first field.</param>
99-
/// <param name="tupleFieldName2">The expected tuple field name for the second field.</param>
98+
/// <param name="tupleElementName1">The expected tuple element name for the first field.</param>
99+
/// <param name="tupleElementName2">The expected tuple element name for the second field.</param>
100100
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
101101
[Theory]
102-
[InlineData(DefaultTestSettings, "fieldName1", "fieldName2")]
103-
[InlineData(CamelCaseTestSettings, "fieldName1", "fieldName2")]
104-
[InlineData(PascalCaseTestSettings, "FieldName1", "FieldName2")]
105-
public async Task ValidateProperCasedTupleFieldNamesAsync(string settings, string tupleFieldName1, string tupleFieldName2)
102+
[InlineData(DefaultTestSettings, "elementName1", "elementName2")]
103+
[InlineData(CamelCaseTestSettings, "elementName1", "elementName2")]
104+
[InlineData(PascalCaseTestSettings, "ElementName1", "ElementName2")]
105+
public async Task ValidateProperCasedTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2)
106106
{
107107
var testCode = $@"
108108
public class TestClass
109109
{{
110-
public (int {tupleFieldName1}, int {tupleFieldName2}) TestMethod()
110+
public (int {tupleElementName1}, int {tupleElementName2}) TestMethod()
111111
{{
112112
return (1, 1);
113113
}}
@@ -122,7 +122,7 @@ public class TestClass
122122
/// </summary>
123123
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
124124
[Fact]
125-
public async Task ValidateNoTupleFieldNamesAsync()
125+
public async Task ValidateNoTupleElementNamesAsync()
126126
{
127127
var testCode = @"
128128
public class TestClass
@@ -138,30 +138,30 @@ public class TestClass
138138
}
139139

140140
/// <summary>
141-
/// Validates the properly named inferred tuple field names will not produce diagnostics.
141+
/// Validates the properly named inferred tuple element names will not produce diagnostics.
142142
/// </summary>
143143
/// <param name="settings">The test settings to use.</param>
144-
/// <param name="tupleFieldName1">The expected tuple field name for the first field.</param>
145-
/// <param name="tupleFieldName2">The expected tuple field name for the second field.</param>
144+
/// <param name="tupleElementName1">The expected tuple element name for the first field.</param>
145+
/// <param name="tupleElementName2">The expected tuple element name for the second field.</param>
146146
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
147147
[Theory]
148-
[InlineData(DefaultTestSettings, "fieldName1", "fieldName2")]
149-
[InlineData(CamelCaseTestSettings, "fieldName1", "fieldName2")]
150-
[InlineData(PascalCaseTestSettings, "FieldName1", "FieldName2")]
151-
[InlineData(CamelCaseInferredTestSettings, "fieldName1", "fieldName2")]
152-
[InlineData(PascalCaseInferredTestSettings, "FieldName1", "FieldName2")]
153-
[InlineData(CamelCaseExplicitOnlyTestSettings, "fieldName1", "fieldName2")]
154-
[InlineData(PascalCaseExplicitOnlyTestSettings, "FieldName1", "FieldName2")]
155-
public async Task ValidateProperCasedInferredTupleFieldNamesAsync(string settings, string tupleFieldName1, string tupleFieldName2)
148+
[InlineData(DefaultTestSettings, "elementName1", "elementName2")]
149+
[InlineData(CamelCaseTestSettings, "elementName1", "elementName2")]
150+
[InlineData(PascalCaseTestSettings, "ElementName1", "ElementName2")]
151+
[InlineData(CamelCaseInferredTestSettings, "elementName1", "elementName2")]
152+
[InlineData(PascalCaseInferredTestSettings, "ElementName1", "ElementName2")]
153+
[InlineData(CamelCaseExplicitOnlyTestSettings, "elementName1", "elementName2")]
154+
[InlineData(PascalCaseExplicitOnlyTestSettings, "ElementName1", "ElementName2")]
155+
public async Task ValidateProperCasedInferredTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2)
156156
{
157157
var testCode = $@"
158158
public class TestClass
159159
{{
160160
public void TestMethod()
161161
{{
162-
var {tupleFieldName1} = 1;
163-
var {tupleFieldName2} = ""test"";
164-
var tuple = ({tupleFieldName1}, {tupleFieldName2});
162+
var {tupleElementName1} = 1;
163+
var {tupleElementName2} = ""test"";
164+
var tuple = ({tupleElementName1}, {tupleElementName2});
165165
}}
166166
}}
167167
";
@@ -170,29 +170,29 @@ public void TestMethod()
170170
}
171171

172172
/// <summary>
173-
/// Validates the improperly named tuple field names will produce the expected diagnostics.
173+
/// Validates the improperly named tuple element names will produce the expected diagnostics.
174174
/// </summary>
175175
/// <param name="settings">The test settings to use.</param>
176-
/// <param name="tupleFieldName1">The expected tuple field name for the first field.</param>
177-
/// <param name="tupleFieldName2">The expected tuple field name for the second field.</param>
178-
/// <param name="fixedTupleFieldName1">The expected fixed tuple field name for the first field.</param>
179-
/// <param name="fixedTupleFieldName2">The expected fixed tuple field name for the second field.</param>
176+
/// <param name="tupleElementName1">The expected tuple element name for the first field.</param>
177+
/// <param name="tupleElementName2">The expected tuple element name for the second field.</param>
178+
/// <param name="fixedTupleElementName1">The expected fixed tuple element name for the first field.</param>
179+
/// <param name="fixedTupleElementName2">The expected fixed tuple element name for the second field.</param>
180180
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
181181
[Theory]
182-
[InlineData(DefaultTestSettings, "FieldName1", "FieldName2", "fieldName1", "fieldName2")]
183-
[InlineData(CamelCaseTestSettings, "FieldName1", "FieldName2", "fieldName1", "fieldName2")]
184-
[InlineData(PascalCaseTestSettings, "fieldName1", "fieldName2", "FieldName1", "FieldName2")]
185-
public async Task ValidateImproperCasedTupleFieldNamesAsync(string settings, string tupleFieldName1, string tupleFieldName2, string fixedTupleFieldName1, string fixedTupleFieldName2)
182+
[InlineData(DefaultTestSettings, "ElementName1", "ElementName2", "elementName1", "elementName2")]
183+
[InlineData(CamelCaseTestSettings, "ElementName1", "ElementName2", "elementName1", "elementName2")]
184+
[InlineData(PascalCaseTestSettings, "elementName1", "elementName2", "ElementName1", "ElementName2")]
185+
public async Task ValidateImproperCasedTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2, string fixedTupleElementName1, string fixedTupleElementName2)
186186
{
187187
var testCode = $@"
188188
public class TestClass
189189
{{
190-
public (int [|{tupleFieldName1}|], int [|{tupleFieldName2}|]) TestMethod1()
190+
public (int [|{tupleElementName1}|], int [|{tupleElementName2}|]) TestMethod1()
191191
{{
192192
return (1, 1);
193193
}}
194194
195-
public (int /* 1 */ [|{tupleFieldName1}|] /* 2 */ , int /* 3 */ [|{tupleFieldName2}|] /* 4 */) TestMethod2()
195+
public (int /* 1 */ [|{tupleElementName1}|] /* 2 */ , int /* 3 */ [|{tupleElementName2}|] /* 4 */) TestMethod2()
196196
{{
197197
return (1, 1);
198198
}}
@@ -202,12 +202,12 @@ public class TestClass
202202
var fixedCode = $@"
203203
public class TestClass
204204
{{
205-
public (int {fixedTupleFieldName1}, int {fixedTupleFieldName2}) TestMethod1()
205+
public (int {fixedTupleElementName1}, int {fixedTupleElementName2}) TestMethod1()
206206
{{
207207
return (1, 1);
208208
}}
209209
210-
public (int /* 1 */ {fixedTupleFieldName1} /* 2 */ , int /* 3 */ {fixedTupleFieldName2} /* 4 */) TestMethod2()
210+
public (int /* 1 */ {fixedTupleElementName1} /* 2 */ , int /* 3 */ {fixedTupleElementName2} /* 4 */) TestMethod2()
211211
{{
212212
return (1, 1);
213213
}}
@@ -223,28 +223,28 @@ public class TestClass
223223
}
224224

225225
/// <summary>
226-
/// Verifies that improperly named inferred tuple field names are ignored when the 'includeInferredTupleFieldNames' option is not set to true.
226+
/// Verifies that improperly named inferred tuple element names are ignored when the 'includeInferredTupleElementNames' option is not set to true.
227227
/// </summary>
228228
/// <param name="settings">The test settings to use.</param>
229-
/// <param name="tupleFieldName1">The expected tuple field name for the first field.</param>
230-
/// <param name="tupleFieldName2">The expected tuple field name for the second field.</param>
229+
/// <param name="tupleElementName1">The expected tuple element name for the first field.</param>
230+
/// <param name="tupleElementName2">The expected tuple element name for the second field.</param>
231231
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
232232
[Theory]
233-
[InlineData(DefaultTestSettings, "FieldName1", "FieldName2")]
234-
[InlineData(CamelCaseTestSettings, "FieldName1", "FieldName2")]
235-
[InlineData(PascalCaseTestSettings, "fieldName1", "fieldName2")]
236-
[InlineData(CamelCaseExplicitOnlyTestSettings, "FieldName1", "FieldName2")]
237-
[InlineData(PascalCaseExplicitOnlyTestSettings, "fieldName1", "fieldName2")]
238-
public async Task ValidateImproperCasedInferredTupleFieldNamesAreIgnoredAsync(string settings, string tupleFieldName1, string tupleFieldName2)
233+
[InlineData(DefaultTestSettings, "ElementName1", "ElementName2")]
234+
[InlineData(CamelCaseTestSettings, "ElementName1", "ElementName2")]
235+
[InlineData(PascalCaseTestSettings, "elementName1", "elementName2")]
236+
[InlineData(CamelCaseExplicitOnlyTestSettings, "ElementName1", "ElementName2")]
237+
[InlineData(PascalCaseExplicitOnlyTestSettings, "elementName1", "elementName2")]
238+
public async Task ValidateImproperCasedInferredTupleElementNamesAreIgnoredAsync(string settings, string tupleElementName1, string tupleElementName2)
239239
{
240240
var testCode = $@"
241241
public class TestClass
242242
{{
243243
public void TestMethod()
244244
{{
245-
var {tupleFieldName1} = 1;
246-
var {tupleFieldName2} = ""test"";
247-
var tuple = ({tupleFieldName1}, {tupleFieldName2});
245+
var {tupleElementName1} = 1;
246+
var {tupleElementName2} = ""test"";
247+
var tuple = ({tupleElementName1}, {tupleElementName2});
248248
}}
249249
}}
250250
";
@@ -253,33 +253,33 @@ public void TestMethod()
253253
}
254254

255255
/// <summary>
256-
/// Validates the improperly named inferred tuple field names will produce the expected diagnostics.
256+
/// Validates the improperly named inferred tuple element names will produce the expected diagnostics.
257257
/// </summary>
258258
/// <param name="settings">The test settings to use.</param>
259-
/// <param name="tupleFieldName1">The expected tuple field name for the first field.</param>
260-
/// <param name="tupleFieldName2">The expected tuple field name for the second field.</param>
259+
/// <param name="tupleElementName1">The expected tuple element name for the first field.</param>
260+
/// <param name="tupleElementName2">The expected tuple element name for the second field.</param>
261261
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
262262
[Theory]
263-
[InlineData(CamelCaseInferredTestSettings, "FieldName1", "FieldName2")]
264-
[InlineData(PascalCaseInferredTestSettings, "fieldName1", "fieldName2")]
265-
public async Task ValidateImproperCasedImplicitTupleFieldNamesAsync(string settings, string tupleFieldName1, string tupleFieldName2)
263+
[InlineData(CamelCaseInferredTestSettings, "ElementName1", "ElementName2")]
264+
[InlineData(PascalCaseInferredTestSettings, "elementName1", "elementName2")]
265+
public async Task ValidateImproperCasedImplicitTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2)
266266
{
267267
//// TODO: C# 7.1
268268
var testCode = $@"
269269
public class TestClass
270270
{{
271271
public void TestMethod1()
272272
{{
273-
var {tupleFieldName1} = 1;
274-
var {tupleFieldName2} = ""test"";
275-
var tuple = ([|{tupleFieldName1}|], [|{tupleFieldName2}|]);
273+
var {tupleElementName1} = 1;
274+
var {tupleElementName2} = ""test"";
275+
var tuple = ([|{tupleElementName1}|], [|{tupleElementName2}|]);
276276
}}
277277
278278
public void TestMethod2()
279279
{{
280-
var {tupleFieldName1} = 1;
281-
var {tupleFieldName2} = ""test"";
282-
var tuple = (/* 1 */ [|{tupleFieldName1}|] /* 2 */, /* 3 */ [|{tupleFieldName2}|] /* 4 */);
280+
var {tupleElementName1} = 1;
281+
var {tupleElementName2} = ""test"";
282+
var tuple = (/* 1 */ [|{tupleElementName1}|] /* 2 */, /* 3 */ [|{tupleElementName2}|] /* 4 */);
283283
}}
284284
}}
285285
";

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1142CSharp7UnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
99
using StyleCop.Analyzers.ReadabilityRules;
1010
using Xunit;
1111
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12-
StyleCop.Analyzers.ReadabilityRules.SA1142ReferToTupleFieldsByName,
12+
StyleCop.Analyzers.ReadabilityRules.SA1142ReferToTupleElementsByName,
1313
StyleCop.Analyzers.ReadabilityRules.SA1142CodeFixProvider>;
1414

1515
/// <summary>
1616
/// This class contains the CSharp 7.x unit tests for SA1142.
1717
/// </summary>
18-
/// <seealso cref="SA1142ReferToTupleFieldsByName"/>
18+
/// <seealso cref="SA1142ReferToTupleElementsByName"/>
1919
/// <seealso cref="SA1142CodeFixProvider"/>
2020
public class SA1142CSharp7UnitTests
2121
{

0 commit comments

Comments
 (0)