Skip to content

Add AccessModifier support to ReactiveCommand#342

Merged
ChrisPulman merged 5 commits intomainfrom
AddReactiveCommandWithAccessModifier
Dec 9, 2025
Merged

Add AccessModifier support to ReactiveCommand#342
ChrisPulman merged 5 commits intomainfrom
AddReactiveCommandWithAccessModifier

Conversation

@ChrisPulman
Copy link
Member

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

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

Other information:

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
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 52.50000% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.16%. Comparing base (f283e27) to head (170c697).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...eactiveCommand/ReactiveCommandGenerator.Execute.cs 0.00% 13 Missing ⚠️
....Roslyn/Core/Extensions/AttributeDataExtensions.cs 0.00% 4 Missing ⚠️
...ators.Roslyn/ReactiveCommand/Models/CommandInfo.cs 0.00% 2 Missing ⚠️
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.
📢 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.

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 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 PropertyAccessModifier enum with six access level values
  • Adds AccessModifier property to ReactiveCommandAttribute
  • 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.

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

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.
@glennawatson glennawatson requested a review from Copilot December 9, 2025 08:02
@ChrisPulman ChrisPulman merged commit 1f97e4a into main Dec 9, 2025
8 checks passed
@ChrisPulman ChrisPulman deleted the AddReactiveCommandWithAccessModifier branch December 9, 2025 08:03
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

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.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to declare a private or protected ReactiveCommand

3 participants