File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ public enum WellKnownType
123
123
System_ComponentModel_DataAnnotations_ValidationAttribute ,
124
124
System_ComponentModel_DataAnnotations_RequiredAttribute ,
125
125
System_ComponentModel_DataAnnotations_CustomValidationAttribute ,
126
+ System_Type ,
126
127
}
127
128
128
129
public static string [ ] WellKnownTypeNames =
@@ -243,5 +244,6 @@ public enum WellKnownType
243
244
"System.ComponentModel.DataAnnotations.ValidationAttribute" ,
244
245
"System.ComponentModel.DataAnnotations.RequiredAttribute" ,
245
246
"System.ComponentModel.DataAnnotations.CustomValidationAttribute" ,
247
+ "System.Type" ,
246
248
] ;
247
249
}
Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Linq ;
6
+ using Microsoft . AspNetCore . App . Analyzers . Infrastructure ;
6
7
using Microsoft . CodeAnalysis ;
7
8
8
9
namespace Microsoft . Extensions . Validation ;
@@ -32,4 +33,9 @@ attribute.AttributeClass is { } attributeClass &&
32
33
33
34
return property . Name ;
34
35
}
36
+
37
+ public static bool IsEqualityContract ( this IPropertySymbol prop , WellKnownTypes wellKnownTypes ) =>
38
+ prop . Name == "EqualityContract"
39
+ && SymbolEqualityComparer . Default . Equals ( prop . Type , wellKnownTypes . Get ( WellKnownTypeData . WellKnownType . System_Type ) )
40
+ && prop . DeclaredAccessibility == Accessibility . Protected ;
35
41
}
Original file line number Diff line number Diff line change @@ -162,7 +162,9 @@ internal ImmutableArray<ValidatableProperty> ExtractValidatableMembers(ITypeSymb
162
162
{
163
163
// Skip compiler generated properties and properties already processed via
164
164
// the record processing logic above.
165
- if ( member . IsImplicitlyDeclared || resolvedRecordProperty . Contains ( member , SymbolEqualityComparer . Default ) )
165
+ if ( member . IsImplicitlyDeclared
166
+ || member . IsEqualityContract ( wellKnownTypes )
167
+ || resolvedRecordProperty . Contains ( member , SymbolEqualityComparer . Default ) )
166
168
{
167
169
continue ;
168
170
}
You can’t perform that action at this time.
0 commit comments