Skip to content

Commit 3c000d4

Browse files
committed
chore(repo): ran VS code clean-up task
1 parent 8fd565a commit 3c000d4

7 files changed

Lines changed: 72 additions & 38 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ dotnet_diagnostic.CS1591.severity = none
5151
dotnet_diagnostic.CA1707.severity = none
5252
dotnet_diagnostic.CA1716.severity = none
5353

54+
# CS1591: Missing XML comment for publicly visible type or member
55+
dotnet_diagnostic.CS1591.severity = error
56+
5457
[*.json]
5558
indent_size = 2
5659

src/GoAffPro.Client/Events/ProductDetectedEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using GoAffPro.Client.Generated.Models;
2-
31
namespace GoAffPro.Client.Events;
42

53
///// <summary>

src/GoAffPro.Client/Events/TransactionDetectedEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using GoAffPro.Client.Generated.Models;
2-
31
namespace GoAffPro.Client.Events;
42

53
///// <summary>

src/GoAffPro.Client/GoAffPro.Client.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<PackageProjectUrl>https://github.com/Agash/GoAffPro.Client</PackageProjectUrl>
1313
<PackageReadmeFile>README.md</PackageReadmeFile>
1414
<PackageTags>goaffpro;affiliate;marketing;api;client;dotnet</PackageTags>
15+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
16+
<WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors>
1517
<NoWarn>$(NoWarn);CS8981;CA1708</NoWarn>
1618
</PropertyGroup>
1719

src/GoAffPro.Client/GoAffProClient.cs

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
using GoAffPro.Client.Events;
55
using GoAffPro.Client.Exceptions;
66
using GoAffPro.Client.Generated.Models;
7-
using GoAffPro.Client.Generated.User.Feed.Orders;
87
using GoAffPro.Client.Generated.User.Sites;
98
using GoAffPro.Client.Policies;
109
using Microsoft.Extensions.Http;
1110
using Microsoft.Kiota.Abstractions;
1211
using Microsoft.Kiota.Abstractions.Authentication;
1312
using Microsoft.Kiota.Http.HttpClientLibrary;
14-
using GetSiteFieldsQueryParameterType = GoAffPro.Client.Generated.User.Sites.GetFieldsQueryParameterType;
1513
using GetOrderFieldsQueryParameterType = GoAffPro.Client.Generated.User.Feed.Orders.GetFieldsQueryParameterType;
14+
using GetSiteFieldsQueryParameterType = GoAffPro.Client.Generated.User.Sites.GetFieldsQueryParameterType;
1615

1716
namespace GoAffPro.Client;
1817

@@ -241,9 +240,9 @@ await Api.User.Sites.GetAsync(config =>
241240
config.QueryParameters.StatusAsGetStatusQueryParameterType = status.ToUpperInvariant() switch
242241
{
243242
"APPROVED" => GetStatusQueryParameterType.Approved,
244-
"PENDING" => GetStatusQueryParameterType.Pending,
245-
"BLOCKED" => GetStatusQueryParameterType.Blocked,
246-
_ => null,
243+
"PENDING" => GetStatusQueryParameterType.Pending,
244+
"BLOCKED" => GetStatusQueryParameterType.Blocked,
245+
_ => null,
247246
};
248247
}
249248
}, cancellationToken).ConfigureAwait(false)
@@ -310,25 +309,34 @@ public async Task StartEventObserverAsync(
310309

311310
_ = RewardDetected; // keep obsolete member in compiled output
312311

313-
DateTimeOffset lastOrderPoll = OrderObserverStartTime ?? DateTimeOffset.UtcNow;
312+
DateTimeOffset lastOrderPoll = OrderObserverStartTime ?? DateTimeOffset.UtcNow;
314313
DateTimeOffset lastTrafficPoll = TrafficObserverStartTime ?? DateTimeOffset.UtcNow;
315-
DateTimeOffset lastPayoutPoll = PayoutObserverStartTime ?? DateTimeOffset.UtcNow;
314+
DateTimeOffset lastPayoutPoll = PayoutObserverStartTime ?? DateTimeOffset.UtcNow;
316315

317316
while (!cancellationToken.IsCancellationRequested)
318317
{
319318
DateTimeOffset orderTo = DateTimeOffset.UtcNow;
320319
foreach (UserOrderFeedItem order in await PollOrdersAsync(lastOrderPoll, orderTo, validatedPageSize, cancellationToken).ConfigureAwait(false))
320+
{
321321
OrderDetected?.Invoke(this, new OrderDetectedEventArgs(order));
322+
}
323+
322324
lastOrderPoll = orderTo;
323325

324326
DateTimeOffset trafficTo = DateTimeOffset.UtcNow;
325327
foreach (UserTrafficFeedItem item in await PollTrafficAsync(lastTrafficPoll, trafficTo, validatedPageSize, cancellationToken).ConfigureAwait(false))
328+
{
326329
TrafficDetected?.Invoke(this, new TrafficDetectedEventArgs(item));
330+
}
331+
327332
lastTrafficPoll = trafficTo;
328333

329334
DateTimeOffset payoutTo = DateTimeOffset.UtcNow;
330335
foreach (UserPayoutFeedItem payout in await PollPayoutsAsync(lastPayoutPoll, payoutTo, validatedPageSize, cancellationToken).ConfigureAwait(false))
336+
{
331337
PayoutDetected?.Invoke(this, new PayoutDetectedEventArgs(payout));
338+
}
339+
332340
lastPayoutPoll = payoutTo;
333341

334342
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
@@ -353,7 +361,10 @@ public async IAsyncEnumerable<UserOrderFeedItem> NewOrdersAsync(
353361
{
354362
DateTimeOffset to = DateTimeOffset.UtcNow;
355363
foreach (UserOrderFeedItem order in await PollOrdersAsync(lastPoll, to, size, cancellationToken).ConfigureAwait(false))
364+
{
356365
yield return order;
366+
}
367+
357368
lastPoll = to;
358369
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
359370
}
@@ -373,7 +384,10 @@ public async IAsyncEnumerable<UserTrafficFeedItem> NewTrafficAsync(
373384
{
374385
DateTimeOffset to = DateTimeOffset.UtcNow;
375386
foreach (UserTrafficFeedItem item in await PollTrafficAsync(lastPoll, to, size, cancellationToken).ConfigureAwait(false))
387+
{
376388
yield return item;
389+
}
390+
377391
lastPoll = to;
378392
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
379393
}
@@ -393,7 +407,10 @@ public async IAsyncEnumerable<UserPayoutFeedItem> NewPayoutsAsync(
393407
{
394408
DateTimeOffset to = DateTimeOffset.UtcNow;
395409
foreach (UserPayoutFeedItem payout in await PollPayoutsAsync(lastPoll, to, size, cancellationToken).ConfigureAwait(false))
410+
{
396411
yield return payout;
412+
}
413+
397414
lastPoll = to;
398415
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
399416
}
@@ -414,7 +431,10 @@ public async IAsyncEnumerable<UserProductFeedItem> NewProductsAsync(
414431
(IReadOnlyList<UserProductFeedItem> products, int? nextId) = await PollProductsAsync(lastId, size, cancellationToken).ConfigureAwait(false);
415432
lastId = nextId;
416433
foreach (UserProductFeedItem product in products)
434+
{
417435
yield return product;
436+
}
437+
418438
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
419439
}
420440
}
@@ -434,7 +454,10 @@ public async IAsyncEnumerable<UserTransactionItem> NewTransactionsAsync(
434454
(IReadOnlyList<UserTransactionItem> transactions, int? nextId) = await PollTransactionsAsync(lastId, size, cancellationToken).ConfigureAwait(false);
435455
lastId = nextId;
436456
foreach (UserTransactionItem tx in transactions)
457+
{
437458
yield return tx;
459+
}
460+
438461
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
439462
}
440463
}
@@ -456,7 +479,11 @@ public async IAsyncEnumerable<UserRewardFeedItem> NewRewardsAsync(
456479
/// <summary>Disposes resources owned by this client.</summary>
457480
public void Dispose()
458481
{
459-
if (!_disposeHttpClient) return;
482+
if (!_disposeHttpClient)
483+
{
484+
return;
485+
}
486+
460487
(_requestAdapter as IDisposable)?.Dispose();
461488
_httpClient.Dispose();
462489
}
@@ -551,15 +578,19 @@ await Api.User.Feed.Products.GetAsync(config =>
551578
?? new UserProductFeedResponse()).ConfigureAwait(false);
552579

553580
if (response.Products is not { Count: > 0 })
581+
{
554582
return ([], lastId);
583+
}
555584

556585
int? maxId = response.Products
557586
.Select(p => ToNullableInt(p.ProductId) ?? ToNullableInt(p.Id))
558587
.Where(v => v.HasValue).Select(v => v!.Value)
559588
.DefaultIfEmpty(lastId ?? int.MinValue).Max();
560589

561590
if (!lastId.HasValue)
591+
{
562592
return ([], maxId == int.MinValue ? null : maxId);
593+
}
563594

564595
var newItems = response.Products
565596
.Where(p => { int? id = ToNullableInt(p.ProductId) ?? ToNullableInt(p.Id); return id > lastId; })
@@ -581,14 +612,18 @@ await Api.User.Feed.Transactions.GetAsync(config =>
581612
?? new UserTransactionFeedResponse()).ConfigureAwait(false);
582613

583614
if (response.Transactions is not { Count: > 0 })
615+
{
584616
return ([], lastId);
617+
}
585618

586619
int? maxId = response.Transactions
587620
.Select(t => t.TxId).Where(v => v.HasValue).Select(v => v!.Value)
588621
.DefaultIfEmpty(lastId ?? int.MinValue).Max();
589622

590623
if (!lastId.HasValue)
624+
{
591625
return ([], maxId == int.MinValue ? null : maxId);
626+
}
592627

593628
var newItems = response.Transactions
594629
.Where(t => t.TxId > lastId)
@@ -598,11 +633,15 @@ await Api.User.Feed.Transactions.GetAsync(config =>
598633
return (newItems, maxId == int.MinValue ? lastId : maxId);
599634
}
600635

601-
private static int? ToNullableInt(UserProductFeedItem.UserProductFeedItem_product_id? v) =>
602-
v?.Integer ?? (int.TryParse(v?.String, NumberStyles.Integer, CultureInfo.InvariantCulture, out int p) ? p : null);
636+
private static int? ToNullableInt(UserProductFeedItem.UserProductFeedItem_product_id? v)
637+
{
638+
return v?.Integer ?? (int.TryParse(v?.String, NumberStyles.Integer, CultureInfo.InvariantCulture, out int p) ? p : null);
639+
}
603640

604-
private static int? ToNullableInt(UserProductFeedItem.UserProductFeedItem_id? v) =>
605-
v?.Integer ?? (int.TryParse(v?.String, NumberStyles.Integer, CultureInfo.InvariantCulture, out int p) ? p : null);
641+
private static int? ToNullableInt(UserProductFeedItem.UserProductFeedItem_id? v)
642+
{
643+
return v?.Integer ?? (int.TryParse(v?.String, NumberStyles.Integer, CultureInfo.InvariantCulture, out int p) ? p : null);
644+
}
606645

607646
private static HttpClient CreateHttpClient(GoAffProClientOptions options)
608647
{
@@ -625,8 +664,10 @@ private static GoAffProClientOptions ValidateOptions(GoAffProClientOptions optio
625664
return options;
626665
}
627666

628-
private static int ValidatePageSize(int pageSize) =>
629-
pageSize > 0 ? pageSize : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "Page size must be greater than zero.");
667+
private static int ValidatePageSize(int pageSize)
668+
{
669+
return pageSize > 0 ? pageSize : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "Page size must be greater than zero.");
670+
}
630671

631672
private static async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
632673
{

src/GoAffPro.Client/GoAffProUtils.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ public static class GoAffProUtils
3636
/// </example>
3737
public static decimal? ParseMonetary(string? value)
3838
{
39-
if (string.IsNullOrWhiteSpace(value))
40-
{
41-
return null;
42-
}
43-
44-
return decimal.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out decimal result)
39+
return string.IsNullOrWhiteSpace(value)
40+
? null
41+
: decimal.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out decimal result)
4542
? result
4643
: null;
4744
}
@@ -59,12 +56,9 @@ public static class GoAffProUtils
5956
/// </returns>
6057
public static DateTimeOffset? ParseTimestamp(string? value)
6158
{
62-
if (string.IsNullOrWhiteSpace(value))
63-
{
64-
return null;
65-
}
66-
67-
return DateTimeOffset.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out DateTimeOffset result)
59+
return string.IsNullOrWhiteSpace(value)
60+
? null
61+
: DateTimeOffset.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out DateTimeOffset result)
6862
? result.ToUniversalTime()
6963
: null;
7064
}

src/GoAffPro.Client/Policies/RetryPolicies.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ public static class RetryPolicies
2828
/// <returns>An async Polly retry policy.</returns>
2929
public static IAsyncPolicy<HttpResponseMessage> CreateTransientRetryPolicy(int retryCount = 3)
3030
{
31-
if (retryCount <= 0)
32-
return Policy.NoOpAsync<HttpResponseMessage>();
33-
34-
return HttpPolicyExtensions
31+
return retryCount <= 0
32+
? Policy.NoOpAsync<HttpResponseMessage>()
33+
: HttpPolicyExtensions
3534
.HandleTransientHttpError()
3635
.OrResult(static r => r.StatusCode == HttpStatusCode.TooManyRequests)
3736
.WaitAndRetryAsync(
@@ -59,10 +58,9 @@ public static IAsyncPolicy<HttpResponseMessage> CreateCircuitBreakerPolicy(
5958
int? handledEventsAllowedBeforeBreaking = 5,
6059
TimeSpan? durationOfBreak = null)
6160
{
62-
if (handledEventsAllowedBeforeBreaking is not > 0)
63-
return Policy.NoOpAsync<HttpResponseMessage>();
64-
65-
return HttpPolicyExtensions
61+
return handledEventsAllowedBeforeBreaking is not > 0
62+
? Policy.NoOpAsync<HttpResponseMessage>()
63+
: HttpPolicyExtensions
6664
.HandleTransientHttpError()
6765
.OrResult(static r => r.StatusCode == HttpStatusCode.TooManyRequests)
6866
.CircuitBreakerAsync(

0 commit comments

Comments
 (0)