mrlacey / Rapid-XAML-Toolkit

A collection of tools to accelerate XAML development within Visual Studio. These include XAML analysis, XAML generations, plus templates and helpers.
https://marketplace.visualstudio.com/items?itemName=MattLaceyLtd.RapidXamlToolkit
Other
666 stars 43 forks source link

RXRA001 and RXRA003 false positive because of Fody #486

Closed Luk164 closed 3 years ago

Luk164 commented 3 years ago

Is your feature request related to a problem? Please describe.

The aforementioned warnings appear when a property is being used by XAML binding and does not contain OnPropertyChanged call in the setter. This is very useful so that to programmers do not forget to set them and get confused why the UI is not updating, but the problem is that when using Fody PropertyChanged weaver, these are automatically injected.

Describe the solution you'd like

If at all possible, detect that Fody PropertyChanged weaver is installed and active, and if so, disable RXRA001 and RXRA003 checks for the project they are active for.

Describe alternatives you've considered

Just turning them off manually is of course a much simpler solution, but I find it a bit tedious and I worry about turning them off and later removing Fody, or binding to a project without Fody with checks disabled for the entire solution.

Additional context

Nothing I can think of.

mrlacey commented 3 years ago

Thanks for reporting. So I'm clear, is this that you don't want the options to show up in the context menu for auto-implemented properties? Or is this something else?

Luk164 commented 3 years ago

@mrlacey Pretty much. I currently have them set to suggestions, so I do not accidentally miss them in projects where I do not have Fody on.

mrlacey commented 3 years ago

It's not possible to detect if Fody packages are referenced without a complete re-architecture (to not use Roslyn Analyzers) These "code fixes" are set to be Hidden by default and so should only show up in the Suggested Actions context menu when it is opened. They should never show up in any output or any other UI to indicate their existence. (They're as hidden as I can make them) If they're showing up anywhere else, please can you provide a screenshot and details of which versions of Windows, VS and the extension you have installed.

The only other thing I could think of to make them less conspicuous would be to change where they appear in the order in the context menu but there is no way for me to control or influence this. :(

Luk164 commented 3 years ago

@mrlacey Actually, you do not need to detect the referenced packages. Fody generates a file in which weavers are activated and configured, so it should be possible to detect them via this file. Also, these checks do only come up in intellisense, not as a compile warnings or anything like that.

mrlacey commented 3 years ago

@mrlacey Actually, you do not need to detect the referenced packages. Fody generates a file in which weavers are activated and configured, so it should be possible to detect them via this file. Also, these checks do only come up in intellisense, not as a compile warnings or anything like that.

Sadly, the way Roslyn Analyzers work is they have very limited access to information about the project the files being analyzed are in. This includes not being able to access (read or even be aware of) other files in the project. I've spent a lot of time trying to work around this for other projects and there isn't a way to do it.

As an aside, the last time I worked on a project that used Fody I still found these "fixes" useful for properties where I needed to do more than just call into INPC. Sorry, it's going to be an all-or-nothing situation with these options. There isn't a way to make them smarter or more configurable. You'll just have to disable the extension for such projects if you can't look past the options they provide in the context menu.

Luk164 commented 3 years ago

@mrlacey It is not a big deal, I just thought it could be a quick and easy fix, but I did not know about the roslyn limitations. Thank you for your time and quick replies.