@@ -11,17 +11,12 @@ public class CodeFix
1111 private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic . Create ( ASP004ParameterSyntax . Descriptor ) ;
1212 private static readonly CodeFixProvider Fix = new TemplateTextFix ( ) ;
1313
14- [ TestCase ( "api/orders/↓id:long}" , "api/orders/{id:long}" ) ]
15- [ TestCase ( "api/orders/↓{id:long" , "api/orders/{id:long}" ) ]
16- [ TestCase ( "api/orders/{id:min(1}" , "api/orders/{id:min(1)}" ) ]
17- [ TestCase ( "api/orders/{id:max(1}" , "api/orders/{id:max(1)}" ) ]
18- [ TestCase ( "api/orders/{id:minlength(1}" , "api/orders/{id:minlength(1)}" ) ]
19- [ TestCase ( "api/orders/{id:maxlength(1}" , "api/orders/{id:maxlength(1)}" ) ]
20- [ TestCase ( "api/orders/{id:length(1}" , "api/orders/{id:length(1)}" ) ]
21- [ TestCase ( "api/orders/{id:length(1,2}" , "api/orders/{id:length(1,2)}" ) ]
22- [ TestCase ( "api/orders/{id:range(1,2}" , "api/orders/{id:range(1,2)}" ) ]
23- [ TestCase ( "api/orders/{id:regex((a|b)-c}" , "api/orders/{id:regex((a|b)-c)}" ) ]
24- public void When ( string before , string after )
14+ [ TestCase ( "api/orders/↓id:long}" , "api/orders/{id:long}" ) ]
15+ [ TestCase ( "api/orders/↓{id:long" , "api/orders/{id:long}" ) ]
16+ [ TestCase ( "api/orders/{id:min(1}" , "api/orders/{id:min(1)}" ) ]
17+ [ TestCase ( "api/orders/{id:max(1}" , "api/orders/{id:max(1)}" ) ]
18+ [ TestCase ( "api/orders/{id:range(1,2}" , "api/orders/{id:range(1,2)}" ) ]
19+ public void WhenLong ( string before , string after )
2520 {
2621 var code = @"
2722namespace ValidCode
@@ -56,5 +51,48 @@ public IActionResult GetId(long id)
5651}" . AssertReplace ( "api/orders/{id:long}" , after ) ;
5752 AnalyzerAssert . CodeFix ( Analyzer , Fix , ExpectedDiagnostic , code , fixedCode ) ;
5853 }
54+
55+ [ TestCase ( "\" api/orders/{id:↓minlength(1}\" " , "\" api/orders/{id:minlength(1)}\" " ) ]
56+ [ TestCase ( "\" api/orders/{id:↓maxlength(1}\" " , "\" api/orders/{id:maxlength(1)}\" " ) ]
57+ [ TestCase ( "\" api/orders/{id:↓length(1}\" " , "\" api/orders/{id:length(1)}\" " ) ]
58+ [ TestCase ( "\" api/orders/{id:↓length(1,2}\" " , "\" api/orders/{id:length(1,2)}\" " ) ]
59+ [ TestCase ( "\" api/orders/{id:↓regex((a|b)-c}\" " , "\" api/orders/{id:regex((a|b)-c)}\" " ) ]
60+ [ TestCase ( "\" api/orders/{id:regex(\\ \\ d+):↓length(1}\" " , "\" api/orders/{id:regex(\\ \\ d+):length(1)}\" " ) ]
61+ public void WhenString ( string before , string after )
62+ {
63+ var code = @"
64+ namespace ValidCode
65+ {
66+ using Microsoft.AspNetCore.Mvc;
67+
68+ [ApiController]
69+ public class OrdersController : Controller
70+ {
71+ [HttpGet(""api/orders/{id}"")]
72+ public IActionResult GetId(string id)
73+ {
74+ return this.Ok(id);
75+ }
76+ }
77+ }" . AssertReplace ( "\" api/orders/{id}\" " , before ) ;
78+
79+ var fixedCode = @"
80+ namespace ValidCode
81+ {
82+ using Microsoft.AspNetCore.Mvc;
83+
84+ [ApiController]
85+ public class OrdersController : Controller
86+ {
87+ [HttpGet(""api/orders/{id}"")]
88+ public IActionResult GetId(string id)
89+ {
90+ return this.Ok(id);
91+ }
92+ }
93+ }" . AssertReplace ( "\" api/orders/{id}\" " , after ) ;
94+
95+ AnalyzerAssert . CodeFix ( Analyzer , Fix , ExpectedDiagnostic , code , fixedCode ) ;
96+ }
5997 }
6098}
0 commit comments