Fix sync method pipeline to match async behavior (ExceptionFactory, IApiResponse, disposal)#2070
Merged
ChrisPulman merged 3 commits intoFixFor2065_2067from Mar 25, 2026
Merged
Conversation
2 tasks
… behavior - Rewrite BuildGeneratedSyncFuncForMethod as a dispatcher that handles void return separately and delegates non-void to a new generic method. - Add BuildGeneratedSyncFuncForMethodGeneric<T,TBody> that mirrors the full async pipeline: runs ExceptionFactory (skipped for HttpResponseMessage), honours IsApiResponse, uses ShouldDisposeResponse for cleanup, and surfaces DeserializationExceptionFactory on deserialization errors. - Add DeserializeContentSync<T> handling all content types: HttpResponseMessage, HttpContent, Stream, string, and deserialised T. - Fix RestMethodInfo sync branch to properly decompose IApiResponse<T> / ApiResponse<T> return types, setting DeserializedResultType to the inner type just like the async Task<IApiResponse<T>> path does. - Add SyncVoid to ReturnTypeInfo enum and handle it in Parser.cs and Emitter.cs so void-returning sync stub methods emit a plain call instead of the invalid 'return (void)...' pattern. - Add comprehensive tests covering error responses, HttpResponseMessage, HttpContent, Stream, IApiResponse<T>, and void sync methods. Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com> Agent-Logs-Url: https://github.com/reactiveui/refit/sessions/7e184030-9d18-44ec-aff4-305b2c7e973d
Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com> Agent-Logs-Url: https://github.com/reactiveui/refit/sessions/7e184030-9d18-44ec-aff4-305b2c7e973d
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on sync interface members & enum names implementation
Fix sync method pipeline to match async behavior (ExceptionFactory, IApiResponse, disposal)
Mar 25, 2026
ChrisPulman
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sync path for explicit/non-public interface members bypassed
ExceptionFactory, ignoredIsApiResponse, always disposed the response, and couldn't correctly returnHttpResponseMessage/HttpContent/Stream/IApiResponse<T>.Changes
Refit/RequestBuilderImplementation.csBuildGeneratedSyncFuncForMethodwith a dispatcher: void returns runExceptionFactorythen return null; non-void delegates to newBuildGeneratedSyncFuncForMethodGeneric<T, TBody>via reflection.BuildGeneratedSyncFuncForMethodGeneric<T, TBody>mirrorsBuildCancellableTaskFuncForMethodexactly: skipsExceptionFactoryforHttpResponseMessage, wraps inApiResponse<TBody>whenIsApiResponse, usesShouldDisposeResponsefor conditional cleanup, surfacesDeserializationExceptionFactoryon deserialization failure.DeserializeContentSync<T>handlingHttpResponseMessage,HttpContent,Stream,string, and genericT(via content serializer).DeserializeSyncResponse/DeserializeSyncResponseGeneric<T>.Refit/RestMethodInfo.csDetermineReturnTypeInfonow decomposesIApiResponse<T>/ApiResponse<T>to setDeserializedResultTypeto the inner type, matching theTask<IApiResponse<T>>path.Source generator (
InterfaceStubGenerator.Shared)ReturnTypeInfo.SyncVoidenum value; parser mapsVoidmetadata name to it; emitter emits a plain call______func(...)instead of the invalidreturn (void)______func(...).Example
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.