.NET Format Style Fixes
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -39,21 +39,20 @@ public readonly partial struct MongoId : IEquatable<MongoId>
|
||||
Span<byte> 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);
|
||||
|
||||
@@ -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)}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user