@@ -99,6 +99,7 @@ public sealed class MinimalApiGenerator : IIncrementalGenerator
9999 private const string UseEndpointHandlersMethodName = "MapEndpointHandlers" ;
100100 private const string UseEndpointHandlersMethodHint = $ "{ RoutingNamespace } .{ UseEndpointHandlersMethodName } .g.cs";
101101
102+ private const string ConfigureMethodName = "Configure" ;
102103 private const string AsyncSuffix = "Async" ;
103104
104105 private static readonly string FileHeader = $ """
@@ -852,7 +853,7 @@ ref List<ProducesValidationProblemMetadata>? producesValidationProblem
852853 ? GetStringArrayValues ( attribute . ConstructorArguments [ 2 ] )
853854 : null ;
854855
855- var producesProblemList = producesProblem ??= new List < ProducesProblemMetadata > ( ) ;
856+ var producesProblemList = producesProblem ??= [ ] ;
856857 producesProblemList . Add ( new ProducesProblemMetadata ( statusCode , contentType , additionalContentTypes ) ) ;
857858 break ;
858859 }
@@ -868,7 +869,7 @@ ref List<ProducesValidationProblemMetadata>? producesValidationProblem
868869 ? GetStringArrayValues ( attribute . ConstructorArguments [ 2 ] )
869870 : null ;
870871
871- var producesValidationProblemList = producesValidationProblem ??= new List < ProducesValidationProblemMetadata > ( ) ;
872+ var producesValidationProblemList = producesValidationProblem ??= [ ] ;
872873 producesValidationProblemList . Add ( new ProducesValidationProblemMetadata ( statusCode , contentType , additionalContentTypes ) ) ;
873874 break ;
874875 }
@@ -923,12 +924,12 @@ private static void TryAddAcceptsMetadata(
923924 INamedTypeSymbol attributeClass ,
924925 ref List < AcceptsMetadata > ? accepts )
925926 {
926- string ? requestType = null ;
927+ string ? requestType ;
927928 string contentType ;
928929 EquatableImmutableArray < string > ? additionalContentTypes ;
929930 var isOptional = GetNamedBoolValue ( attribute , IsOptionalAttributeNamedParameter ) ;
930931
931- if ( attributeClass . IsGenericType && attributeClass . TypeArguments . Length == 1 )
932+ if ( attributeClass is { IsGenericType : true , TypeArguments . Length : 1 } )
932933 {
933934 requestType = attributeClass . TypeArguments [ 0 ] . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ;
934935 contentType = attribute . ConstructorArguments . Length > 0
@@ -953,7 +954,7 @@ private static void TryAddAcceptsMetadata(
953954 return ;
954955 }
955956
956- var acceptsList = accepts ??= new List < AcceptsMetadata > ( ) ;
957+ var acceptsList = accepts ??= [ ] ;
957958 acceptsList . Add ( new AcceptsMetadata ( requestType , contentType , additionalContentTypes , isOptional ) ) ;
958959 }
959960
@@ -962,12 +963,12 @@ private static void TryAddProducesMetadata(
962963 INamedTypeSymbol attributeClass ,
963964 ref List < ProducesMetadata > ? produces )
964965 {
965- string ? responseType = null ;
966+ string ? responseType ;
966967 int statusCode ;
967968 string ? contentType ;
968969 EquatableImmutableArray < string > ? additionalContentTypes ;
969970
970- if ( attributeClass . IsGenericType && attributeClass . TypeArguments . Length == 1 )
971+ if ( attributeClass is { IsGenericType : true , TypeArguments . Length : 1 } )
971972 {
972973 responseType = attributeClass . TypeArguments [ 0 ] . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ;
973974 statusCode = attribute . ConstructorArguments . Length > 0 && attribute . ConstructorArguments [ 0 ] . Value is int producesStatusCode
@@ -998,7 +999,7 @@ private static void TryAddProducesMetadata(
998999 return ;
9991000 }
10001001
1001- var producesList = produces ??= new List < ProducesMetadata > ( ) ;
1002+ var producesList = produces ??= [ ] ;
10021003 producesList . Add ( new ProducesMetadata ( responseType , statusCode , contentType , additionalContentTypes ) ) ;
10031004 }
10041005
@@ -1102,7 +1103,7 @@ CancellationToken cancellationToken
11021103 var hasConfigureMethod = false ;
11031104 var acceptsServiceProvider = false ;
11041105
1105- foreach ( var member in classSymbol . GetMembers ( "Configure" ) )
1106+ foreach ( var member in classSymbol . GetMembers ( ConfigureMethodName ) )
11061107 {
11071108 cancellationToken . ThrowIfCancellationRequested ( ) ;
11081109
@@ -1426,7 +1427,9 @@ private static void GenerateMapRequestHandler(StringBuilder source, RequestHandl
14261427 {
14271428 source . Append ( " " ) ;
14281429 source . Append ( requestHandler . Class . Name ) ;
1429- source . AppendLine ( ".Configure(" ) ;
1430+ source . Append ( '.' ) ;
1431+ source . Append ( ConfigureMethodName ) ;
1432+ source . AppendLine ( "(" ) ;
14301433 }
14311434
14321435 source . Append ( indent ) ;
0 commit comments