-
-
Notifications
You must be signed in to change notification settings - Fork 402
Open
Description
Describe the bug
I upgraded to the latest version of CSLA and found a bug in ViewModelBase. When I try to load the BusinessBase, the SetProperties method calls BusinessRules.HasPermission. However, it should call BusinessRules.HasPermissionAsync to work with the new implementation.
Version and Platform
CSLA version: 9.0.0
OS: Windows
Platform: WPF
Code that Fails
ViewModelBase.cs
private void SetProperties()
Stack Trace or Exception Detail
Specified argument was out of the range of valid values.
private static bool HasPermission(AuthorizationActions action, object? obj, ApplicationContext applicationContext, Type objType, object?[]? criteria, string? ruleSet)
{
...
if (rule is IAuthorizationRule sync)
{
...
}
else
-->>> throw new ArgumentOutOfRangeException(rule.GetType().FullName);
}
return result;
}
Additional context
private void SetProperties()
{
bool isObjectBusy = false;
if (Model is INotifyBusy busyObject && busyObject.IsBusy)
isObjectBusy = true;
// Does Model instance implement ITrackStatus
if (Model is ITrackStatus targetObject)
{
var canDeleteInstance = BusinessRules.HasPermission(ApplicationContext, AuthorizationActions.DeleteObject, targetObject);
The SetProperties method and other calls in the ViewModel should be updated to call HasPermissionAsync. Since HasPermissionAsync is asynchronous, replacing the synchronous calls, could cause issues??