-
-
Notifications
You must be signed in to change notification settings - Fork 6
Add IReactiveObject source generator and tests #352
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
Conversation
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.
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.
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
ReactiveObjectGeneratorwith 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.
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.Execute.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.Execute.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/Models/ReactiveObjectInfo.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveObjectGeneratorTests.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/ReactiveObjectGenerator.cs
Outdated
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveObject/Models/ReactiveObjectInfo.cs
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
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.
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
Other information: