Skip to content

Conversation

@ChrisPulman
Copy link
Member

What kind of change does this PR introduce?

fixes #296

What is the current behavior?

#296

What is the new behavior?

Introduces ReactiveAttributeMisuseAnalyzer and ReactiveAttributeMisuseCodeFixProvider to warn and fix cases where [Reactive] is used on non-partial properties or types.
Adds corresponding unit tests and updates diagnostic descriptors and analyzer release notes.

What might this PR break?

None

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

Introduces ReactiveAttributeMisuseAnalyzer and ReactiveAttributeMisuseCodeFixProvider to warn and fix cases where [Reactive] is used on non-partial properties or types. Adds corresponding unit tests and updates diagnostic descriptors and analyzer release notes.
Introduces TestCompilationReferences to centralize default metadata references for test compilation setup. Updates analyzer and code fix provider tests to use this helper, improving maintainability. Enhances PropertyToReactiveFieldAnalyzer to better handle cases where ReactiveUI types may not be referenced, falling back to syntax-based checks for base types and attributes.
@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 72.11538% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.54%. Comparing base (215611a) to head (a6471e6).

Files with missing lines Patch % Lines
...deFixers/ReactiveAttributeMisuseCodeFixProvider.cs 78.18% 7 Missing and 5 partials ⚠️
...tics/CodeFixers/ReactiveAttributeMisuseAnalyzer.cs 58.33% 4 Missing and 6 partials ⚠️
...tics/CodeFixers/PropertyToReactiveFieldAnalyzer.cs 56.25% 1 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #365      +/-   ##
==========================================
+ Coverage   43.22%   43.54%   +0.32%     
==========================================
  Files          64       75      +11     
  Lines        3646     3991     +345     
  Branches      420      484      +64     
==========================================
+ Hits         1576     1738     +162     
- Misses       1950     2095     +145     
- Partials      120      158      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@martinbu
Copy link

martinbu commented Jan 4, 2026

Thanks for this analyzer. It prevents a lot of pain. :-)

Wouldn't that also apply to the ObservableAsProperty attribute like used here

And then the question arises for me: could there also be an analyzer that checks that when an ObservableAsProperty property is used with .ToProperty(...), it also checks whether the return value is assigned to the helper field? Or maybe more generic, that the return value of a .ToProperty must not be ignored?

@ChrisPulman
Copy link
Member Author

Thanks for this analyzer. It prevents a lot of pain. :-)

Wouldn't that also apply to the ObservableAsProperty attribute like used here

And then the question arises for me: could there also be an analyzer that checks that when an ObservableAsProperty property is used with .ToProperty(...), it also checks whether the return value is assigned to the helper field? Or maybe more generic, that the return value of a .ToProperty must not be ignored?

Hi, I will add an analyser for the ObservableAsProperty too in the same way as the Reactive attribute, I will see what I can do about adding a ToProperty analyser too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add warning message for incorrect usage of [Reactive]

4 participants