Skip to content

Commit 5eced6b

Browse files
sharwellvweijsters
andauthored
Apply suggestions from code review
Co-Authored-By: vweijsters <vweijsters@users.noreply.github.com>
1 parent afba2b3 commit 5eced6b

10 files changed

Lines changed: 49 additions & 49 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/NamingSettings.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ protected internal NamingSettings()
2222
this.AllowCommonHungarianPrefixes = true;
2323
this.allowedHungarianPrefixes = ImmutableArray.CreateBuilder<string>();
2424

25-
this.IncludeInferredTupleFieldNames = false;
26-
this.TupleFieldNameCasing = TupleFieldNameCase.CamelCase;
25+
this.IncludeInferredTupleElementNames = false;
26+
this.TupleElementNameCasing = TupleElementNameCase.CamelCase;
2727
}
2828

2929
/// <summary>
@@ -57,12 +57,12 @@ protected internal NamingSettings(JsonObject namingSettingsObject)
5757

5858
break;
5959

60-
case "includeInferredTupleFieldNames":
61-
this.IncludeInferredTupleFieldNames = kvp.ToBooleanValue();
60+
case "includeInferredTupleElementNames":
61+
this.IncludeInferredTupleElementNames = kvp.ToBooleanValue();
6262
break;
6363

64-
case "tupleFieldNameCasing":
65-
this.TupleFieldNameCasing = kvp.ToEnumValue<TupleFieldNameCase>();
64+
case "tupleElementNameCasing":
65+
this.TupleElementNameCasing = kvp.ToEnumValue<TupleElementNameCase>();
6666
break;
6767

6868
default:

StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TupleFieldNameCase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
namespace StyleCop.Analyzers.Settings.ObjectModel
55
{
6-
internal enum TupleFieldNameCase
6+
internal enum TupleElementNameCase
77
{
88
/// <summary>
9-
/// Tuple field names must use camel case.
9+
/// Tuple element names must use camelCase.
1010
/// </summary>
1111
CamelCase = 0,
1212

1313
/// <summary>
14-
/// Tuple field names must use pascal case.
14+
/// Tuple element names must use PascalCase.
1515
/// </summary>
1616
PascalCase,
1717
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@
128128
"uniqueItems": true
129129
}
130130
},
131-
"includeInferredTupleFieldNames": {
131+
"includeInferredTupleElementNames": {
132132
"type": "boolean",
133-
"description": "Specifies whether inferred tuple field names will be analyzed as well.",
133+
"description": "Specifies whether inferred tuple element names will be analyzed as well.",
134134
"default": false
135135
},
136-
"tupleFieldNameCasing": {
136+
"tupleElementNameCasing": {
137137
"type": "string",
138-
"description": "Specifies the casing convention used for tuple field names.",
138+
"description": "Specifies the casing convention used for tuple element names.",
139139
"enum": [
140140
"camelCase",
141-
"pascalCase"
141+
"PascalCase"
142142
],
143143
"default": "camelCase"
144144
}

documentation/Configuration.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,39 +314,39 @@ The following example shows a settings file which allows the common prefixes as
314314
}
315315
```
316316

317-
### Tuple field names
317+
### Tuple element names
318318

319-
The following properties are used to configure the behavior of the tuple field name analyzers.
319+
The following properties are used to configure the behavior of the tuple element name analyzers.
320320

321321
| Property | Default Value | Minimum Version | Summary |
322322
| --- | --- | --- | --- |
323-
| `includeInferredTupleFieldNames` | false | 1.2.0 | Specifies whether inferred tuple field names will be analyzed as well. |
324-
| `tupleFieldNameCasing` | "camelCase" | 1.2.0 | Specifies the casing convention used for tuple field names. |
323+
| `includeInferredTupleElementNames` | false | 1.2.0 | Specifies whether inferred tuple element names will be analyzed as well. |
324+
| `tupleElementNameCasing` | "camelCase" | 1.2.0 | Specifies the casing convention used for tuple element names. |
325325

326-
The following example shows a settings file which requires tuple field names to use pascalCase for all tuple field names (including implicitly named tuple fields).
326+
The following example shows a settings file which requires tuple element names to use PascalCase for all tuple elements (including inferred element names).
327327

328328
```json
329329
{
330330
"settings": {
331331
"namingRules": {
332-
"includeInferredTupleFieldNames": true,
333-
"tupleFieldNameCasing" : "pascalCase"
332+
"includeInferredTupleElementNames": true,
333+
"tupleElementNameCasing" : "PascalCase"
334334
}
335335
}
336336
}
337337
```
338338

339339

340-
#### Tuple Field Name Casing
341-
The `tupleFieldNameCasing` property affects the behavior of the [SA1316 Tuple field names must use correct casing](SA1316.md) analyzer.
340+
#### Tuple Element Name Casing
341+
The `tupleElementNameCasing` property affects the behavior of the [SA1316 Tuple element names should use correct casing](SA1316.md) analyzer.
342342

343343
This property has two allowed values, which are described as follows.
344344

345345
##### `"camelCase"`
346-
In this mode, tuple field names must start with a lowercase letter.
346+
In this mode, tuple element names must start with a lowercase letter.
347347

348-
##### `"pascalCase"`
349-
In this mode, tuple field names must start with an uppercase letter.
348+
##### `"PascalCase"`
349+
In this mode, tuple element names must start with an uppercase letter.
350350

351351

352352
## Maintainability Rules

documentation/NamingRules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Identifier | Name | Description
1818
[SA1312](SA1312.md) | VariableNamesMustBeginWithLowerCaseLetter | The name of a variable in C# does not begin with a lower-case letter.
1919
[SA1313](SA1313.md) | ParameterNamesMustBeginWithLowerCaseLetter | The name of a parameter in C# does not begin with a lower-case letter.
2020
[SA1314](SA1314.md) | TypeParameterNamesMustBeginWithT | The name of a C# type parameter does not begin with the capital letter T.
21-
[SA1316](SA1316.md) | TupleFieldNamesMustUseCorrectCasing | Field names within a tuple declaration should have the correct casing.
21+
[SA1316](SA1316.md) | TupleElementNamesShouldUseCorrectCasing | Element names within a tuple type should have the correct casing.

documentation/ReadabilityRules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ Identifier | Name | Description
4242
[SA1137](SA1137.md) | ElementsShouldHaveTheSameIndentation | Two sibling elements which each start on their own line have different levels of indentation.
4343
[SA1139](SA1139.md) | UseLiteralsSuffixNotationInsteadOfCasting | Use literal suffix notation instead of casting.
4444
[SA1141](SA1141.md) | UseTupleSyntax | Use tuple syntax instead of the underlying ValueTuple implementation type.
45-
[SA1142](SA1142.md) | ReferToTupleFieldsByName | A field of a tuple was referenced by its metadata name when a field name is available.
45+
[SA1142](SA1142.md) | ReferToTupleElementsByName | An element of a tuple was referenced by its metadata name when an element name is available.

documentation/SA1141.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A ValueTuple type declaration was used instead of the preferred tuple language c
2929
For example, the following code would produce a violation of this rule:
3030

3131
```csharp
32-
ValueTuple<int, int> x;
32+
ValueTuple<int, int> x; // SA1141
3333
```
3434

3535
The following code would not produce any violations:

documentation/SA1142.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<table>
44
<tr>
55
<td>TypeName</td>
6-
<td>SA1142ReferToTupleFieldsByName</td>
6+
<td>SA1142ReferToTupleElementsByName</td>
77
</tr>
88
<tr>
99
<td>CheckId</td>
@@ -20,18 +20,18 @@
2020

2121
## Cause
2222

23-
A field of a tuple was referenced by its metadata name when a field name is available.
23+
An element of a tuple was referenced by its metadata name when an element name is available.
2424

2525
## Rule description
2626

27-
A field of a tuple was referenced by its metadata name when a field name is available. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7.
27+
An element of a tuple was referenced by its metadata name when an element name is available. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7.
2828

2929
For example, the following code would produce a violation of this rule:
3030

3131
```csharp
3232
(int valueA, int valueB) x;
3333

34-
var y = x.Item1;
34+
var y = x.Item1; // SA1142
3535
```
3636

3737
The following code would not produce any violations:
@@ -44,15 +44,15 @@ var y = x.valueA;
4444

4545
## How to fix violations
4646

47-
To fix a violation of this rule, use the appropriate tuple field name in code instead of the metadata name.
47+
To fix a violation of this rule, use the appropriate tuple element name in code instead of the metadata name.
4848

4949
## How to suppress violations
5050

5151
```csharp
52-
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1142:ReferToTupleFieldsByName", Justification = "Reviewed.")]
52+
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1142:ReferToTupleElementsByName", Justification = "Reviewed.")]
5353
```
5454

5555
```csharp
56-
#pragma warning disable SA1142 // Refer to tuple fields by name
57-
#pragma warning restore SA1142 // Refer to tuple fields by name
56+
#pragma warning disable SA1142 // Refer to tuple elements by name
57+
#pragma warning restore SA1142 // Refer to tuple elements by name
5858
```

documentation/SA1316.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<table>
44
<tr>
55
<td>TypeName</td>
6-
<td>SA1316TupleFieldNamesMustUseCorrectCasing</td>
6+
<td>SA1316TupleElementNamesShouldUseCorrectCasing</td>
77
</tr>
88
<tr>
99
<td>CheckId</td>
@@ -20,18 +20,18 @@
2020

2121
## Cause
2222

23-
Field names within a tuple declaration should have the correct casing.
23+
Element names within a tuple type should have the correct casing.
2424

2525
## Rule description
2626

27-
Tuple declarations with field names should use the configured casing for the field names (see [Configuration.md](Configuration.md) for details). See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7.
27+
Tuple types with element names should use the configured casing for the element names (see [Configuration.md](Configuration.md) for details). See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7.
2828

2929
For example, the following code would produce a violation of this rule (with default settings):
3030

3131
```csharp
3232
public class ExampleClass
3333
{
34-
public (int ValueA, int ValueB) ExampleMethod()
34+
public (int ValueA, int ValueB) ExampleMethod() // SA1316
3535
{
3636
}
3737
}
@@ -50,15 +50,15 @@ public class ExampleClass
5050

5151
## How to fix violations
5252

53-
To fix a violation of this rule, correct the casing of the tuple field name.
53+
To fix a violation of this rule, correct the casing of the tuple element name.
5454

5555
## How to suppress violations
5656

5757
```csharp
58-
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1316:TupleFieldNamesMustUseCorrectCasing", Justification = "Reviewed.")]
58+
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1316:TupleElementNamesShouldUseCorrectCasing", Justification = "Reviewed.")]
5959
```
6060

6161
```csharp
62-
#pragma warning disable SA1316 // Tuple field names must use correct casing
63-
#pragma warning restore SA1316 // Tuple field names must use correct casing
62+
#pragma warning disable SA1316 // Tuple element names should use correct casing
63+
#pragma warning restore SA1316 // Tuple element names should use correct casing
6464
```

documentation/SA1414.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020

2121
## Cause
2222

23-
A tuple declaration without element names is present in a member declaration.
23+
A tuple type without element names is present in a member declaration.
2424

2525
## Rule description
2626

27-
Tuple types appearing in member declarations should have explicitly named tuple elements. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7.
27+
Tuple types appearing in member declarations should have explicitly named elements. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7.
2828

2929
For example, the following code would produce a violation of this rule:
3030

3131
```csharp
3232
public class ExampleClass
3333
{
34-
public (int, int) ExampleMethod()
34+
public (int, int) ExampleMethod() // SA1414
3535
{
3636
}
3737
}
@@ -50,7 +50,7 @@ public class ExampleClass
5050

5151
## How to fix violations
5252

53-
To fix a violation of this rule, provide an element name foreach tuple element.
53+
To fix a violation of this rule, provide an element name for each tuple element.
5454

5555
## How to suppress violations
5656

0 commit comments

Comments
 (0)