Skip to content

[RFC] v109 #1976

@alexeyzimarev

Description

@alexeyzimarev

RFC for v109.

New features

Done, awaiting feedback

  • IRestClient interface with Options, Serializers, ExecuteAsync, and DownloadStreamAsync
  • Target frameworks: .NET 6, .NET 9, .NET Framework 4.7.1, .NET Standard 2.0
  • Using the Configuration pattern for options, serializers, etc

Planned

  • RestClientFactory implementation. It is unclear if we should use IHttpClientFactory or an internal factory like it's done by Flurl. Using both might work too.

Breaking changes

  • Serializers configuration using a delegate passed to the constructor. UseXXX methods to configure serializers moved to the SerializerConfig
  • Authenticator, Encode, EncodeQuery moved to RestClientOptions
  • Options exposed by the client changed the type to IRestClientOptions where most of the properties are get-only. Also, properties that configure HttpClient or HttpMessageHandler are not included to IRestClientOptions.

Motivation

The client instance should not be as mutable as it is today. The current API allows making configuration changes at runtime, which can produce undesired side-effects when the client instance is used in multi-threaded scenarios.

Example serializer configuration

Before:

var client = new RestClient(url);
client.UseNewtonsoftJson();

After:

var client = new RestClient(url, configureSerializers: cfg => cfg.UseNewtonsoftJson());

Metadata

Metadata

Assignees

No one assigned

    Labels

    rfcRequest for comments

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions