Skip to content

Add an analizer to mvvm toolkit to warn when I use fields instead of generated properties #518

@DoctorKrolic

Description

@DoctorKrolic

Let's say I have code like this:

partial class MyViewModel : ObservableObject
{
  [ObservableProperty]
  int someProp;

  void M()
  {
    someProp = 1; // mistake here
  }
}

At line 7 I accidentally made a mistake and assigned a private field instead of generated observable property. As of now, there is no thing to warn me, that I've done such mistake. Considering that the difference between a property and a field is only 1 letter it can be a bit tricky to understand, where the mistake lies, especially when the file is quite large. My request here is to add a custom analyzer, that would detect such cases and produce a warning, pointing me to the location of a mistake. It should also have a codefix, so I can switch to generated property in several clicks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request 📬A request for new changes to improve functionalitymvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions