Add AccessModifier support to ReactiveCommand#342
Conversation
Introduces the AccessModifier property to the ReactiveCommand attribute, allowing generated command properties to specify their access level. Updates documentation, attribute definitions, generator logic, and test usage to support internal, protected, private, and other modifiers.
Introduces the PropertyAccessModifier enum to specify property access levels and adds an AccessModifier property to the ReactiveCommandAttribute. This enhances control over generated property access in source generator tests.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #342 +/- ##
==========================================
+ Coverage 39.98% 40.16% +0.17%
==========================================
Files 61 61
Lines 3429 3466 +37
Branches 395 398 +3
==========================================
+ Hits 1371 1392 +21
- Misses 1948 1964 +16
Partials 110 110 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds AccessModifier support to the ReactiveCommand attribute, allowing developers to control the visibility of generated command properties. The implementation enables specifying access levels (public, protected, internal, private, protected internal, private protected) for generated ReactiveCommand properties through the PropertyAccessModifier enum.
Key Changes
- Introduces
PropertyAccessModifierenum with six access level values - Adds
AccessModifierproperty toReactiveCommandAttribute - Updates generator logic to map enum values to C# access modifier strings
- Updates documentation with usage examples
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ReactiveUI.SourceGenerators.Roslyn/AttributeDefinitions.cs | Added PropertyAccessModifier enum definition and AccessModifier property to ReactiveCommandAttribute |
| src/ReactiveUI.SourceGenerators.Roslyn/ReactiveCommand/ReactiveCommandGenerator.Execute.cs | Implemented enum value extraction and mapping to access modifier strings for code generation |
| src/ReactiveUI.SourceGenerators.Roslyn/ReactiveCommand/Models/CommandInfo.cs | Extended CommandInfo record with AccessModifier parameter |
| src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs | Added usage example demonstrating PropertyAccessModifier.Internal |
| src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/*.verified.cs | Updated snapshot tests to include new PropertyAccessModifier enum in generated attributes |
| src/ReactiveUI.SourceGenerator.Tests/REACTIVE/*.verified.cs | Updated snapshot tests to include new PropertyAccessModifier enum in generated attributes |
| README.md | Added documentation for the AccessModifier feature with usage example |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveCommand/ReactiveCommandGenerator.Execute.cs
Outdated
Show resolved
Hide resolved
Introduces a new unit test to verify that the ReactiveCommand source generator correctly handles the AccessModifier property. Also updates generated test assets and clarifies a comment in the generator implementation.
Deleted .received.cs files for DotNet8_0, DotNet9_0, and DotNet10_0 test targets as their content is now covered by the verified file. This streamlines the test assets and reduces duplication.
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveCommand/ReactiveCommandGenerator.Execute.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Introduced a generic GetNamedArgument<T> extension method for AttributeData to simplify retrieval of named arguments. Refactored ReactiveCommandGenerator.Execute.cs to use the new method for accessing the AccessModifier argument.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveCMDGeneratorTests.cs
Show resolved
Hide resolved
src/ReactiveUI.SourceGenerators.Roslyn/Core/Extensions/AttributeDataExtensions.cs
Show resolved
Hide resolved
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
feature
closes #316
What is the current behavior?
#316
What is the new behavior?
Introduces the AccessModifier property to the ReactiveCommand attribute, allowing generated command properties to specify their access level. Updates documentation, attribute definitions, generator logic, and test usage to support internal, protected, private, and other modifiers.
What might this PR break?
New Feature
Please check if the PR fulfills these requirements
Other information: