Skip to content

Commit 0d23b74

Browse files
committed
Address PR feedback
1 parent d4de971 commit 0d23b74

2 files changed

Lines changed: 15 additions & 24 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1132UnitTests.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,24 @@ class Foo
112112
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
113113
}
114114

115-
[Fact]
116-
public async Task TestDeclarationWithMissingTokensAndNodesAsync()
115+
[Theory]
116+
[InlineData("CS1001", 19, "Identifier expected", "private int a,, b;")]
117+
[InlineData("CS1001", 20, "Identifier expected", "private int e, = 3;")]
118+
[InlineData("CS1002", 21, "; expected", "private int c, d")]
119+
public async Task TestDeclarationWithMissingTokensAndNodesAsync(string id, int column, string message, string declaration)
117120
{
118-
const string testCode = @"
121+
string testCode = $@"
119122
class Foo
120-
{
121-
private int a,, b;
122-
private int c, d
123-
}";
123+
{{
124+
{declaration}
125+
}}";
124126

125-
DiagnosticResult[] expected =
127+
DiagnosticResult expected = new DiagnosticResult
126128
{
127-
new DiagnosticResult
128-
{
129-
Id = "CS1001",
130-
Severity = DiagnosticSeverity.Error,
131-
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 4, 19) },
132-
Message = "Identifier expected"
133-
},
134-
new DiagnosticResult
135-
{
136-
Id = "CS1002",
137-
Severity = DiagnosticSeverity.Error,
138-
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 5, 21) },
139-
Message = "; expected"
140-
}
129+
Id = id,
130+
Severity = DiagnosticSeverity.Error,
131+
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 4, column) },
132+
Message = message
141133
};
142134

143135
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1132DoNotCombineFields.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace StyleCop.Analyzers.ReadabilityRules
55
{
66
using System.Collections.Immutable;
7-
using System.Linq;
87
using Microsoft.CodeAnalysis;
98
using Microsoft.CodeAnalysis.CSharp;
109
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -55,7 +54,7 @@ private static void HandleDeclaration(SyntaxNodeAnalysisContext context)
5554

5655
foreach (VariableDeclaratorSyntax variable in variables)
5756
{
58-
if (variable.IsMissing)
57+
if (variable.IsMissing || variable.Identifier.IsMissing)
5958
{
6059
return;
6160
}

0 commit comments

Comments
 (0)