Skip to content

feat: support more path parameter types in generated request building#2193

Merged
ChrisPulman merged 1 commit into
mainfrom
feat/generated-path-parameter-types
Jul 2, 2026
Merged

feat: support more path parameter types in generated request building#2193
ChrisPulman merged 1 commit into
mainfrom
feat/generated-path-parameter-types

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature (with a couple of fixes).

What is the new behavior?

More route parameter types are built by the source generator instead of reflection, so they work when the client is resolved through AddRefitGeneratedClient (generated-only) and under NativeAOT.

Route parameters of these types now use the generated path:

  • enums
  • Guid
  • DateTime, DateTimeOffset, DateOnly, TimeOnly, TimeSpan
  • sbyte and the remaining integer widths
  • Int128, UInt128, Half
  • any other IFormattable type
[Get("/events/{date}")]
Task<Event> GetEvent(DateOnly date);   // no longer needs reflection

What is the current behavior?

These types fell back to the reflection request builder, which throws under AddRefitGeneratedClient/NativeAOT. Guid, DateTimeOffset and enum route parameters were falling back even outside AOT.

What might this PR break?

None. URLs are formatted through the same IUrlParameterFormatter as before, so generated output matches the reflection path.

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

None.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (b592413) to head (ff205c0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2193      +/-   ##
==========================================
+ Coverage   97.16%   97.17%   +0.01%     
==========================================
  Files         129      129              
  Lines        6560     6556       -4     
  Branches     1216     1219       +3     
==========================================
- Hits         6374     6371       -3     
  Misses         69       69              
+ Partials      117      116       -1     

☔ View full report in Codecov by Harness.
📢 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.

- Route parameters typed as enum, Guid, DateTimeOffset, DateOnly, TimeOnly,
  TimeSpan, sbyte, Int128/UInt128, Half (and any IFormattable type) now use the
  reflection-free generated request path, so they work under AddRefitGeneratedClient
  and NativeAOT instead of falling back to reflection.
- Fixes Guid, DateTimeOffset and enum route parameters that were silently falling
  back to reflection.
@glennawatson glennawatson force-pushed the feat/generated-path-parameter-types branch from c8ba254 to ff205c0 Compare July 2, 2026 05:46
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@ChrisPulman ChrisPulman merged commit 9bc6754 into main Jul 2, 2026
14 checks passed
@ChrisPulman ChrisPulman deleted the feat/generated-path-parameter-types branch July 2, 2026 06:18
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.

2 participants