-
Notifications
You must be signed in to change notification settings - Fork 295
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 fixers project and implement a fixer for FieldReferenceForObservablePropertyFieldAnalyzer #578
Conversation
…blePropertyFieldAnalyzer This adds a fixer for MVVMTK0034, that simply swaps the field reference for what will be generated for the property. It leaves the qualification intact, basically just doing a text swap. Because it's very a very simple fixer, the built-in batch fixall provider works just fine and does not need special handling. While I implemented the fixer and added some tests, I did not actually set up all the msbuild goop for properly packaging this as part of the existing packages (as, frankly, the multi-targeting and msbuild setup in this repo is very complicated and I didn't feel like trying to grok exactly how to add it given the setup). The fixer assembly needs to be put next to the analyzer assemblies. This PR will be editable by maintainers, so feel free to implement this in-place in the PR itself. Fixes #577.
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
...m.SourceGenerators.Roslyn401.UnitTests/Test_FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Mvvm.Fixers/FieldReferenceForObservablePropertyFieldFixer.cs
Outdated
Show resolved
Hide resolved
Now for the fun part, making this thing actually work with multi-targeted packaging 🤣 |
FYI @Arlodotexe you might also want to take a look if you want to learn something new 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming you've tested the package in VS and seen the analyzers (and fix all) working?
Not yet. I've just marked this as ready to review as it's not clearly still work in progress, is all 😄 |
Mmmh trying this out, I get this:
Kinda seems unrelated. Not sure why the code fix isn't showing up though. Let me try in a different project as well. |
Hey @333fred are you able to run the unit tests locally? They're failing for me with some packing error, but they run fine in the CI, so I'm not entirely sure I understand what's going on with them. Can you try on your end as well as a sanity check? |
What is the error? |
Message:
Stack Trace:
I get a total of 114 failing unit tests across all source generator tests on all targets 🥲 |
@Sergio0694 Does deleting |
Oh, cool, that worked, thank you! 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's my pr so I can't mark it approved, but your changes lgtm
Thank you @333fred! And @Youssef1313 for the review 😄 |
This adds a fixer for MVVMTK0034, that simply swaps the field reference for what will be generated for the property. It leaves the qualification intact, basically just doing a text swap. Because it's a very very simple fixer, the built-in batch fixall provider works just fine and does not need special handling.
While I implemented the fixer and added some tests, I did not actually set up all the msbuild goop for properly packaging this as part of the existing packages (as, frankly, the multi-targeting and msbuild setup in this repo is very complicated and I didn't feel like trying to grok exactly how to add it given the setup). The fixer assembly needs to be put next to the analyzer assemblies. This PR will be editable by maintainers, so feel free to implement this in-place in the PR itself.
Fixes #577.