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

Pass Atributes to generated public property is not working #524

Closed
1 of 4 tasks
AndreasReitberger opened this issue Dec 11, 2022 · 1 comment
Closed
1 of 4 tasks
Labels
fixed in main 🏎️ An issue/feature that has already been fixed/added in main mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@AndreasReitberger
Copy link

Describe the bug

I having a class, where some properties should not be serialized. For instance, the Timer property.

[ObservableProperty]
[field: JsonIgnore]
[field: XmlIgnore]
Timer _timer;

Before switching to this nuget, the code looked like.

[JsonIgnore, XmlIgnore]
Timer _timer;
[JsonIgnore, XmlIgnore]
public Timer Timer
{
    get => _timer;
    set
    {
        if (_timer == value) return;
        _timer = value;
        OnPropertyChanged();
    }
}

There, I just was able to set [JsonIgnore, XmlIgnore] to the public property as well.
How do I achieve this here?

Regression

No response

Steps to reproduce

1. Take a property which fails the XML serialization (for instance Timer)
2. Try to pass the [XmlIgnore] attribute to the generated source code.

Expected behavior

Public, generated proeprty should get the attribute passed.

Screenshots

No response

IDE and version

VS 2022 Preview

IDE version

17.5.0 Preview 1.0

Nuget packages

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

Nuget package version(s)

8.0.0

Additional context

No response

Help us help you

No, just wanted to report this

@Sergio0694
Copy link
Member

This is supported as part of #413. You'll need 8.1 Preview, and you'll need to use property: in the attribute list on the field (not field:) 🙂

@Sergio0694 Sergio0694 added mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit fixed in main 🏎️ An issue/feature that has already been fixed/added in main and removed bug 🐛 An unexpected issue that highlights incorrect behavior labels Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in main 🏎️ An issue/feature that has already been fixed/added in main mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
None yet
Development

No branches or pull requests

2 participants