@@ -27,33 +27,40 @@ internal static void GetForwardedAttributes(
27
27
{
28
28
using var forwardedAttributeBuilder = ImmutableArrayBuilder < AttributeInfo > . Rent ( ) ;
29
29
30
- // Gather attributes info
31
- foreach ( var attribute in symbol . GetAttributes ( ) )
32
- {
33
- token . ThrowIfCancellationRequested ( ) ;
30
+ var symbolAttributes = symbol . GetAttributes ( ) ;
34
31
35
- // Track the current attribute for forwarding if it is a validation attribute
36
- if ( attribute . AttributeClass ? . InheritsFromFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.ValidationAttribute" ) == true )
32
+ // if attributes contains the [Reactive] attribute, we should not forward any attributes without field targets
33
+ var isReactiveFromPartialProperty = symbol is IPropertySymbol && symbolAttributes . Any ( a => a . AttributeClass ? . HasFullyQualifiedMetadataName ( AttributeDefinitions . ReactiveAttributeType ) == true ) ;
34
+ if ( ! isReactiveFromPartialProperty && symbolAttributes . Length > 1 )
35
+ {
36
+ // Gather attributes info
37
+ foreach ( var attribute in symbolAttributes )
37
38
{
38
- forwardedAttributeBuilder . Add ( AttributeInfo . Create ( attribute ) ) ;
39
- }
39
+ token . ThrowIfCancellationRequested ( ) ;
40
40
41
- // Track the current attribute for forwarding if it is a Json Serialization attribute
42
- if ( attribute . AttributeClass ? . InheritsFromFullyQualifiedMetadataName ( "System.Text.Json.Serialization.JsonAttribute " ) == true )
43
- {
44
- forwardedAttributeBuilder . Add ( AttributeInfo . Create ( attribute ) ) ;
45
- }
41
+ // Track the current attribute for forwarding if it is a validation attribute
42
+ if ( attribute . AttributeClass ? . InheritsFromFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.ValidationAttribute " ) == true )
43
+ {
44
+ forwardedAttributeBuilder . Add ( AttributeInfo . Create ( attribute ) ) ;
45
+ }
46
46
47
- // Also track the current attribute for forwarding if it is of any of the following types:
48
- if ( attribute . AttributeClass ? . HasOrInheritsFromFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.UIHintAttribute" ) == true ||
49
- attribute . AttributeClass ? . HasOrInheritsFromFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.ScaffoldColumnAttribute" ) == true ||
50
- attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.DisplayAttribute" ) == true ||
51
- attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.EditableAttribute" ) == true ||
52
- attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.KeyAttribute" ) == true ||
53
- attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.Runtime.Serialization.DataMemberAttribute" ) == true ||
54
- attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.Runtime.Serialization.IgnoreDataMemberAttribute" ) == true )
55
- {
56
- forwardedAttributeBuilder . Add ( AttributeInfo . Create ( attribute ) ) ;
47
+ // Track the current attribute for forwarding if it is a Json Serialization attribute
48
+ if ( attribute . AttributeClass ? . InheritsFromFullyQualifiedMetadataName ( "System.Text.Json.Serialization.JsonAttribute" ) == true )
49
+ {
50
+ forwardedAttributeBuilder . Add ( AttributeInfo . Create ( attribute ) ) ;
51
+ }
52
+
53
+ // Also track the current attribute for forwarding if it is of any of the following types:
54
+ if ( attribute . AttributeClass ? . HasOrInheritsFromFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.UIHintAttribute" ) == true ||
55
+ attribute . AttributeClass ? . HasOrInheritsFromFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.ScaffoldColumnAttribute" ) == true ||
56
+ attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.DisplayAttribute" ) == true ||
57
+ attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.EditableAttribute" ) == true ||
58
+ attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.ComponentModel.DataAnnotations.KeyAttribute" ) == true ||
59
+ attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.Runtime.Serialization.DataMemberAttribute" ) == true ||
60
+ attribute . AttributeClass ? . HasFullyQualifiedMetadataName ( "System.Runtime.Serialization.IgnoreDataMemberAttribute" ) == true )
61
+ {
62
+ forwardedAttributeBuilder . Add ( AttributeInfo . Create ( attribute ) ) ;
63
+ }
57
64
}
58
65
}
59
66
0 commit comments