diff --git a/Libraries/SPTarkov.Server.Core/Extensions/MongoIDExtensions.cs b/Libraries/SPTarkov.Server.Core/Extensions/MongoIDExtensions.cs index 6b742e0e..de8f7901 100644 --- a/Libraries/SPTarkov.Server.Core/Extensions/MongoIDExtensions.cs +++ b/Libraries/SPTarkov.Server.Core/Extensions/MongoIDExtensions.cs @@ -23,9 +23,7 @@ namespace SPTarkov.Server.Core.Extensions { var c = span[i]; var isHex = - (c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F'); + (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); if (!isHex) { @@ -55,9 +53,7 @@ namespace SPTarkov.Server.Core.Extensions { var c = span[i]; var isHex = - (c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F'); + (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); if (!isHex) { diff --git a/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs b/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs index 48acc184..5b423b63 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs @@ -39,21 +39,20 @@ public readonly partial struct MongoId : IEquatable Span objectId = stackalloc byte[12]; // 4 bytes: current timestamp (big endian) - var timestamp = (int) DateTimeOffset.UtcNow - .ToUnixTimeSeconds(); - objectId[0] = (byte) (timestamp >> 24); - objectId[1] = (byte) (timestamp >> 16); - objectId[2] = (byte) (timestamp >> 8); - objectId[3] = (byte) timestamp; + var timestamp = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + objectId[0] = (byte)(timestamp >> 24); + objectId[1] = (byte)(timestamp >> 16); + objectId[2] = (byte)(timestamp >> 8); + objectId[3] = (byte)timestamp; // 5 bytes: random machine/process identifier Random.Shared.NextBytes(objectId.Slice(4, 5)); // 3 bytes: random counter fallback (no static state) var counter = Random.Shared.Next(0, 0xFFFFFF); - objectId[9] = (byte) (counter >> 16); - objectId[10] = (byte) (counter >> 8); - objectId[11] = (byte) counter; + objectId[9] = (byte)(counter >> 16); + objectId[10] = (byte)(counter >> 8); + objectId[11] = (byte)counter; // Convert to lowercase hex string (24 chars) return Convert.ToHexStringLower(objectId); diff --git a/UnitTests/Tests/Utils/MongoIdTests.cs b/UnitTests/Tests/Utils/MongoIdTests.cs index f5e4072b..bd137668 100644 --- a/UnitTests/Tests/Utils/MongoIdTests.cs +++ b/UnitTests/Tests/Utils/MongoIdTests.cs @@ -29,7 +29,11 @@ namespace UnitTests.Tests.Utils } } - Assert.AreEqual(0, invalidIds.Count, $"Invalid MongoIds found: {string.Join(", ", invalidIds)}"); + Assert.AreEqual( + 0, + invalidIds.Count, + $"Invalid MongoIds found: {string.Join(", ", invalidIds)}" + ); } } }