Refit

The automatic type-safe REST library for Xamarin and .NET

This project is maintained by reactiveui

Breaking changes and release notes

Every breaking change and notable addition, newest first. Each major version links back to the feature documentation in the main README.

V14.x.x

Breaking changes in V14.x

Refit 14 finishes the move to generated request building. Interfaces whose methods all generate inline no longer touch the reflection request builder at any point, which is what makes them trim and Native AOT clean — and that shift is visible in three places.

New in V14.x

V13.x.x

Breaking changes in V13.x

Refit 13 hardens the default security posture from a security audit. The new behavior is safe by default; the changes below only affect code that previously relied on the less-secure defaults.

The release also adds two opt-in, non-breaking knobs on RefitSettings for hardening exception handling:

New in V13.x

Breaking changes in V12.x

Refit 12.0 is a large release centered on a near-complete rewrite of request building. The source generator now builds eligible HTTP requests inline at compile time instead of going through the reflection request-builder pipeline, with the reflection path kept as a fallback for shapes that cannot be generated inline.

Two breaking changes are called out for migration:

See the Refit 12.0.0 release notes for the full release details.

V11.x.x

Breaking changes in 11.x

Refit 11 introduces ApiRequestException to represent requests that fail before receiving a response from the server. This exception will now wrap previous exceptions such as HttpRequestException and TaskCanceledException when they occur during request execution.

The IApiResponse.Error property’s type has also changed to ApiExceptionBase, which is the new base class for ApiException and ApiRequestException. If your code accessed members specific to ApiException (i.e. anything related to the response from the server), you can use the new IApiResponse.HasResponseError(out var apiException) method to safely check and retrieve the ApiException instance.

All response-related properties of IApiResponse are now nullable. The new IApiResponse.IsReceived property can be used to check if a response was received from the server, and will mark those properties as non-null. The original IApiResponse.IsSuccessful and IApiResponse.IsSuccessStatusCode properties can still be used to check if the response was received and is successful.

Updates in 8.0.x

Fixes for some issues experienced, this led to some breaking changes. See Releases for full details.

V6.x.x

Refit 6 requires Visual Studio 16.8 or higher, or the .NET SDK 5.0.100 or higher. It can target any .NET Standard 2.0 platform.

Refit 6 does not support the old packages.config format for NuGet references (as they do not support analyzers/source generators). You must migrate to PackageReference to use Refit v6 and later.

Breaking changes in 6.x

Refit 6 makes System.Text.Json the default JSON serializer. If you’d like to continue to use Newtonsoft.Json, add the Refit.Newtonsoft.Json NuGet package and set your ContentSerializer to NewtonsoftJsonContentSerializer on your RefitSettings instance. System.Text.Json is faster and uses less memory, though not all features are supported. The migration guide contains more details.

IContentSerializer was renamed to IHttpContentSerializer to better reflect its purpose. Additionally, two of its methods were renamed, SerializeAsync<T> -> ToHttpContent<T> and DeserializeAsync<T> -> FromHttpContentAsync<T>. Any existing implementations of these will need to be updated, though the changes should be minor.

Updates in 6.3

Refit 6.3 splits out the XML serialization via XmlContentSerializer into a separate package, Refit.Xml. This is to reduce the dependency size when using Refit with Web Assembly (WASM) applications. If you require XML, add a reference to Refit.Xml.