New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Validation #3586
Refactor Validation #3586
Conversation
…se always creating error descriptors with only single item in.
…out ErrorDescriptors.
I was OK with the reflection, it was cached. Is Avalonia using the same reflection solution? |
No, you never implement this code inside Avalonia... however Avalonia is removing all reflection code from its code base. Its cached. but the reflection takes place when you want the most performance, when the ui loads. I will see what implementing some kind of naming convention based on reflection looks like. BTW the only advantage is to remove the calls to |
@molnard iv implemented it using reflection and it actually makes it really easy to use... its actually very fast so probably dont need to worry about performance. Basically now if you have a property called |
@danwalmsley as far as i remember the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settings tab doesn't open:
2020-04-27 03:04:14 ERROR ToolCommands (47) System.ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type.
at System.Reflection.RuntimeMethodInfo.CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags)
at System.Reflection.RuntimeMethodInfo.CreateDelegate(Type delegateType, Object target)
at WalletWasabi.Gui.ViewModels.ViewModelBase.RegisterValidationMethods() in C:\Users\RESEAU\Desktop\WalletWasabi\WalletWasabi.Gui\ViewModels\ViewModelBase.cs:line 46
at WalletWasabi.Gui.ViewModels.ViewModelBase..ctor() in C:\Users\RESEAU\Desktop\WalletWasabi\WalletWasabi.Gui\ViewModels\ViewModelBase.cs:line 23
at WalletWasabi.Gui.ViewModels.WasabiDocumentTabViewModel..ctor(String title) in C:\Users\RESEAU\Desktop\WalletWasabi\WalletWasabi.Gui\ViewModels\WasabiDocumentTabViewModel.cs:line 20
at WalletWasabi.Gui.Tabs.SettingsViewModel..ctor() in C:\Users\RESEAU\Desktop\WalletWasabi\WalletWasabi.Gui\Tabs\SettingsViewModel.cs:line 44
at WalletWasabi.Gui.Shell.Commands.ToolCommands.<>c.<.ctor>b__0_4() in C:\Users\RESEAU\Desktop\WalletWasabi\WalletWasabi.Gui\Shell\Commands\ToolCommands.cs:line 30
at AvalonStudio.Shell.IShellExtensions.AddOrSelectDocument[T](IShell me, Func`1 factory)
at WalletWasabi.Gui.Shell.Commands.ToolCommands.<>c.<.ctor>b__0_0() in C:\Users\RESEAU\Desktop\WalletWasabi\WalletWasabi.Gui\Shell\Commands\ToolCommands.cs:line 30
at ReactiveUI.ReactiveCommand.<>c__DisplayClass0_0.<Create>b__1(IObserver`1 observer) in d:\a\1\s\src\ReactiveUI\ReactiveCommand\ReactiveCommand.cs:line 108
at System.Reactive.Linq.QueryLanguage.CreateWithDisposableObservable`1.SubscribeCore(IObserver`1 observer) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\QueryLanguage.Creation.cs:line 35
at System.Reactive.ObservableBase`1.Subscribe(IObserver`1 observer) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\ObservableBase.cs:line 58
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
Outdated
Show resolved
Hide resolved
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
Outdated
Show resolved
Hide resolved
WalletWasabi.Gui/Tabs/WalletManager/RecoverWallets/RecoverWalletViewModel.cs
Outdated
Show resolved
Hide resolved
…ons from binding system.
Co-Authored-By: yahiheb <52379387+yahiheb@users.noreply.github.com>
Co-Authored-By: yahiheb <52379387+yahiheb@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK
4c692ac
…WalletWasabi into refactor/validation
Done some refactoring to support:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Codefactor is yet again showing an issue found, but it doesnt actually exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good! Cheers!
|
Validation is a little bit of a mess and doesnt work in some cases.
I have simplified how validation works, and it will now support mulitple errors on a single property... this was only partially supported previously.
Furthermore you can now prevent commands from executing by observing the "HasErrors" property now and this will work.
I have removed the
[ValidateMethod]
attribute and replaced this with naming convention.Basically now if you have a property called Password and you add a method (public or private) called ValidatePassword(IErrorList errors) it will automagically get called during validation.
The validation logic is all inside ViewModelBase now
@jmacato iv no idea what that ErrorDescriptors to Border converter is doing... can you give some input here.. seems it shouldnt be needed anymore?
Colour converter shouldnt be a source of errors in the UI, so we need to at least refactor it, but I need help with that.
Validation methods went from:
to