File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ protected ObservableValidator(ValidationContext validationContext)
123
123
}
124
124
125
125
/// <inheritdoc/>
126
+ [ Display ( AutoGenerateField = false ) ]
126
127
public bool HasErrors => this . totalErrors > 0 ;
127
128
128
129
/// <summary>
Original file line number Diff line number Diff line change @@ -607,7 +607,20 @@ public void Test_ObservableValidator_ValidateAllProperties_IncludeInheritedPrope
607
607
Assert . IsFalse ( model . HasErrors ) ;
608
608
Assert . IsTrue ( events . Count == 1 ) ;
609
609
610
- Assert . IsTrue ( events . Any ( e => e . PropertyName == nameof ( DerivedModelWithValidatableProperties . Name ) ) ) ; }
610
+ Assert . IsTrue ( events . Any ( e => e . PropertyName == nameof ( DerivedModelWithValidatableProperties . Name ) ) ) ;
611
+ }
612
+
613
+ // See https://github.com/CommunityToolkit/dotnet/issues/881
614
+ [ TestMethod ]
615
+ public void Test_ObservableValidator_HasErrors_IncludeNonAutogenerateAttribute ( )
616
+ {
617
+ DerivedModelWithValidatableProperties model = new ( ) ;
618
+
619
+ DisplayAttribute ? displayAttribute = model . GetType ( ) . GetProperty ( nameof ( ObservableValidator . HasErrors ) ) ? . GetCustomAttribute < DisplayAttribute > ( ) ;
620
+
621
+ Assert . IsNotNull ( displayAttribute ) ;
622
+ Assert . IsFalse ( displayAttribute . AutoGenerateField ) ;
623
+ }
611
624
612
625
public class Person : ObservableValidator
613
626
{
You can’t perform that action at this time.
0 commit comments