Skip to content

Commit 32488f9

Browse files
committed
file scoped namespaces
1 parent 52583e5 commit 32488f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3651
-3716
lines changed

AspNetCoreAnalyzers.Tests/ASP001ParameterNameTests/CodeFix.cs

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
2-
{
3-
using Gu.Roslyn.Asserts;
4-
using Microsoft.CodeAnalysis.CodeFixes;
5-
using Microsoft.CodeAnalysis.Diagnostics;
6-
using NUnit.Framework;
1+
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests;
2+
3+
using Gu.Roslyn.Asserts;
4+
using Microsoft.CodeAnalysis.CodeFixes;
5+
using Microsoft.CodeAnalysis.Diagnostics;
6+
using NUnit.Framework;
77

8-
public static class CodeFix
8+
public static class CodeFix
9+
{
10+
private static readonly DiagnosticAnalyzer Analyzer = new AttributeAnalyzer();
11+
private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic.Create(Descriptors.ASP001ParameterSymbolName);
12+
private static readonly CodeFixProvider Fix = new RenameParameterFix();
13+
14+
[TestCase("\"{value}\"")]
15+
[TestCase("@\"{value}\"")]
16+
[TestCase("\"{value?}\"")]
17+
[TestCase("\"{*value}\"")]
18+
[TestCase("\"{**value}\"")]
19+
[TestCase("\"{value=abc}\"")]
20+
[TestCase("@\"{value?}\"")]
21+
[TestCase("\"api/orders/{value}\"")]
22+
[TestCase("\"api/orders/{value?}\"")]
23+
[TestCase("\"api/orders/{value:alpha}\"")]
24+
[TestCase("\"api/orders/{value:regex(a-(0|1))}\"")]
25+
[TestCase("\"api/orders/{value:regex(^\\\\d{{3}}-\\\\d{{2}}-\\\\d{4}$)}\"")]
26+
public static void WhenHttpGet(string template)
927
{
10-
private static readonly DiagnosticAnalyzer Analyzer = new AttributeAnalyzer();
11-
private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic.Create(Descriptors.ASP001ParameterSymbolName);
12-
private static readonly CodeFixProvider Fix = new RenameParameterFix();
13-
14-
[TestCase("\"{value}\"")]
15-
[TestCase("@\"{value}\"")]
16-
[TestCase("\"{value?}\"")]
17-
[TestCase("\"{*value}\"")]
18-
[TestCase("\"{**value}\"")]
19-
[TestCase("\"{value=abc}\"")]
20-
[TestCase("@\"{value?}\"")]
21-
[TestCase("\"api/orders/{value}\"")]
22-
[TestCase("\"api/orders/{value?}\"")]
23-
[TestCase("\"api/orders/{value:alpha}\"")]
24-
[TestCase("\"api/orders/{value:regex(a-(0|1))}\"")]
25-
[TestCase("\"api/orders/{value:regex(^\\\\d{{3}}-\\\\d{{2}}-\\\\d{4}$)}\"")]
26-
public static void WhenHttpGet(string template)
27-
{
28-
var before = @"
28+
var before = @"
2929
namespace AspBox
3030
{
3131
using Microsoft.AspNetCore.Mvc;
@@ -41,7 +41,7 @@ public IActionResult GetId(string ↓wrong)
4141
}
4242
}".AssertReplace("\"api/orders/{value}\"", template);
4343

44-
var after = @"
44+
var after = @"
4545
namespace AspBox
4646
{
4747
using Microsoft.AspNetCore.Mvc;
@@ -56,13 +56,13 @@ public IActionResult GetId(string value)
5656
}
5757
}
5858
}".AssertReplace("\"api/orders/{value}\"", template);
59-
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
60-
}
59+
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
60+
}
6161

62-
[Test]
63-
public static void WhenRouteAndHttpGetOnMethod()
64-
{
65-
var before = @"
62+
[Test]
63+
public static void WhenRouteAndHttpGetOnMethod()
64+
{
65+
var before = @"
6666
namespace AspBox
6767
{
6868
using Microsoft.AspNetCore.Mvc;
@@ -79,7 +79,7 @@ public IActionResult GetId(string ↓wrong)
7979
}
8080
}";
8181

82-
var after = @"
82+
var after = @"
8383
namespace AspBox
8484
{
8585
using Microsoft.AspNetCore.Mvc;
@@ -95,13 +95,13 @@ public IActionResult GetId(string value)
9595
}
9696
}
9797
}";
98-
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
99-
}
98+
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
99+
}
100100

101-
[Test]
102-
public static void ImplicitSingleParameter()
103-
{
104-
var order = @"
101+
[Test]
102+
public static void ImplicitSingleParameter()
103+
{
104+
var order = @"
105105
namespace AspBox
106106
{
107107
public class Order
@@ -110,7 +110,7 @@ public class Order
110110
}
111111
}";
112112

113-
var db = @"
113+
var db = @"
114114
namespace AspBox
115115
{
116116
using Microsoft.EntityFrameworkCore;
@@ -120,7 +120,7 @@ public class Db : DbContext
120120
public DbSet<Order> Orders => this.Set<Order>();
121121
}
122122
}";
123-
var before = @"
123+
var before = @"
124124
namespace AspBox
125125
{
126126
using System.Threading.Tasks;
@@ -151,7 +151,7 @@ public async Task<IActionResult> GetOrder(int ↓wrong)
151151
}
152152
}";
153153

154-
var after = @"
154+
var after = @"
155155
namespace AspBox
156156
{
157157
using System.Threading.Tasks;
@@ -181,13 +181,13 @@ public async Task<IActionResult> GetOrder(int id)
181181
}
182182
}
183183
}";
184-
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, new[] { order, db, before }, after);
185-
}
184+
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, new[] { order, db, before }, after);
185+
}
186186

187-
[Test]
188-
public static void FirstParameter()
189-
{
190-
var before = @"
187+
[Test]
188+
public static void FirstParameter()
189+
{
190+
var before = @"
191191
namespace AspBox
192192
{
193193
using Microsoft.AspNetCore.Mvc;
@@ -203,7 +203,7 @@ public IActionResult GetOrder(int ↓wrong, int itemId)
203203
}
204204
}";
205205

206-
var after = @"
206+
var after = @"
207207
namespace AspBox
208208
{
209209
using Microsoft.AspNetCore.Mvc;
@@ -218,13 +218,13 @@ public IActionResult GetOrder(int orderId, int itemId)
218218
}
219219
}
220220
}";
221-
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
222-
}
221+
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
222+
}
223223

224-
[Test]
225-
public static void LastParameter()
226-
{
227-
var before = @"
224+
[Test]
225+
public static void LastParameter()
226+
{
227+
var before = @"
228228
namespace AspBox
229229
{
230230
using Microsoft.AspNetCore.Mvc;
@@ -240,7 +240,7 @@ public IActionResult GetOrder(int orderId, int ↓wrong)
240240
}
241241
}";
242242

243-
var after = @"
243+
var after = @"
244244
namespace AspBox
245245
{
246246
using Microsoft.AspNetCore.Mvc;
@@ -255,13 +255,13 @@ public IActionResult GetOrder(int orderId, int itemId)
255255
}
256256
}
257257
}";
258-
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
259-
}
258+
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
259+
}
260260

261-
[Test]
262-
public static void ExplicitFromRouteAttributeSingleParameter()
263-
{
264-
var before = @"
261+
[Test]
262+
public static void ExplicitFromRouteAttributeSingleParameter()
263+
{
264+
var before = @"
265265
namespace AspBox
266266
{
267267
using Microsoft.AspNetCore.Mvc;
@@ -277,7 +277,7 @@ public IActionResult GetId(string ↓wrong)
277277
}
278278
}";
279279

280-
var after = @"
280+
var after = @"
281281
namespace AspBox
282282
{
283283
using Microsoft.AspNetCore.Mvc;
@@ -292,7 +292,6 @@ public IActionResult GetId(string value)
292292
}
293293
}
294294
}";
295-
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
296-
}
295+
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
297296
}
298297
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests
1+
namespace AspNetCoreAnalyzers.Tests.ASP001ParameterNameTests;
2+
3+
using Gu.Roslyn.Asserts;
4+
using Microsoft.CodeAnalysis.Diagnostics;
5+
using NUnit.Framework;
6+
7+
public static class Diagnostics
28
{
3-
using Gu.Roslyn.Asserts;
4-
using Microsoft.CodeAnalysis.Diagnostics;
5-
using NUnit.Framework;
9+
private static readonly DiagnosticAnalyzer Analyzer = new AttributeAnalyzer();
10+
private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic.Create(Descriptors.ASP001ParameterSymbolName);
611

7-
public static class Diagnostics
12+
[Test]
13+
public static void BothParameters()
814
{
9-
private static readonly DiagnosticAnalyzer Analyzer = new AttributeAnalyzer();
10-
private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic.Create(Descriptors.ASP001ParameterSymbolName);
11-
12-
[Test]
13-
public static void BothParameters()
14-
{
15-
var code = @"
15+
var code = @"
1616
namespace AspBox
1717
{
1818
using Microsoft.AspNetCore.Mvc;
@@ -28,7 +28,6 @@ public class OrdersController : Controller
2828
}
2929
}";
3030

31-
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code);
32-
}
31+
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code);
3332
}
3433
}

0 commit comments

Comments
 (0)