riganti / dotvvm

Open source MVVM framework for Web Apps
https://www.dotvvm.com
Apache License 2.0
743 stars 97 forks source link

ExceptionFilterAttribute is not applied to commands in controls #1042

Open mrnustik opened 3 years ago

mrnustik commented 3 years ago

When I pass a command to a markup control as a property the ExceptionFilterAttribute.OnCommandExceptionAsync method is not called when an exception occurs.

DotvvmApplication10.zip

exyi commented 3 years ago

We tried to fix this issue today with @acizmarik, but it was harder than expected. Let me briefly explain what are the problems:

To fix this, we basically need to put the ICommandFilter handling into the command binding expression. Ideally, to emulate what static commands are already doing, we'd handle the filters around each invoked method. However, this is quite problematic since the filter is asynchronous. We'd have to be able to put something like await into the expression, which is hard to do with Linq.Expressions. There is a library for that (DotNext.Metaprogramming), but it does not support net451. And the command delegate does not actually have to be async, so this might be impossible. We could also hack around the problem by putting Task.Result into it, but this also causes problems on net451.

I'm not sure we will ever fix this problem. Rather, we'd like to get rid of attributes on commands, since it suffers from many similar problems (for example, the attributes are ignored on virtual methods)