File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Microsoft.Toolkit.Mvvm/ComponentModel
UnitTests/UnitTests.NetCore/Mvvm Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -489,12 +489,13 @@ static Action<object> GetValidationAction(Type type)
489
489
static Action < object > GetValidationActionFallback ( Type type )
490
490
{
491
491
// Get the collection of all properties to validate
492
- PropertyInfo [ ] validatableProperties = (
492
+ ( string Name , MethodInfo GetMethod ) [ ] validatableProperties = (
493
493
from property in type . GetProperties ( BindingFlags . Instance | BindingFlags . Public )
494
494
where property . GetIndexParameters ( ) . Length == 0 &&
495
- property . GetCustomAttributes < ValidationAttribute > ( true ) . Any ( ) &&
496
- property . GetMethod is not null
497
- select property ) . ToArray ( ) ;
495
+ property . GetCustomAttributes < ValidationAttribute > ( true ) . Any ( )
496
+ let getMethod = property . GetMethod
497
+ where getMethod is not null
498
+ select ( property . Name , getMethod ) ) . ToArray ( ) ;
498
499
499
500
// Short path if there are no properties to validate
500
501
if ( validatableProperties . Length == 0 )
Original file line number Diff line number Diff line change 12
12
using Microsoft . Toolkit . Mvvm . ComponentModel ;
13
13
using Microsoft . VisualStudio . TestTools . UnitTesting ;
14
14
15
- #pragma warning disable SA1124
15
+ #pragma warning disable SA1124 , SA1307 , SA1401
16
16
17
17
#nullable enable
18
18
@@ -371,7 +371,7 @@ public partial class ModelWithValuePropertyWithValidation : ObservableValidator
371
371
[ MinLength ( 5 ) ]
372
372
private string ? value ;
373
373
}
374
-
374
+
375
375
public partial class ViewModelWithValidatableGeneratedProperties : ObservableValidator
376
376
{
377
377
[ Required ]
You can’t perform that action at this time.
0 commit comments