@@ -142,16 +142,16 @@ private void ProcessEndpointParameterSource(Endpoint endpoint, ISymbol symbol, I
142
142
}
143
143
if ( symbol is IPropertySymbol ||
144
144
Type is not INamedTypeSymbol namedTypeSymbol ||
145
- ! TryGetAsParametersConstructor ( endpoint , namedTypeSymbol , out var isParameterlessConstructor , out var matchedParameters ) )
145
+ ! TryGetAsParametersConstructor ( endpoint , namedTypeSymbol , out var isDefaultConstructor , out var matchedProperties ) )
146
146
{
147
147
if ( symbol is IPropertySymbol )
148
148
{
149
149
endpoint . Diagnostics . Add ( Diagnostic . Create ( DiagnosticDescriptors . InvalidAsParametersNested , location ) ) ;
150
150
}
151
151
return ;
152
152
}
153
- EndpointParameters = matchedParameters . Select ( matchedParameter => new EndpointParameter ( endpoint , matchedParameter . Property , matchedParameter . Parameter , wellKnownTypes ) ) ;
154
- if ( isParameterlessConstructor == true )
153
+ EndpointParameters = matchedProperties . Select ( matchedParameter => new EndpointParameter ( endpoint , matchedParameter . Property , matchedParameter . Parameter , wellKnownTypes ) ) ;
154
+ if ( isDefaultConstructor == true )
155
155
{
156
156
var parameterList = string . Join ( ", " , EndpointParameters . Select ( p => $ "{ p . LookupName } = { p . EmitHandlerArgument ( ) } ") ) ;
157
157
AssigningCode = $ "new { namedTypeSymbol . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) } {{ { parameterList } }}";
@@ -471,10 +471,10 @@ private static string GetEscapedParameterName(AttributeData attribute, string pa
471
471
}
472
472
}
473
473
474
- private static bool TryGetAsParametersConstructor ( Endpoint endpoint , INamedTypeSymbol type , out bool ? isParameterlessConstructor , [ NotNullWhen ( true ) ] out IEnumerable < ConstructorParameter > ? matchedParameters )
474
+ private static bool TryGetAsParametersConstructor ( Endpoint endpoint , INamedTypeSymbol type , out bool ? isDefaultConstructor , [ NotNullWhen ( true ) ] out IEnumerable < ConstructorParameter > ? matchedProperties )
475
475
{
476
- isParameterlessConstructor = null ;
477
- matchedParameters = null ;
476
+ isDefaultConstructor = null ;
477
+ matchedProperties = null ;
478
478
var parameterTypeString = type . ToDisplayString ( SymbolDisplayFormat . CSharpShortErrorMessageFormat ) ;
479
479
var location = endpoint . Operation . Syntax . GetLocation ( ) ;
480
480
if ( type . IsAbstract )
@@ -492,7 +492,7 @@ private static bool TryGetAsParametersConstructor(Endpoint endpoint, INamedTypeS
492
492
493
493
if ( numOfConstructors == 1 )
494
494
{
495
- var targetConstructor = constructors . SingleOrDefault ( ) ;
495
+ var targetConstructor = constructors . Single ( ) ;
496
496
var lookupTable = new Dictionary < ParameterLookupKey , IPropertySymbol > ( ) ;
497
497
foreach ( var property in properties )
498
498
{
@@ -504,8 +504,8 @@ private static bool TryGetAsParametersConstructor(Endpoint endpoint, INamedTypeS
504
504
505
505
if ( parameters . Length == 0 )
506
506
{
507
- isParameterlessConstructor = true ;
508
- matchedParameters = writableProperties . Select ( property => new ConstructorParameter ( property , null ) ) ;
507
+ isDefaultConstructor = true ;
508
+ matchedProperties = writableProperties . Select ( property => new ConstructorParameter ( property , null ) ) ;
509
509
return true ;
510
510
}
511
511
@@ -523,15 +523,15 @@ private static bool TryGetAsParametersConstructor(Endpoint endpoint, INamedTypeS
523
523
}
524
524
}
525
525
526
- isParameterlessConstructor = false ;
527
- matchedParameters = propertiesWithParameterInfo ;
526
+ isDefaultConstructor = false ;
527
+ matchedProperties = propertiesWithParameterInfo ;
528
528
return true ;
529
529
}
530
530
531
531
if ( type . IsValueType )
532
532
{
533
- isParameterlessConstructor = true ;
534
- matchedParameters = writableProperties . Select ( property => new ConstructorParameter ( property , null ) ) ;
533
+ isDefaultConstructor = true ;
534
+ matchedProperties = writableProperties . Select ( property => new ConstructorParameter ( property , null ) ) ;
535
535
return true ;
536
536
}
537
537
0 commit comments