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

Add an option to [ObservableProperty] - generate a private setter #840

Closed
stepagrus opened this issue Feb 20, 2024 · 2 comments
Closed

Add an option to [ObservableProperty] - generate a private setter #840

stepagrus opened this issue Feb 20, 2024 · 2 comments
Labels
duplicate 👥 Indicates that an identical issue or PR already exists feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@stepagrus
Copy link

Overview

Hello!

I need a private setter when generating an observable property.

For example:

  [ObservableProperty(privateSetter: true)]
  private bool _isValid;

Will generate the following code (code simplified to make it easier to read):

public bool IsValid
{
    get => _isValid;
    private set
    {
        if (EqualityComparer<bool>.Default.Equals(_isValid, value))
        {
            _isValid = value;
            OnPropertyChanged();
        }
    }
}

API breakdown

no breakdowns

Usage example

  [ObservableProperty(privateSetter: true)]
  private bool _isValid;

Breaking change?

No

Alternatives

Additional context

No response

Help us help you

Yes, but only if others can assist

@stepagrus stepagrus added the feature request 📬 A request for new changes to improve functionality label Feb 20, 2024
@Sergio0694
Copy link
Member

Duplicate of #291.
Superseded by #555.

@Sergio0694 Sergio0694 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2024
@Sergio0694 Sergio0694 added duplicate 👥 Indicates that an identical issue or PR already exists mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit labels Feb 20, 2024
@stepagrus
Copy link
Author

Thank you. We will wait for partial properties to be delivered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate 👥 Indicates that an identical issue or PR already exists feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
None yet
Development

No branches or pull requests

2 participants