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 analyzer for [field: ObservableProperty] uses #734

Closed
Sergio0694 opened this issue Jul 10, 2023 · 0 comments · Fixed by #735
Closed

Add an analyzer for [field: ObservableProperty] uses #734

Sergio0694 opened this issue Jul 10, 2023 · 0 comments · Fixed by #735
Assignees
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

@Sergio0694
Copy link
Member

The [ObservableProperty] attribute is only valid on field declarations. Trying to use it on a backing field for a property will not cause errors, as the source generator will simply skip that syntax node, but it will produce no diagnostics to tell the users what's wrong. There should be a new diagnostic analyzer to produce the appropriate diagnostic in these cases.

Example

Consider this snippet:

public partial class MyViewModel : ObservableObject
{
    [field: ObservableProperty]
    public string? Name { get; private set; }
}

This should emit a diagnostic on that attribute use.

@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 labels Jul 10, 2023
@Sergio0694 Sergio0694 self-assigned this Jul 10, 2023
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.

1 participant