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
123123 System_ComponentModel_DataAnnotations_ValidationAttribute ,
124124 System_ComponentModel_DataAnnotations_RequiredAttribute ,
125125 System_ComponentModel_DataAnnotations_CustomValidationAttribute ,
126+ System_Type ,
126127 }
127128
128129 public static string [ ] WellKnownTypeNames =
@@ -243,5 +244,6 @@ public enum WellKnownType
243244 "System.ComponentModel.DataAnnotations.ValidationAttribute" ,
244245 "System.ComponentModel.DataAnnotations.RequiredAttribute" ,
245246 "System.ComponentModel.DataAnnotations.CustomValidationAttribute" ,
247+ "System.Type" ,
246248 ] ;
247249}
Original file line number Diff line number Diff line change 33
44using System ;
55using System . Linq ;
6+ using Microsoft . AspNetCore . App . Analyzers . Infrastructure ;
67using Microsoft . CodeAnalysis ;
78
89namespace Microsoft . Extensions . Validation ;
@@ -32,4 +33,9 @@ attribute.AttributeClass is { } attributeClass &&
3233
3334 return property . Name ;
3435 }
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 ;
3541}
Original file line number Diff line number Diff line change @@ -162,7 +162,9 @@ internal ImmutableArray<ValidatableProperty> ExtractValidatableMembers(ITypeSymb
162162 {
163163 // Skip compiler generated properties and properties already processed via
164164 // 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 ) )
166168 {
167169 continue ;
168170 }
You can’t perform that action at this time.
0 commit comments