@@ -1016,18 +1016,20 @@ static void GatherForwardedAttributes(
1016
1016
}
1017
1017
}
1018
1018
1019
- // Gather attributes from the method declaration
1020
- GatherForwardedAttributes ( methodSymbol , semanticModel , token , in diagnostics , in fieldAttributesInfo , in propertyAttributesInfo ) ;
1021
-
1022
1019
// If the method is a partial definition, also gather attributes from the implementation part
1023
- if ( methodSymbol is { IsPartialDefinition : true , PartialImplementationPart : { } partialImplementation } )
1020
+ if ( methodSymbol is { IsPartialDefinition : true } or { PartialDefinitionPart : not null } )
1024
1021
{
1022
+ IMethodSymbol partialDefinition = methodSymbol . PartialDefinitionPart ?? methodSymbol ;
1023
+ IMethodSymbol partialImplementation = methodSymbol . PartialImplementationPart ?? methodSymbol ;
1024
+
1025
+ // We always give priority to the partial definition, to ensure a predictable and testable ordering
1026
+ GatherForwardedAttributes ( partialDefinition , semanticModel , token , in diagnostics , in fieldAttributesInfo , in propertyAttributesInfo ) ;
1025
1027
GatherForwardedAttributes ( partialImplementation , semanticModel , token , in diagnostics , in fieldAttributesInfo , in propertyAttributesInfo ) ;
1026
1028
}
1027
- else if ( methodSymbol is { IsPartialDefinition : false , PartialDefinitionPart : { } partialDefinition } )
1029
+ else
1028
1030
{
1029
- // If the method is a partial implementation, also gather attributes from the definition part
1030
- GatherForwardedAttributes ( partialDefinition , semanticModel , token , in diagnostics , in fieldAttributesInfo , in propertyAttributesInfo ) ;
1031
+ // If the method is not a partial definition/ implementation, just gather attributes from the method with no modifications
1032
+ GatherForwardedAttributes ( methodSymbol , semanticModel , token , in diagnostics , in fieldAttributesInfo , in propertyAttributesInfo ) ;
1031
1033
}
1032
1034
1033
1035
fieldAttributes = fieldAttributesInfo . ToImmutable ( ) ;
0 commit comments