diff --git a/appveyor.yml b/appveyor.yml index 53d8c2dd..2537d76b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - build_version: 8.0.0 + build_version: 8.1.0 version: $(build_version)-{build} image: Visual Studio 2022 configuration: Release diff --git a/samples/ASP.NETCore/WebApplication/WebApplication.csproj b/samples/ASP.NETCore/WebApplication/WebApplication.csproj index b0c81d2a..a08f56de 100644 --- a/samples/ASP.NETCore/WebApplication/WebApplication.csproj +++ b/samples/ASP.NETCore/WebApplication/WebApplication.csproj @@ -8,7 +8,7 @@ - + diff --git a/samples/ConsoleApp/ConsoleApp.csproj b/samples/ConsoleApp/ConsoleApp.csproj index 6c148f16..f5928dab 100644 --- a/samples/ConsoleApp/ConsoleApp.csproj +++ b/samples/ConsoleApp/ConsoleApp.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/ConfigCat.Client.Tests/UtilsTest.cs b/src/ConfigCat.Client.Tests/UtilsTest.cs index 25cc5bc5..d1ce7945 100644 --- a/src/ConfigCat.Client.Tests/UtilsTest.cs +++ b/src/ConfigCat.Client.Tests/UtilsTest.cs @@ -17,11 +17,12 @@ public void ArrayUtils_ToHexString_Works(byte[] bytes, string expected) Assert.AreEqual(expected, bytes.ToHexString()); } - [DataRow("-62135596801", -1L)] - [DataRow("-62135596800", 0L)] + [DataRow("-62135596800001", -1L)] + [DataRow("-62135596800000", 0L)] [DataRow("0", 621355968000000000L)] - [DataRow("+253402300799", 3155378975990000000L)] - [DataRow("+253402300800", -1L)] + [DataRow("+253402300799999", 3155378975999990000L)] + [DataRow("+253402300800000", -1L)] + [DataRow(".0", -1L)] [DataRow("1.0", -1L)] [DataRow("1x", -1L)] [DataTestMethod] diff --git a/src/ConfigCatClient/Logging/LogLevel.cs b/src/ConfigCatClient/Logging/LogLevel.cs index 3ed5989d..9ad09074 100644 --- a/src/ConfigCatClient/Logging/LogLevel.cs +++ b/src/ConfigCatClient/Logging/LogLevel.cs @@ -18,7 +18,7 @@ public enum LogLevel /// Error = 1, /// - /// Warning and Error events should be logged. Information and Debug events are discarded. + /// Warning and Error events are logged. Information and Debug events are discarded. /// Warning = 2, /// diff --git a/src/ConfigCatClient/ProjectConfig.cs b/src/ConfigCatClient/ProjectConfig.cs index 01476b1d..0b57bda9 100644 --- a/src/ConfigCatClient/ProjectConfig.cs +++ b/src/ConfigCatClient/ProjectConfig.cs @@ -7,7 +7,7 @@ namespace ConfigCat.Client; internal sealed class ProjectConfig { - internal const string SerializationFormatVersion = "v1"; + internal const string SerializationFormatVersion = "v2"; public static readonly ProjectConfig Empty = new(null, null, DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc), null); @@ -40,8 +40,8 @@ public bool IsExpired(TimeSpan expiration) public static DateTime GenerateTimeStamp() { var utcNow = DateTime.UtcNow; - // Remove the sub-second part as we need second precision only. - return utcNow.AddTicks(-(utcNow.Ticks % TimeSpan.TicksPerSecond)); + // Remove the sub-millisecond part as we need millisecond precision only. + return utcNow.AddTicks(-(utcNow.Ticks % TimeSpan.TicksPerMillisecond)); } public static string Serialize(ProjectConfig config) diff --git a/src/ConfigCatClient/RefreshResult.cs b/src/ConfigCatClient/RefreshResult.cs index b51fad89..b400a4ca 100644 --- a/src/ConfigCatClient/RefreshResult.cs +++ b/src/ConfigCatClient/RefreshResult.cs @@ -4,7 +4,7 @@ namespace ConfigCat.Client; /// -/// Contains the result of a or operation. +/// Contains the result of an or operation. /// public readonly record struct RefreshResult { diff --git a/src/ConfigCatClient/Utils/DateTimeUtils.cs b/src/ConfigCatClient/Utils/DateTimeUtils.cs index 8c3096b7..dba653d8 100644 --- a/src/ConfigCatClient/Utils/DateTimeUtils.cs +++ b/src/ConfigCatClient/Utils/DateTimeUtils.cs @@ -8,16 +8,15 @@ internal static class DateTimeUtils public static string ToUnixTimeStamp(this DateTime dateTime) { #if !NET45 - var seconds = new DateTimeOffset(dateTime).ToUnixTimeSeconds(); + var milliseconds = new DateTimeOffset(dateTime).ToUnixTimeMilliseconds(); #else - // Based on: https://github.com/dotnet/runtime/blob/v6.0.13/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.cs#L607 + // Based on: https://github.com/dotnet/runtime/blob/v6.0.13/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.cs#L629 - const long unixEpochSeconds = 62_135_596_800L; - - var seconds = dateTime.Ticks / TimeSpan.TicksPerSecond - unixEpochSeconds; + const long unixEpochMilliseconds = 62_135_596_800_000L; + var milliseconds = dateTime.Ticks / TimeSpan.TicksPerMillisecond - unixEpochMilliseconds; #endif - return seconds.ToString(CultureInfo.InvariantCulture); + return milliseconds.ToString(CultureInfo.InvariantCulture); } public static bool TryParseUnixTimeStamp(ReadOnlySpan span, out DateTime dateTime) @@ -28,33 +27,33 @@ public static bool TryParseUnixTimeStamp(ReadOnlySpan span, out DateTime d var slice = span.ToString(); #endif - if (!long.TryParse(slice, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var seconds)) + if (!long.TryParse(slice, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var milliseconds)) { dateTime = default; return false; } #if !NET45 - try { dateTime = DateTimeOffset.FromUnixTimeSeconds(seconds).UtcDateTime; } + try { dateTime = DateTimeOffset.FromUnixTimeMilliseconds(milliseconds).UtcDateTime; } catch (ArgumentOutOfRangeException) { dateTime = default; return false; } #else - // Based on: https://github.com/dotnet/runtime/blob/v6.0.13/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.cs#L431 + // Based on: https://github.com/dotnet/runtime/blob/v6.0.13/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.cs#L443 - const long unixEpochSeconds = 62_135_596_800L; - const long unixMinSeconds = 0 / TimeSpan.TicksPerSecond - unixEpochSeconds; - const long unixMaxSeconds = 3_155_378_975_999_999_999L / TimeSpan.TicksPerSecond - unixEpochSeconds; + const long unixEpochMilliseconds = 62_135_596_800_000L; + const long unixMinMilliseconds = 0 / TimeSpan.TicksPerMillisecond - unixEpochMilliseconds; + const long unixMaxMilliseconds = 3_155_378_975_999_999_999L / TimeSpan.TicksPerMillisecond - unixEpochMilliseconds; - if (seconds < unixMinSeconds || seconds > unixMaxSeconds) + if (milliseconds < unixMinMilliseconds || milliseconds > unixMaxMilliseconds) { dateTime = default; return false; } - long ticks = (seconds + unixEpochSeconds) * TimeSpan.TicksPerSecond; + var ticks = (milliseconds + unixEpochMilliseconds) * TimeSpan.TicksPerMillisecond; dateTime = new DateTime(ticks, DateTimeKind.Utc); #endif