Repository navigation
Description
Follow-up from #2174 (v13.0.0).
Is your feature request related to a problem?
After #2174, request shaping is reflection-free, but value formatting for path params (and query values, once those go inline) still goes through IUrlParameterFormatter / DefaultUrlParameterFormatter, which uses reflection for enums and TypeConverter. So the reflection-free/AOT guarantee only holds at the request-shaping layer, not value formatting: enum, TypeConverter, and other non-primitive values can still hit trimming/AOT warnings or format wrong under AddRefitGeneratedClient / NativeAOT.
Describe the solution you'd like
Format statically-known parameter types in generated code without runtime reflection, matching DefaultUrlParameterFormatter output and still honoring a custom IUrlParameterFormatter when one is set.
Describe alternatives you've considered
- Keep calling
IUrlParameterFormatterfor everything (status quo): simplest, but leaves reflection in the path and breaks the AOT promise for enum/TypeConvertervalues. - Emit direct formatting only for provably-simple types and fall back to the formatter (and the reflection builder) for the rest: a reasonable first cut.
Describe suggestions on how to achieve the feature
- Simple types (
IsSimpleType,Parser.Request.Helpers.cs): emit directToString(CultureInfo.InvariantCulture)/ToString("D")matchingDefaultUrlParameterFormatter. - Enums: emit the resolved string at compile time from the enum symbol (plus any
[EnumMember]/Display/Descriptionthe default formatter honors) instead of runtime enum reflection. - Custom
IUrlParameterFormatter: still call it, but pass the statictypeof(TParam)and the generator-emittedICustomAttributeProvider(GeneratedParameterAttributeProvider) instead of reflectingParameterInfo. - Anything not provably safe falls back to the reflection builder (RF006 then flags it at compile time).
Additional context
Deferred from the #2174 review. Best done after the extra path-parameter type coverage (Guid / DateTime / DateTimeOffset / decimal / double / float / enum), since that work is what surfaces types that need real formatting.
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.