Skip to content
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

Exception raised in an async command handler method disables the command though the exception is handled #164

Closed
1 of 4 tasks
egvijayanand opened this issue Mar 17, 2022 · 3 comments
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior fixed in main 🏎️ An issue/feature that has already been fixed/added in main mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects

Comments

@egvijayanand
Copy link

Describe the bug

Using v8.0.0-preview2 MVVM Toolkit NuGet package.

Exception raised in an async command handler method disables the command though the exception is handled.

Have a look at the below code snippet:

The developer is certain about the possibility of an exception, so a try ... catch block is introduced to handle the exception. In this case, the exception is handled, the command should not move into the disabled state and should continue to work as before.

private async Task DoSomething()
{
    try
    {
        // Execute the logic and it raises an exception
    }
    catch (Exception ex)
    {
        // Handle the exception
    }
}

Regression

NA

Steps to reproduce

1. Add the v8.0.0-preview2 version of the MVVM Toolkit NuGet package
2. Add a new class and inherit from ObservableObject
3. Add an async method with a try ... catch construct to handle errors
4. Decorate the method with [ICommand] attribute
5. Verify the Command's CanExecute() method's output before- and after- the exception is raised and handled

Expected behavior

Since the exception is handled by the developer code, the command should not move into the disabled state and continue to work as before.

Screenshots

NA

IDE and version

VS 2022 Preview

IDE version

17.2.0 Preview 2.0

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Additional context

NA

Help us help you

Yes, but only if others can assist

@egvijayanand egvijayanand added the bug 🐛 An unexpected issue that highlights incorrect behavior label Mar 17, 2022
@Sergio0694 Sergio0694 added the mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit label Mar 18, 2022
@Sergio0694
Copy link
Member

Pretty sure this is actually unrelated from the exception, and just caused by the bug in Preview2 that caused async commands with no concurrent execution (which is now the default setting) not to be enabled again after the first execution. This is essentially a duplicate of #149, and was fixed in #139. Could you try with the latest package from our daily feed (https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json) to verify that this works? Thanks! 🙂

@Sergio0694 Sergio0694 added the needs author feedback 📝 This issue or PR needs a reply from the author label Mar 18, 2022
@Sergio0694 Sergio0694 added this to To do in 8.0 via automation Mar 18, 2022
@egvijayanand
Copy link
Author

As communicated, validated it with nightly build 8.0.0-build.94 from the internal CI feed and found it to be working as expected.

Kindly include the fix in the next preview release if it meets other criteria.

@Sergio0694
Copy link
Member

Yup, everything that's on main will go into the next preview release 😄
Closing this as it's resolved then, thank you!

8.0 automation moved this from To do to Done Mar 25, 2022
@Sergio0694 Sergio0694 added fixed in main 🏎️ An issue/feature that has already been fixed/added in main and removed needs author feedback 📝 This issue or PR needs a reply from the author labels Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior fixed in main 🏎️ An issue/feature that has already been fixed/added in main mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
No open projects
8.0
Done
Development

No branches or pull requests

2 participants