You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
If a user invokes an async validator synchronously (either by calling Validate, or by using auto-validation in ASP.NET), then the validator will silently end up being run synchronously. This is not easily detectable and leads to bugs and potential deadlocks.
Describe the solution you'd like
Ideally, this should be caught at compile-time by having 2 base classes (a sync and an async version), but multiple attempts to build this have failed because of the complexity as well as the number of breaking changes that this would introduce. Instead, I'm proposing the following:
Step 1
Validators would be modified so that they throw an exception if an async rule is executed synchronously. While not as good as a compile-time error, this will at least surface the problem. This is a major change of behaviour, so would only be done in a major version release (11.0).
Step 2
Investigate whether it's possible to enable async validation in ASP.NET some other way.
Also investigate switching to a filter-based implementation to perform validation, rather than using the ModelValidatorProvider api.
Step 3
If step 2 is possible and we can reliably implement async validation in aspnet projects, then synchronous validation should be deprecated, and eventually removed, with the intention that all validators only offer ValidateAsync as the entrypoint. For users who are unable to call FV from inside an async method, they can manually call GetAwaiter().GetResult() themselves, rather than the library doing this for them.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
If a user invokes an async validator synchronously (either by calling
Validate
, or by using auto-validation in ASP.NET), then the validator will silently end up being run synchronously. This is not easily detectable and leads to bugs and potential deadlocks.Describe the solution you'd like
Ideally, this should be caught at compile-time by having 2 base classes (a sync and an async version), but multiple attempts to build this have failed because of the complexity as well as the number of breaking changes that this would introduce. Instead, I'm proposing the following:
Step 1
Validators would be modified so that they throw an exception if an async rule is executed synchronously. While not as good as a compile-time error, this will at least surface the problem. This is a major change of behaviour, so would only be done in a major version release (11.0).
Step 2
Investigate whether it's possible to enable async validation in ASP.NET some other way.
Step 3
ValidateAsync
as the entrypoint. For users who are unable to call FV from inside an async method, they can manually callGetAwaiter().GetResult()
themselves, rather than the library doing this for them.The text was updated successfully, but these errors were encountered: