Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@corvinsz
Copy link

GitHub Issue (If applicable): -

PR Type

What kind of change does this PR introduce?

  • Refactoring (no functional changes, no api changes)

What is the current behavior?

Currently the ICommand properties are not source generated.

What is the new behavior?

The ICommand properties are being source generated.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Associated with an issue (GitHub or internal)

Other information

I recently created an uno project using the templates you guys provide via https://new.platform.uno/.
I noticed when selecting the MVVM pattern, it does not utilize the RelayCommandAttribute from the CommunityToolkit.Mvvm.
Unless there are uno specific limitations or guidelines I'm not aware of, I don't see a reason to not use the source generated property.

I'm new to uno, so bear with me if what I'm proposing is total nonsense.

@CLAassistant
Copy link

CLAassistant commented Mar 28, 2025

CLA assistant check
All committers have signed the CLA.

@DevTKSS
Copy link
Contributor

DevTKSS commented May 18, 2025

@corvinsz did you also get the observable Properties working? I just could decide between compiler telling me I would try to use reflection and should use aot compartble definition or it wanted me to use the .net 9 fields... Like I tryed every community Toolkit described scenario for them and nothing was not giving me a warning.
Why did you change the names of them? I mean the Login to "DoLogin" and so on... That would not be anything I would expect...

@corvinsz
Copy link
Author

corvinsz commented May 20, 2025

@DevTKSS I assume you mean using the new partial properties which got released with .NET 9? I have not tried that, no.

Why did you change the names of them? I mean the Login to "DoLogin" and so on... That would not be anything I would expect...

I changed the command-bindings from Login to DoLogin because that's how the source generator works. The method is called DoLogin and applying the CommunityToolkit.MVVM attribute [RelayCommand] to it generates an ICommand (or an async version of that) which is called <Method name>Command.

Does this answer your question?

@DevTKSS
Copy link
Contributor

DevTKSS commented May 20, 2025

Oh that's interesting! Did not recognize this detail so far on the command and relay commands...
For the property attribute, I am struggling how this would be used in uno mvvm app but would not result in a complaining Compiler.
Following the community Toolkit mvvm gallery guidance, I tryed out all of them and the ones intellisence did tell but might be that I did it wrong so I did not find a way to have it not complaining... Last time I created a mvvm uno app this attribute did miss on the property. If you do know how to add it correctly, I at least would like this already implemented in the template 🤔 would make sense somehow if the rest of the app is using mvvm the properties does also

@corvinsz
Copy link
Author

@DevTKSS I'm not super familiar with uno itself, but I just spun up a uno project and was able to successfully data-bind a partial property. In order for this to work you have to set the <LangVersion>preview</LangVersion> in your project. If you need help with that you can reach out to me on discord (name: "qlay"), I don't think this PR is the correct place to discuss problems like that. 😄

public ICommand Logout { get; }

#endif
[RelayCommand]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't remove the Authentication and mauiembedding scenarios

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corvinsz could you check on this? Would be cool if this enhancement you trying to add could get added also from my user POV :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants