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 support for "required" and "virtual" keywords to property generator #679

Closed
michael-tlsoftware opened this issue May 1, 2023 · 1 comment
Labels
feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@michael-tlsoftware
Copy link

michael-tlsoftware commented May 1, 2023

Overview

When working with nullable libraries, being able to add the required keyword to properties is helpful. I have reviewed the source generator and dont believe this is currently supported when using ObservablePropertyAttribute . I propose adding properties to the this class to signal to the generator to add this modifier where required. This would default to false to not impact existing usage.

As the code would be similar, I propose to add the virtual modifier at the same time for completeness.

API breakdown

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class ObservablePropertyAttribute : Attribute
{
    public bool Virtual { get; set; } = false;
    public bool Required { get; set; } = false;
}

Usage example

[ObservableProperty(Required = true, Virtual = true)]
bool _myProperty;

Breaking change?

No

Alternatives

Current alternative is to selectively use source generator, and use the underlying methods when creating properties by hand.

Additional context

No response

Help us help you

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

@michael-tlsoftware michael-tlsoftware added the feature request 📬 A request for new changes to improve functionality label May 1, 2023
@Sergio0694 Sergio0694 added the mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit label May 1, 2023
@Sergio0694
Copy link
Member

Duplicate of #291.
Superseded by #555.

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
None yet
Development

No branches or pull requests

2 participants