Skip to content

Conversation

@ChrisPulman
Copy link
Member

What kind of change does this PR introduce?

Closes #317

What is the current behavior?

#317

What is the new behavior?

Introduces new unit tests and verified source for ReactiveCommand methods with nullable parameter and return types. Updates generator logic to handle nullable types correctly. Adds usage of nested classes with nullable types in test and example view models, and updates project references accordingly.

What might this PR break?

Existing commands are generated with non-null return types.

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 new unit tests and verified source for ReactiveCommand methods with nullable parameter and return types. Updates generator logic to handle nullable types correctly. Adds usage of nested classes with nullable types in test and example view models, and updates project references accordingly.
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 support for nullable parameter and return types in ReactiveCommand source generation by updating the generator to preserve nullability annotations when extracting type information.

Key Changes

  • Modified ReactiveCommandGenerator.Execute.cs to use GetFullyQualifiedNameWithNullabilityAnnotations() instead of ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) for method parameters, ensuring nullable type annotations (?) are preserved
  • Added comprehensive test coverage with a new unit test FromReactiveCommandWithNullableTypeAndNullableReturnType and example implementations in test view models
  • Added project reference to support the new nested test classes

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ReactiveCommandGenerator.Execute.cs Updated parameter type extraction logic to preserve nullability annotations and removed unused import
TestViewModel.cs Added example usage of ReactiveCommand with nullable parameter and return types across different namespaces
ReactiveUI.SourceGenerators.Execute.csproj Added project reference to Nested3 test project
Class1.cs (Nested3) Added example ReactiveCommand implementation with nullable types and constructor that exercises the generated command
ReactiveCMDGeneratorTests.cs Added unit test to verify nullable type support in ReactiveCommand generation
ReactiveCommandAttribute.g.verified.cs Verified generated attribute code matches expected output

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

@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.12%. Comparing base (a28d1e2) to head (bf50e86).

Files with missing lines Patch % Lines
...eactiveCommand/ReactiveCommandGenerator.Execute.cs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #345      +/-   ##
==========================================
- Coverage   40.16%   40.12%   -0.04%     
==========================================
  Files          61       61              
  Lines        3466     3469       +3     
  Branches      398      399       +1     
==========================================
  Hits         1392     1392              
- Misses       1964     1967       +3     
  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.

Renamed 'methodReturnType' and 'methodParametersstring' to 'argumentType' and 'argumentTypeString' for improved clarity and consistency in naming related to method argument types.
Eliminated the unused variable 'c' of type Class1 from the TestViewModel constructor to clean up the code.
Replaces LINQ ToArray with a range operator in GenerateParentClassDeclarations for improved clarity. Also removes an unused using directive from ReactiveCommandGenerator.cs.
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.

[Bug]: Generated ReactiveCommand doesn not respect the nullability of command input parameter

2 participants