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

[Feature] Specify the generated ObservableProperty name #795

Closed
blueshift777 opened this issue Nov 14, 2023 · 2 comments
Closed

[Feature] Specify the generated ObservableProperty name #795

blueshift777 opened this issue Nov 14, 2023 · 2 comments
Labels
analyzer 👓 A new analyzer being implemented or updated feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@blueshift777
Copy link

I would like to contribute an update to the ObservableProperty attribute that would allow the user to specify the resulting property name. This would involve adding a string property, SpecifiedPropertyName, to the ObservableProperty attribute class in addition to a new, overloaded constructor that accepts the specified property name as a parameter. If the SpecifiedPropertyName is not null or whitespace, the property with the specified name is generated. Otherwise, the current method for generating the property name will be used. For example,

[ObservableProperty("SpecialValue")]
private double value;

will generate the observable property,

public double SpecialValue
{
    get => value;
    set
    {
        if (!global::System.Collections.Generic.EqualityComparer<double>.Default.Equals(this.value, value))
        {
            OnSpecialValueChanging(value);
            OnSpecialValueChanging(default, value);
            OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.SpecialValue);
            this.value = value;
            OnSpecialValueChanged(value);
            OnSpecialValueChanged(default, value);
            OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.SpecialValue);
        }
    }
}

The purpose of this feature is to allow users to specify the property name when the private member variable does not follow common naming conventions.

@ghost ghost added the needs triage 🔍 This issue is awaiting triage by maintainers label Nov 14, 2023
@ghost
Copy link

ghost commented Nov 14, 2023

Hello blueshift777, 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 🙌

@michael-hawker michael-hawker transferred this issue from CommunityToolkit/WindowsCommunityToolkit Nov 16, 2023
@Sergio0694
Copy link
Member

Duplicate of #706.
Superseded by #555.

This is also a duplicate of #835, please avoid opening the same proposal multiple times 🙂

@Sergio0694 Sergio0694 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2024
@Sergio0694 Sergio0694 added feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit analyzer 👓 A new analyzer being implemented or updated and removed needs triage 🔍 This issue is awaiting triage by maintainers labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 👓 A new analyzer being implemented or updated feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants