Skip to content

Commit 0d83daf

Browse files
committed
All tests pass
1 parent 7f864ee commit 0d83daf

File tree

66 files changed

+1533
-2790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1533
-2790
lines changed

src/RestSharp.Serializers.NewtonsoftJson/RestClientExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ public static class RestClientExtensions {
77
/// </summary>
88
/// <param name="client"></param>
99
/// <returns></returns>
10-
public static IRestClient UseNewtonsoftJson(this IRestClient client) => client.UseSerializer(() => new JsonNetSerializer());
10+
public static RestClient UseNewtonsoftJson(this RestClient client) => client.UseSerializer(() => new JsonNetSerializer());
1111

1212
/// <summary>
1313
/// Use Newtonsoft.Json serializer with custom settings
1414
/// </summary>
1515
/// <param name="client"></param>
1616
/// <param name="settings">Newtonsoft.Json serializer settings</param>
1717
/// <returns></returns>
18-
public static IRestClient UseNewtonsoftJson(this IRestClient client, JsonSerializerSettings settings)
18+
public static RestClient UseNewtonsoftJson(this RestClient client, JsonSerializerSettings settings)
1919
=> client.UseSerializer(() => new JsonNetSerializer(settings));
2020
}

src/RestSharp.Serializers.SystemTextJson/RestSharp.Serializers.SystemTextJson.csproj

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/RestSharp/Authenticators/AuthenticatorBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ public abstract class AuthenticatorBase : IAuthenticator {
77

88
protected abstract ValueTask<Parameter> GetAuthenticationParameter(string accessToken);
99

10-
public async ValueTask Authenticate(RestClient client, IRestRequest request)
10+
public async ValueTask Authenticate(RestClient client, RestRequest request)
1111
=> request.AddOrUpdateParameter(await GetAuthenticationParameter(Token));
1212
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace RestSharp.Authenticators;
22

33
public interface IAuthenticator {
4-
ValueTask Authenticate(RestClient client, IRestRequest request);
4+
ValueTask Authenticate(RestClient client, RestRequest request);
55
}

src/RestSharp/Authenticators/JwtAuthenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class JwtAuthenticator : IAuthenticator {
1717
[PublicAPI]
1818
public void SetBearerToken(string accessToken) => _authHeader = $"Bearer {Ensure.NotEmpty(accessToken, nameof(accessToken))}";
1919

20-
public ValueTask Authenticate(RestClient client, IRestRequest request) {
20+
public ValueTask Authenticate(RestClient client, RestRequest request) {
2121
request.AddOrUpdateParameter("Authorization", _authHeader, ParameterType.HttpHeader);
2222
return default;
2323
}

src/RestSharp/Authenticators/OAuth/OAuth1Authenticator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class OAuth1Authenticator : IAuthenticator {
3939

4040
internal virtual string ClientPassword { get; set; }
4141

42-
public ValueTask Authenticate(RestClient client, IRestRequest request) {
42+
public ValueTask Authenticate(RestClient client, RestRequest request) {
4343
var workflow = new OAuthWorkflow {
4444
ConsumerKey = ConsumerKey,
4545
ConsumerSecret = ConsumerSecret,
@@ -220,7 +220,7 @@ public static OAuth1Authenticator ForProtectedResource(
220220
TokenSecret = accessTokenSecret
221221
};
222222

223-
void AddOAuthData(RestClient client, IRestRequest request, OAuthWorkflow workflow) {
223+
void AddOAuthData(RestClient client, RestRequest request, OAuthWorkflow workflow) {
224224
var requestUrl = client.BuildUriWithoutQueryParameters(request);
225225

226226
if (requestUrl.Contains('?'))
@@ -250,7 +250,7 @@ void AddOAuthData(RestClient client, IRestRequest request, OAuthWorkflow workflo
250250
? x => BaseQuery(x) && x.Name.StartsWith("oauth_")
251251
: (Func<Parameter, bool>)BaseQuery;
252252

253-
parameters.AddRange(client.Options.DefaultParameters.Where(query).ToWebParameters());
253+
parameters.AddRange(client.DefaultParameters.Where(query).ToWebParameters());
254254
parameters.AddRange(request.Parameters.Where(query).ToWebParameters());
255255

256256
if (Type == OAuthType.RequestToken)

src/RestSharp/Extensions/MiscExtensions.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
namespace RestSharp.Extensions;
1+
using System;
2+
3+
namespace RestSharp.Extensions;
24

35
/// <summary>
46
/// Extension method overload!
57
/// </summary>
6-
public static class MiscExtensions {
8+
static class MiscExtensions {
79
/// <summary>
810
/// Read a stream into a byte array
911
/// </summary>
1012
/// <param name="input">Stream to read</param>
13+
/// <param name="cancellationToken"></param>
1114
/// <returns>byte[]</returns>
12-
[Obsolete("This method will be removed soon. If you use it, please copy the code to your project.")]
13-
public static byte[] ReadAsBytes(this Stream input) {
15+
public static async Task<byte[]> ReadAsBytes(this Stream input, CancellationToken cancellationToken) {
1416
var buffer = new byte[16 * 1024];
1517

1618
using var ms = new MemoryStream();
1719

1820
int read;
19-
20-
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
21+
#if NETSTANDARD
22+
while ((read = await input.ReadAsync(buffer, 0, buffer.Length, cancellationToken)) > 0)
23+
#else
24+
while ((read = await input.ReadAsync(buffer, cancellationToken)) > 0)
25+
#endif
2126
ms.Write(buffer, 0, read);
2227

2328
return ms.ToArray();

src/RestSharp/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static string AddSpaces(this string pascalCasedWord)
158158

159159
internal static bool IsEmpty(this string? value) => string.IsNullOrWhiteSpace(value);
160160

161-
internal static bool IsNotEmpty(this string value) => !string.IsNullOrWhiteSpace(value);
161+
internal static bool IsNotEmpty(this string? value) => !string.IsNullOrWhiteSpace(value);
162162

163163
/// <summary>
164164
/// Return possible variants of a name for name matching.

src/RestSharp/Http.Async.cs

Lines changed: 0 additions & 245 deletions
This file was deleted.

0 commit comments

Comments
 (0)