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 analizer to mvvm toolkit to warn when I use fields instead of generated properties #518

Closed
DoctorKrolic opened this issue Dec 6, 2022 · 0 comments · Fixed by #532
Labels
feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@DoctorKrolic
Copy link

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.

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

Successfully merging a pull request may close this issue.

2 participants