@@ -195,7 +195,7 @@ public class Customer
195195}
196196""" ;
197197
198- var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsableOrBindable )
198+ var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsable )
199199 . WithArguments ( "customer" , "Customer" )
200200 . WithLocation ( 0 ) ;
201201
@@ -218,7 +218,7 @@ public class Customer
218218}
219219""" ;
220220
221- var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsableOrBindable )
221+ var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsable )
222222 . WithArguments ( "customer" , "Customer" )
223223 . WithLocation ( 0 ) ;
224224
@@ -289,7 +289,7 @@ public static bool TryParse(string s, IFormatProvider provider, out Customer res
289289 }
290290
291291 [ Fact ]
292- public async Task Route_Parameter_withBindAsyncMethodThatReturnsTask_of_T_Fails ( )
292+ public async Task Route_Parameter_withBindAsyncMethod_Fails ( )
293293 {
294294 // Arrange
295295 var source = $$ """
@@ -301,14 +301,14 @@ public async Task Route_Parameter_withBindAsyncMethodThatReturnsTask_of_T_Fails(
301301
302302public class Customer
303303{
304- public async static Task <Customer> BindAsync(HttpContext context)
304+ public async static ValueTask <Customer> BindAsync(HttpContext context)
305305 {
306306 return new Customer();
307307 }
308308}
309309""" ;
310310
311- var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . BindAsyncSignatureMustReturnValueTaskOfT )
311+ var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsable )
312312 . WithArguments ( "customer" , "Customer" )
313313 . WithLocation ( 0 ) ;
314314
@@ -422,7 +422,7 @@ public static bool TryParse(string s, IFormatProvider provider, out Customer res
422422 }
423423
424424 [ Fact ]
425- public async Task Route_Parameter_withHttpContextBindableComplexType_viaImplicitIBindableFromHttp_Works ( )
425+ public async Task Route_Parameter_withHttpContextBindableComplexType_viaImplicitIBindableFromHttp_Fails ( )
426426 {
427427 // Arrange
428428 var source = $$ """
@@ -433,7 +433,7 @@ public async Task Route_Parameter_withHttpContextBindableComplexType_viaImplicit
433433using Microsoft.AspNetCore.Http;
434434
435435var webApp = WebApplication.Create();
436- webApp.MapGet("/customers/{customer}", (Customer customer) => {});
436+ webApp.MapGet("/customers/{customer}", ({|#0: Customer customer|} ) => {});
437437
438438public class Customer : IBindableFromHttpContext<Customer>
439439{
@@ -444,12 +444,16 @@ public class Customer : IBindableFromHttpContext<Customer>
444444}
445445""" ;
446446
447+ var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsable )
448+ . WithArguments ( "customer" , "Customer" )
449+ . WithLocation ( 0 ) ;
450+
447451 // Act
448- await VerifyCS . VerifyAnalyzerAsync ( source ) ;
452+ await VerifyCS . VerifyAnalyzerAsync ( source , expectedDiagnostic ) ;
449453 }
450454
451455 [ Fact ]
452- public async Task Route_Parameter_withHttpContextBindableComplexType_viaExplicitIBindableFromHttp_Works ( )
456+ public async Task Route_Parameter_withHttpContextBindableComplexType_viaExplicitIBindableFromHttp_Fails ( )
453457 {
454458 // Arrange
455459 var source = $$ """
@@ -460,7 +464,7 @@ public async Task Route_Parameter_withHttpContextBindableComplexType_viaExplicit
460464using Microsoft.AspNetCore.Http;
461465
462466var webApp = WebApplication.Create();
463- webApp.MapGet("/customers/{customer}", (Customer customer) => {});
467+ webApp.MapGet("/customers/{customer}", ({|#0: Customer customer|} ) => {});
464468
465469public class Customer : IBindableFromHttpContext<Customer>
466470{
@@ -471,8 +475,12 @@ public class Customer : IBindableFromHttpContext<Customer>
471475}
472476""" ;
473477
478+ var expectedDiagnostic = new DiagnosticResult ( DiagnosticDescriptors . RouteParameterComplexTypeIsNotParsable )
479+ . WithArguments ( "customer" , "Customer" )
480+ . WithLocation ( 0 ) ;
481+
474482 // Act
475- await VerifyCS . VerifyAnalyzerAsync ( source ) ;
483+ await VerifyCS . VerifyAnalyzerAsync ( source , expectedDiagnostic ) ;
476484 }
477485
478486 [ Fact ]
0 commit comments