Skip to content

Commit

Permalink
Misc Rider enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Dec 14, 2024
1 parent 0db414d commit acd0817
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions ArchiSteamFarm.CustomPlugins.PeriodicGC/PeriodicGCPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace ArchiSteamFarm.CustomPlugins.PeriodicGC;
internal sealed class PeriodicGCPlugin : IPlugin {
private const byte GCPeriod = 60; // In seconds

private static readonly object LockObject = new();
private static readonly Lock Lock = new();
private static readonly Timer PeriodicGCTimer = new(PerformGC);

[JsonInclude]
Expand All @@ -55,7 +55,7 @@ public Task OnLoaded() {

ASF.ArchiLogger.LogGenericWarning($"Periodic GC will occur every {timeSpan.ToHumanReadable()}. Please keep in mind that this plugin should be used for debugging tests only.");

lock (LockObject) {
lock (Lock) {
PeriodicGCTimer.Change(timeSpan, timeSpan);
}

Expand All @@ -65,7 +65,7 @@ public Task OnLoaded() {
private static void PerformGC(object? state = null) {
ASF.ArchiLogger.LogGenericWarning($"Performing GC, current memory: {GC.GetTotalMemory(false) / 1024} KB.");

lock (LockObject) {
lock (Lock) {
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true);
}
Expand Down
3 changes: 2 additions & 1 deletion ArchiSteamFarm.OfficialPlugins.Monitoring/TradeStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
// limitations under the License.

using System;
using System.Threading;
using ArchiSteamFarm.Steam.Exchange;

namespace ArchiSteamFarm.OfficialPlugins.Monitoring;

internal sealed class TradeStatistics {
private readonly object Lock = new();
private readonly Lock Lock = new();

internal int AcceptedOffers { get; private set; }
internal int BlacklistedOffers { get; private set; }
Expand Down
6 changes: 3 additions & 3 deletions ArchiSteamFarm/Core/AprilFools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace ArchiSteamFarm.Core;

internal static class AprilFools {
private static readonly object LockObject = new();
private static readonly Lock Lock = new();

// We don't care about CurrentCulture global config property, because April Fools are never initialized in this case
private static readonly CultureInfo OriginalCulture = CultureInfo.CurrentCulture;
Expand All @@ -49,7 +49,7 @@ internal static void Init(object? state = null) {

TimeSpan aprilFoolsEnd = TimeSpan.FromDays(1) - now.TimeOfDay;

lock (LockObject) {
lock (Lock) {
Timer.Change(aprilFoolsEnd + TimeSpan.FromMilliseconds(100), Timeout.InfiniteTimeSpan);
}

Expand All @@ -72,7 +72,7 @@ internal static void Init(object? state = null) {
// Timer can accept only dueTimes up to 2^32 - 2
uint dueTime = (uint) Math.Min(uint.MaxValue - 1, (ulong) aprilFoolsStart.TotalMilliseconds + 100);

lock (LockObject) {
lock (Lock) {
Timer.Change(dueTime, Timeout.Infinite);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ArchiSteamFarm/IPC/Integration/SwaggerItemsMinMaxAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace ArchiSteamFarm.IPC.Integration;
[PublicAPI]
public sealed class SwaggerItemsMinMaxAttribute : CustomSwaggerAttribute {

Check warning on line 31 in ArchiSteamFarm/IPC/Integration/SwaggerItemsMinMaxAttribute.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

RoslynAnalyzers Consider making public types internal

Because an application's API isn't typically referenced from outside the assembly, types can be made internal
public uint MaximumUint {
get => BackingMaximum.HasValue ? decimal.ToUInt32(BackingMaximum.Value) : default(uint);
get => BackingMaximum.HasValue ? decimal.ToUInt32(BackingMaximum.Value) : 0;
set => BackingMaximum = value;
}

public uint MinimumUint {
get => BackingMinimum.HasValue ? decimal.ToUInt32(BackingMinimum.Value) : default(uint);
get => BackingMinimum.HasValue ? decimal.ToUInt32(BackingMinimum.Value) : 0;
set => BackingMinimum = value;
}

Expand Down
4 changes: 2 additions & 2 deletions ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public async Task<bool> JoinGroup(ulong groupID) {
Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed);
Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request));

return default(ObjectResponse<T>?);
return null;
}
}

Expand All @@ -759,7 +759,7 @@ public async Task<bool> JoinGroup(ulong groupID) {
ObjectResponse<T>? response = await WebLimitRequest(host, async () => await WebBrowser.UrlGetToJsonObject<T>(request, headers, referer, requestOptions, maxTries, rateLimitingDelay, cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);

if (response == null) {
return default(ObjectResponse<T>?);
return null;
}

if (IsSessionExpiredUri(response.FinalUri)) {
Expand Down

0 comments on commit acd0817

Please sign in to comment.