Skip to content

Preview 5 breaks previously working code. AsyncRelayCommand generates exception. #3791

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

Closed
Noemata opened this issue Feb 26, 2021 · 3 comments
Labels
mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package not an issue ❌ An issue that is beyond the scope of Windows Community Toolkit

Comments

@Noemata
Copy link

Noemata commented Feb 26, 2021

If you upgrade the UWP app at this repo to Preview 5, AsyncRelayCommand generates a missing method exception:

https://github.com/Noemata/SimpleMVVM

Look at CredentialsListViewModel.cs and its corresponding view.

        public AsyncRelayCommand<Credential> DeleteCommand { get; }

I've regressed the project back to Preview 4 to keep things working.

@Sergio0694 Sergio0694 transferred this issue from CommunityToolkit/MVVM-Samples Feb 27, 2021
@ghost ghost added the needs triage 🔍 label Feb 27, 2021
@ghost
Copy link

ghost commented Feb 27, 2021

Hello Noemata, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@Sergio0694 Sergio0694 added mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package not an issue ❌ An issue that is beyond the scope of Windows Community Toolkit and removed needs triage 🔍 labels Feb 27, 2021
@Sergio0694
Copy link
Member

Hi @Noemata! I've tests this in the sample app you provided, and the crash you were seeing by caused by an incorrect setup of NuGet packages in your various projects. Specifically, if you only upgraded to 7.0.0-Preview5 in some projects but not all, it means that thosse on Preview4 were being built targeting a constructor for AsyncRelayCommand that I removed in #3562, but then those were loaded at runtime into the main application that resolved the Preview5 assembly (as it was the highest version compatible with those package resolution rules). Then the code from those projects on Preview4 tried to load up that constructor and crashed, because it was no longer there. Basically, I changed a parameter from a Func<T, bool> to a Predicate<T>, which is not source-breaking, but it is binary-breaking, as was the case here. The fix is to simply upgrade all your references to the MVVM Toolkit to Preview5, to ensure all the projects in your solution are built targeting the latest assembly for the library 🙂

Bonus: you might also want to remove that Microsoft.Bcl.AsyncInterfaces 1.1.1 reference that you have in one of your projects, as that's causing a package downgrade. The MVVM Toolkit already adds an indirect reference to Microsoft.Bcl.AsyncInterfaces 5.0.0, so you don't need that explicit reference, or at least, you shouldn't use one from a lower version (in fact VS also displays a warning if you do that).

Closing this as it's not an issue with the MVVM Toolkit per se, have a nice day! 😊

@Noemata
Copy link
Author

Noemata commented Feb 27, 2021

@Sergio0694 , you are so right! I completely forgot to update the .Net Standard parts of the project. DOH! Sorry to have wasted your time on my super dumb mistake. Thank you very much for taking a close look and filling me in on the details. I really like your work by the way. I was wondering if you had any thoughts on the attribute approach I'm using to automagically register viewmodels? I think this idea could be extended a little.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package not an issue ❌ An issue that is beyond the scope of Windows Community Toolkit
Projects
None yet
Development

No branches or pull requests

2 participants