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.
Let's say I have code like this:
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.