Skip to content

Support adding TransformResult for ValueTask endpoints - #325

Merged
viceroypenguin merged 1 commit into
mainfrom
fix
Jul 28, 2026
Merged

Support adding TransformResult for ValueTask endpoints#325
viceroypenguin merged 1 commit into
mainfrom
fix

Conversation

@viceroypenguin

@viceroypenguin viceroypenguin commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved automatic code fixes for handlers that return either a typed or non-typed asynchronous result.
    • Generated TransformResult methods now use the appropriate result parameter when available, or create a new result when no type is specified.
  • Tests
    • Added coverage for handlers with non-generic asynchronous return types.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The code fix now supports Handle methods returning either generic or non-generic ValueTask forms. It generates typed or parameterless TransformResult methods accordingly, and adds test coverage for non-generic handlers.

Changes

TransformResult code fix

Layer / File(s) Summary
Handle return-type detection
src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs, src/Immediate.Apis.Generators/ImmediateApisGenerator.Transform.cs
Supported generic and non-generic Handle return types are detected, while unsupported types exit without generating a method.
TransformResult generation and validation
src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs, tests/Immediate.Apis.Tests/CodeFixTests/MissingTransformResultMethodCodeFixTests.cs
Typed results generate a result parameter and return it; untyped results generate a parameterless method returning new(), with test coverage for ValueTask.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding TransformResult support for ValueTask-based endpoints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix

Comment @coderabbitai help to get the list of available commands.

@viceroypenguin

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 30317553066

Coverage decreased (-0.001%) to 96.259%

Details

  • Coverage decreased (-0.001%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (35 of 36 lines covered, 97.22%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs 35 34 97.14%
Total (2 files) 36 35 97.22%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1470
Covered Lines: 1415
Line Coverage: 96.26%
Coverage Strength: 3.85 hits per line

💛 - Coveralls

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs`:
- Around line 72-82: Restrict the code fix in the handler-generation flow around
the return-type switch to methods returning ValueTask or ValueTask<T>. Validate
handleMethodSymbol.ReturnType semantically before emitting TransformResult,
rejecting Task, Task<T>, and custom return types while preserving valid
ValueTask cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0703e699-db29-46a5-8f5a-2620627bcaef

📥 Commits

Reviewing files that changed from the base of the PR and between e752e66 and e59f898.

📒 Files selected for processing (3)
  • src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Transform.cs
  • tests/Immediate.Apis.Tests/CodeFixTests/MissingTransformResultMethodCodeFixTests.cs

Comment on lines +72 to +82
var (valid, returnType) = handleMethodSyntax.ReturnType switch
{
GenericNameSyntax
{
TypeArgumentList.Arguments: [{ } returnType],
})
TypeArgumentList.Arguments: [{ } rt],
} => (true, rt),

IdentifierNameSyntax => (true, null),

_ => (false, null),
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C4 'IAPI0007|GetValidHandleMethod|IsValueTask1|IsValueTask' src tests

Repository: ImmediatePlatform/Immediate.Apis

Length of output: 16535


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Code fix ==\n'
sed -n '1,220p' src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs

printf '\n== Language version settings ==\n'
rg -n -C2 '<LangVersion>|TargetFramework|SupportedOSPlatformVersion|ImplicitUsings' -g '*.csproj' -g 'Directory.Build.*' -g 'global.json' .

Repository: ImmediatePlatform/Immediate.Apis

Length of output: 14817


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== MissingTransformResultMethodAnalyzer ==\n'
sed -n '1,220p' src/Immediate.Apis.Analyzers/MissingTransformResultMethodAnalyzer.cs

printf '\n== GetValidHandleMethod / type helpers ==\n'
sed -n '1,220p' src/Common/ITypeSymbolExtensions.cs

printf '\n== Related tests ==\n'
sed -n '1,220p' tests/Immediate.Apis.Tests/AnalyzerTests/MissingTransformResultMethodAnalyzerTests.cs

Repository: ImmediatePlatform/Immediate.Apis

Length of output: 10834


Restrict the fix to ValueTask handlers. The diagnostic is raised for any class with a Handle/HandleAsync method, so Task, Task<T>, and custom return types can still reach this syntax-based switch and generate a mismatched TransformResult; use handleMethodSymbol.ReturnType (or mirror the analyzer’s semantic checks) before emitting the method.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Immediate.Apis.CodeFixes/MissingTransformResultMethodCodeFixProvider.cs`
around lines 72 - 82, Restrict the code fix in the handler-generation flow
around the return-type switch to methods returning ValueTask or ValueTask<T>.
Validate handleMethodSymbol.ReturnType semantically before emitting
TransformResult, rejecting Task, Task<T>, and custom return types while
preserving valid ValueTask cases.

@viceroypenguin
viceroypenguin merged commit 63afbf5 into main Jul 28, 2026
2 of 3 checks passed
@viceroypenguin
viceroypenguin deleted the fix branch July 28, 2026 00:37
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.

IAPI0007 code fix silently does nothing for bare-ValueTask handlers

2 participants