Skip to content

Commit f2e3a7a

Browse files
committed
Fix compiler errors
1 parent 8b3beda commit f2e3a7a

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1308UnitTests.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public async Task TestFieldInsideNativeMethodsClassAsync()
8787
/// <summary>
8888
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#627.
8989
/// </summary>
90+
/// <param name="prefix">The prefix to repeat in the variable name.</param>
9091
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
9192
/// <seealso href="https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/627">#627: Code Fixes For Naming
9293
/// Rules SA1308 and SA1309 Do Not Always Fix The Name Entirely</seealso>
@@ -99,9 +100,10 @@ public async Task TestFixingMultipleIdenticalPrefixesAsync(string prefix)
99100
private string {prefix}{prefix}bar = ""baz"";
100101
}}";
101102

103+
string diagnosticPrefix = prefix.Replace("\\u005F", "_");
102104
DiagnosticResult expected =
103105
this.CSharpDiagnostic()
104-
.WithArguments($"{prefix}{prefix}bar", prefix)
106+
.WithArguments($"{prefix}{prefix}bar", diagnosticPrefix)
105107
.WithLocation(3, 20);
106108

107109
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -125,13 +127,16 @@ public async Task TestMultipleIdenticalPrefixesOnlyAsync(string prefix)
125127
.WithLocation(3, 20);
126128

127129
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
130+
128131
// A code fix is not offered as removing the prefixes would create an empty identifier.
129132
await this.VerifyCSharpFixAsync(testCode, testCode).ConfigureAwait(false);
130133
}
131134

132135
/// <summary>
133136
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#627.
134137
/// </summary>
138+
/// <param name="prefixes">The prefixes to prepend to the variable name.</param>
139+
/// <param name="diagnosticPrefix">The prefix that should be reported in the diagnostic.</param>
135140
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
136141
/// <seealso href="https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/627">#627: Code Fixes For Naming
137142
/// Rules SA1308 and SA1309 Do Not Always Fix The Name Entirely</seealso>
@@ -146,7 +151,7 @@ public async Task TestFixingMultipleDistinctPrefixesAsync(string prefixes, strin
146151

147152
DiagnosticResult expected =
148153
this.CSharpDiagnostic()
149-
.WithArguments($"{prefixes}bar", firstPrefix)
154+
.WithArguments($"{prefixes}bar", diagnosticPrefix)
150155
.WithLocation(3, 20);
151156

152157
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -166,12 +171,13 @@ public async Task TestMultipleDistinctPrefixesOnlyAsync(string prefixes, string
166171

167172
DiagnosticResult expected =
168173
this.CSharpDiagnostic()
169-
.WithArguments(prefixes, firstPrefix)
174+
.WithArguments(prefixes, diagnosticPrefix)
170175
.WithLocation(3, 20);
171176

172177
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
178+
173179
// A code fix is not offered as removing the prefixes would create an empty identifier.
174-
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
180+
await this.VerifyCSharpFixAsync(testCode, testCode).ConfigureAwait(false);
175181
}
176182

177183
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()

0 commit comments

Comments
 (0)