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

Allow custom field and property attributes for [RelayCommand] #599

Closed
virzak opened this issue Feb 9, 2023 · 4 comments · Fixed by #630
Closed

Allow custom field and property attributes for [RelayCommand] #599

virzak opened this issue Feb 9, 2023 · 4 comments · Fixed by #630
Labels
feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@virzak
Copy link

virzak commented Feb 9, 2023

Overview

When trying to serialize an object that contains a [RelayCommand] the command property gets serialized by default, which could be undesirable.

We should be able to apply a custom property. to avoid serialization

Usage example

[RelayCommand]
[property: Newtonsoft.Json.JsonIgnore]
private void DoWork() { }

Breaking change?

No

Alternatives

The alternative is to pass options during serialization.

Help us help you

Yes, I'd like to be assigned to work on this item

@virzak virzak added the feature request 📬 A request for new changes to improve functionality label Feb 9, 2023
@Sergio0694 Sergio0694 added the mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit label Feb 9, 2023
@TruePluto
Copy link

I think so but should be ?

[RelayCommand]
[field: Newtonsoft.Json.JsonIgnore]
private void DoWork() { }

PS:How to colorize these code?

@Sergio0694 Sergio0694 changed the title Allow custom property attributes for [RelayCommand] Allow custom field and property attributes for [RelayCommand] Mar 8, 2023
@Sergio0694 Sergio0694 added this to 8.2 Mar 8, 2023
@Sergio0694 Sergio0694 moved this to 🏗 In progress in 8.2 Mar 8, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in 8.2 Mar 9, 2023
@laolarou726
Copy link

Maybe also add the support for [ObservableProperty]? Some times it's really important to ignore those observable fields.

@Sergio0694
Copy link
Member

@laolarou726 [ObservableProperty] has supported custom attributes since 8.1 already 🙂
See https://devblogs.microsoft.com/dotnet/announcing-the-dotnet-community-toolkit-810/.

@laolarou726
Copy link

@laolarou726 [ObservableProperty] has supported custom attributes since 8.1 already 🙂 See https://devblogs.microsoft.com/dotnet/announcing-the-dotnet-community-toolkit-810/.

My bad, sorry about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants