Repository navigation
Description
Follow-up from #2174 (v13.0.0).
Is your feature request related to a problem?
#2174 made path/route-template parameters generate inline (reflection-free). Query parameters still fall back to the reflection request builder:
- auto-appended query params:
[Get("/users")] Task<T> Search(string q)->/users?q=... [Query](including[Query(Format=...)], nested/collection expansion, custom delimiters)[AliasAs]on a query parameter
A method with any of these is emitted against BuildRestResultFuncForMethod (the reflection tail), so it throws at runtime under AddRefitGeneratedClient (generated-only) or NativeAOT. Query params are the most common Refit shape, so the generated-only/AOT path is still unusable for typical query APIs. The runtime symptom is #2185.
Describe the solution you'd like
Generate inline request building for methods whose only otherwise-unsupported parameters are query params. The generated query string must match the reflection path's escaping and formatting so the RequestUri is identical between the two.
Describe alternatives you've considered
- Leave it as a reflection fallback (status quo): keeps [Bug]: AddRefitGeneratedClient fails for methods with query parameters #2185 broken for the common case.
- feat: add for support AOT request routing #2182 models route/query fragments as a
RouteFragmentModelunion (constant / standard-param / object-access / round-trip), a useful reference for this and the dotted/round-trip work.
Describe suggestions on how to achieve the feature
Generator (src/InterfaceStubGenerator.Shared/):
Parser.Request.cs:ParseRequestParameterreturnsUnsupportedRequestParameter(~line 357) for a parameter with no{...}placeholder. Add aRequestParameterKind.Query, classify plain /[Query]/[AliasAs]params into it, and relaxcanGenerateInlineinParseRequest.- Reuse the existing
[Query]parsing (ParseQueryAttribute*, ~lines 580-625) andIsSimpleType(Parser.Request.Helpers.cs).
Runtime (src/Refit/):
- Add a query-append helper modeled on
GeneratedRequestRunner.BuildRequestPath: linear scan,ValueStringBuilder,StringHelpers.EscapeDataStringper value, handling collection expansion and delimiters. The reflection version is inRequestBuilderImplementation.RequestBuilding.cs.
Guardrails:
- Value formatting still goes through
IUrlParameterFormatter; keep that boundary, the separate value-formatting issue covers it. - Keep the RF006 fallback analyzer and
GeneratedRequestBuildingFallbackContractTestsin sync: as these shapes become inline, theirexpectedFallbackcases flip.
Tests: emit-load-invoke asserting the final RequestUri (single param, multiple, [AliasAs], [Query(Format=...)], collection, null/empty, and a value that needs escaping such as "a b/c") plus Verify snapshots.
Additional context
Deferred from the #2174 review. Related: #2185, #2168, #2169, #2182. Dotted ({request.Prop}) and round-trip ({**param}) placeholders stay on the reflection fallback (#2046) and are already covered by tests.
Activity
feat!: reflection-free source-generated request building (#2210)
glennawatson commentedon Jul 15, 2026
This is addressed in the Refit 14 beta, now available on NuGet: https://www.nuget.org/packages/Refit/14.0.0-beta.1
Please give it a try - feedback ahead of the stable 14.0.0 release is very welcome.
github-actions commentedon Jul 30, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.