Refactor: Rename GetDynamicAsync to GetAsync

Renamed `GetDynamicAsync` to `GetAsync` across `ProfileApi.cs`,
`RecActionApi.cs`, and `ResultApi.cs` to improve consistency
and align with naming conventions for asynchronous methods.

Updated XML documentation to clarify that the non-generic
`GetAsync` overload returns a dynamically deserialized payload,
typically a `System.Text.Json.JsonElement`. Highlighted its
relation to the generic `GetAsync<T>` method.

Adjusted method signatures for both `NETFRAMEWORK` and
non-`NETFRAMEWORK` code paths. Updated test files
(`ProfileApiTests.cs`, `RecActionApiTests.cs`, and
`ResultApiTests.cs`) to reflect the renaming, including
test method names and assertions.

These changes enhance code readability, maintainability,
and consistency.
This commit is contained in:
2026-05-20 13:50:55 +02:00
parent 12f4bf8828
commit afd5cd5fbd
6 changed files with 35 additions and 29 deletions

View File

@@ -42,12 +42,14 @@ namespace ReC.Client.Api
} }
/// <summary> /// <summary>
/// Retrieves profiles and returns a dynamically deserialized payload. /// Retrieves profiles and returns a dynamically deserialized payload
/// (typically a <see cref="System.Text.Json.JsonElement"/>). This is the non-generic
/// overload of <see cref="GetAsync{T}"/>.
/// </summary> /// </summary>
#if NETFRAMEWORK #if NETFRAMEWORK
public Task<dynamic> GetDynamicAsync(long? id = null, bool includeActions = true, CancellationToken cancel = default) public Task<dynamic> GetAsync(long? id = null, bool includeActions = true, CancellationToken cancel = default)
#else #else
public Task<dynamic?> GetDynamicAsync(long? id = null, bool includeActions = true, CancellationToken cancel = default) public Task<dynamic?> GetAsync(long? id = null, bool includeActions = true, CancellationToken cancel = default)
#endif #endif
{ {
return GetAsync<object>(id, includeActions, cancel); return GetAsync<object>(id, includeActions, cancel);

View File

@@ -75,12 +75,14 @@ namespace ReC.Client.Api
} }
/// <summary> /// <summary>
/// Retrieves Rec actions and returns a dynamically deserialized payload. /// Retrieves Rec actions and returns a dynamically deserialized payload
/// (typically a <see cref="System.Text.Json.JsonElement"/>). This is the non-generic
/// overload of <see cref="GetAsync{T}"/>.
/// </summary> /// </summary>
#if NETFRAMEWORK #if NETFRAMEWORK
public Task<dynamic> GetDynamicAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default) public Task<dynamic> GetAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default)
#else #else
public Task<dynamic?> GetDynamicAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default) public Task<dynamic?> GetAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default)
#endif #endif
{ {
return GetAsync<object>(profileId, invoked, cancel); return GetAsync<object>(profileId, invoked, cancel);

View File

@@ -50,12 +50,14 @@ namespace ReC.Client.Api
} }
/// <summary> /// <summary>
/// Retrieves results with optional filters and returns a dynamically deserialized payload. /// Retrieves results with optional filters and returns a dynamically deserialized payload
/// (typically a <see cref="System.Text.Json.JsonElement"/>). This is the non-generic
/// overload of <see cref="GetAsync{T}"/>.
/// </summary> /// </summary>
#if NETFRAMEWORK #if NETFRAMEWORK
public Task<dynamic> GetDynamicAsync(long? id = null, long? actionId = null, long? profileId = null, string batchId = null, bool includeAction = true, bool includeProfile = false, bool lastBatch = false, CancellationToken cancel = default) public Task<dynamic> GetAsync(long? id = null, long? actionId = null, long? profileId = null, string batchId = null, bool includeAction = true, bool includeProfile = false, bool lastBatch = false, CancellationToken cancel = default)
#else #else
public Task<dynamic?> GetDynamicAsync(long? id = null, long? actionId = null, long? profileId = null, string? batchId = null, bool includeAction = true, bool includeProfile = false, bool lastBatch = false, CancellationToken cancel = default) public Task<dynamic?> GetAsync(long? id = null, long? actionId = null, long? profileId = null, string? batchId = null, bool includeAction = true, bool includeProfile = false, bool lastBatch = false, CancellationToken cancel = default)
#endif #endif
{ {
return GetAsync<object>(id, actionId, profileId, batchId, includeAction, includeProfile, lastBatch, cancel); return GetAsync<object>(id, actionId, profileId, batchId, includeAction, includeProfile, lastBatch, cancel);

View File

@@ -36,13 +36,13 @@ public class ProfileApiTests : RecClientTestBase
} }
[Test] [Test]
public void GetDynamicAsync_with_unknown_id_throws_not_found() public void GetAsync_non_generic_with_unknown_id_throws_not_found()
{ {
var (client, scope) = CreateScopedClient(); var (client, scope) = CreateScopedClient();
using var _ = scope; using var _ = scope;
var ex = Assert.ThrowsAsync<ReCApiException>(async () => var ex = Assert.ThrowsAsync<ReCApiException>(async () =>
await client.Profiles.GetDynamicAsync(id: long.MaxValue)); await client.Profiles.GetAsync(id: long.MaxValue));
Assert.That(ex, Is.Not.Null); Assert.That(ex, Is.Not.Null);
Assert.That(ex!.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); Assert.That(ex!.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
@@ -50,14 +50,14 @@ public class ProfileApiTests : RecClientTestBase
} }
[Test] [Test]
public async Task GetDynamicAsync_without_filters_returns_dynamic_payload_or_throws_not_found() public async Task GetAsync_non_generic_returns_dynamic_payload_or_throws_not_found()
{ {
var (client, scope) = CreateScopedClient(); var (client, scope) = CreateScopedClient();
using var _ = scope; using var _ = scope;
try try
{ {
dynamic profiles = await client.Profiles.GetDynamicAsync(); dynamic? profiles = await client.Profiles.GetAsync();
Assert.That(profiles, Is.Not.Null); Assert.That(profiles, Is.Not.Null);
Assert.That(profiles, Is.TypeOf<JsonElement>()); Assert.That(profiles, Is.TypeOf<JsonElement>());
} }

View File

@@ -43,14 +43,14 @@ public class RecActionApiTests : RecClientTestBase
} }
[Test] [Test]
public async Task GetDynamicAsync_without_filters_returns_dynamic_payload_or_throws_not_found() public async Task GetAsync_non_generic_returns_dynamic_payload_or_throws_not_found()
{ {
var (client, scope) = CreateScopedClient(); var (client, scope) = CreateScopedClient();
using var _ = scope; using var _ = scope;
try try
{ {
dynamic? actions = await client.RecActions.GetDynamicAsync(); dynamic? actions = await client.RecActions.GetAsync();
Assert.That(actions, Is.Not.Null); Assert.That(actions, Is.Not.Null);
Assert.That(actions, Is.TypeOf<JsonElement>()); Assert.That(actions, Is.TypeOf<JsonElement>());
Assert.That(((JsonElement)actions).ValueKind, Is.EqualTo(JsonValueKind.Array)); Assert.That(((JsonElement)actions).ValueKind, Is.EqualTo(JsonValueKind.Array));
@@ -104,13 +104,13 @@ public class RecActionApiTests : RecClientTestBase
} }
[Test] [Test]
public void GetDynamicAsync_with_unknown_profile_throws_not_found() public void GetAsync_non_generic_with_unknown_profile_throws_not_found()
{ {
var (client, scope) = CreateScopedClient(); var (client, scope) = CreateScopedClient();
using var _ = scope; using var _ = scope;
var ex = Assert.ThrowsAsync<ReCApiException>(async () => var ex = Assert.ThrowsAsync<ReCApiException>(async () =>
await client.RecActions.GetDynamicAsync(profileId: long.MaxValue)); await client.RecActions.GetAsync(profileId: long.MaxValue));
Assert.That(ex, Is.Not.Null); Assert.That(ex, Is.Not.Null);
Assert.That(ex!.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); Assert.That(ex!.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));

View File

@@ -38,14 +38,14 @@ public class ResultApiTests : RecClientTestBase
} }
[Test] [Test]
public async Task GetDynamicAsync_without_filters_returns_dynamic_payload_or_throws_not_found() public async Task GetAsync_non_generic_returns_dynamic_payload_or_throws_not_found()
{ {
var (client, scope) = CreateScopedClient(); var (client, scope) = CreateScopedClient();
using var _ = scope; using var _ = scope;
try try
{ {
dynamic results = await client.Results.GetDynamicAsync(); dynamic? results = await client.Results.GetAsync();
Assert.That(results, Is.Not.Null); Assert.That(results, Is.Not.Null);
Assert.That(results, Is.TypeOf<JsonElement>()); Assert.That(results, Is.TypeOf<JsonElement>());
} }