Skip to content

Conversation

@ChrisPulman
Copy link
Member

What kind of change does this PR introduce?

feature

What is the new behavior?

Introduces the [IReactiveObject] attribute and a new source generator to implement IReactiveObject for classes that cannot inherit from ReactiveObject.
Updates documentation, adds generator logic, supporting models, and unit tests to verify generated code.
Also updates helper and project files to support the new generator.

What might this PR break?

None, new feature

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 the [IReactiveObject] attribute and a new source generator to implement IReactiveObject for classes that cannot inherit from ReactiveObject. Updates documentation, adds generator logic, supporting models, and unit tests to verify generated code. Also updates helper and project files to support the new generator.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new source generator that implements the IReactiveObject interface for classes that cannot inherit from ReactiveObject. The generator is triggered by the [IReactiveObject] attribute and generates the necessary event infrastructure and interface implementation.

Key changes:

  • Added ReactiveObjectGenerator with attribute-based code generation for IReactiveObject interface implementation
  • Updated helper classes to support the new generator and consolidated common constants
  • Added unit tests with verified snapshots for the new generator

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.cs Main generator class that registers the IReactiveObject attribute and orchestrates code generation
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.Execute.cs Contains execution logic for analyzing classes and generating IReactiveObject implementation code
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/Models/ReactiveObjectInfo.cs Data model for storing information about classes to be processed by the generator
src/ReactiveUI.SourceGenerators.Roslyn/IViewFor/IViewForGenerator.Execute.cs Updated to use shared ExcludeFromCodeCoverage constant from AttributeDefinitions
src/ReactiveUI.SourceGenerators.Roslyn/Core/Extensions/FieldSyntaxExtensions.cs Updated to use centralized ReactiveObjectAttributeType constant for consistency
src/ReactiveUI.SourceGenerators.Roslyn/BindableDerivedList/BindableDerivedListGenerator.cs Removed unused using directives
src/ReactiveUI.SourceGenerators.Roslyn/AttributeDefinitions.cs Added IReactiveObjectAttribute definition and ExcludeFromCodeCoverage constant
src/ReactiveUI.SourceGenerators.Execute/Person.cs Updated example to use the new IReactiveObject attribute instead of inheriting from ReactiveObject
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveObjectGeneratorTests.cs Added unit test for the ReactiveObject generator
src/ReactiveUI.SourceGenerator.Tests/TestHelper.cs Added REACTIVEOBJ folder mapping for test output organization
src/ReactiveUI.SourceGenerator.Tests/ReactiveUI.SourceGenerators.Tests.csproj Added REACTIVEOBJ test folder to project structure
src/ReactiveUI.SourceGenerator.Tests/REACTIVEOBJ/... Added verified test snapshots for generated code
README.md Added documentation for the new IReactiveObject attribute with usage example

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 94.26230% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.86%. Comparing base (8aedecb) to head (826db8d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../ReactiveObject/ReactiveObjectGenerator.Execute.cs 92.59% 4 Missing and 2 partials ⚠️
...ators.Roslyn/IViewFor/IViewForGenerator.Execute.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   40.12%   42.86%   +2.74%     
==========================================
  Files          61       64       +3     
  Lines        3469     3583     +114     
  Branches      399      404       +5     
==========================================
+ Hits         1392     1536     +144     
+ Misses       1967     1935      -32     
- Partials      110      112       +2     

☔ 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.

Eliminated the ViewModelTypeName property from the ReactiveObjectInfo record and updated the generator logic to reflect this change. This simplifies the model and generator by removing unused or unnecessary data.
Corrected 'reative' to 'reactive' in XML documentation and comments across multiple source generator files. Also fixed a typo in the summary for ReactiveCommandAttribute and clarified some comments in ReactiveObjectGenerator.
Clarified the summary comment for the test method to specify it tests the ReactiveObject generator with IReactiveObjectAttribute.
Revised the XML summary comment for ReactiveObjectInfo to clarify that it represents information about a generated ReactiveObject (view model), improving documentation accuracy.
Corrected 'ReativeCommandAttribute' to 'ReactiveCommand Attribute' in the summary comments of multiple generated test files for improved clarity and accuracy.
@ChrisPulman ChrisPulman merged commit de20111 into main Dec 24, 2025
6 checks passed
@ChrisPulman ChrisPulman deleted the Add_IReactiveObject_Feature branch December 24, 2025 11:13
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.

2 participants