diff --git a/src/ReportPortal.Client/Abstractions/Requests/CreateLogItemRequest.cs b/src/ReportPortal.Client/Abstractions/Requests/CreateLogItemRequest.cs index 36306e9f..a200b4fe 100644 --- a/src/ReportPortal.Client/Abstractions/Requests/CreateLogItemRequest.cs +++ b/src/ReportPortal.Client/Abstractions/Requests/CreateLogItemRequest.cs @@ -24,7 +24,6 @@ public class CreateLogItemRequest /// /// Date time of log item. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime Time { get; set; } = DateTime.UtcNow; /// diff --git a/src/ReportPortal.Client/Abstractions/Requests/FinishLaunchRequest.cs b/src/ReportPortal.Client/Abstractions/Requests/FinishLaunchRequest.cs index bdb158bb..a7bad2a0 100644 --- a/src/ReportPortal.Client/Abstractions/Requests/FinishLaunchRequest.cs +++ b/src/ReportPortal.Client/Abstractions/Requests/FinishLaunchRequest.cs @@ -1,6 +1,4 @@ -using ReportPortal.Client.Converters; -using System; -using System.Text.Json.Serialization; +using System; namespace ReportPortal.Client.Abstractions.Requests { @@ -12,7 +10,6 @@ public class FinishLaunchRequest /// /// Gets or sets the date and time when the launch execution is finished. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime EndTime { get; set; } = DateTime.UtcNow; } } diff --git a/src/ReportPortal.Client/Abstractions/Requests/FinishTestItemRequest.cs b/src/ReportPortal.Client/Abstractions/Requests/FinishTestItemRequest.cs index 19b53ee8..5412e533 100644 --- a/src/ReportPortal.Client/Abstractions/Requests/FinishTestItemRequest.cs +++ b/src/ReportPortal.Client/Abstractions/Requests/FinishTestItemRequest.cs @@ -20,7 +20,6 @@ public class FinishTestItemRequest /// /// Gets or sets the date and time when the test item is finished. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime EndTime { get; set; } = DateTime.UtcNow; /// diff --git a/src/ReportPortal.Client/Abstractions/Requests/MergeLaunchesRequest.cs b/src/ReportPortal.Client/Abstractions/Requests/MergeLaunchesRequest.cs index 774cf299..79627e20 100644 --- a/src/ReportPortal.Client/Abstractions/Requests/MergeLaunchesRequest.cs +++ b/src/ReportPortal.Client/Abstractions/Requests/MergeLaunchesRequest.cs @@ -30,13 +30,11 @@ public class MergeLaunchesRequest /// /// Gets or sets the date and time when the launch is executed. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime StartTime { get; set; } /// /// Gets or sets the date and time when the launch is finished. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime EndTime { get; set; } /// diff --git a/src/ReportPortal.Client/Abstractions/Requests/StartLaunchRequest.cs b/src/ReportPortal.Client/Abstractions/Requests/StartLaunchRequest.cs index fef20b54..0796f913 100644 --- a/src/ReportPortal.Client/Abstractions/Requests/StartLaunchRequest.cs +++ b/src/ReportPortal.Client/Abstractions/Requests/StartLaunchRequest.cs @@ -30,7 +30,6 @@ public class StartLaunchRequest /// /// Gets or sets the date and time when the launch is executed. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime StartTime { get; set; } = DateTime.UtcNow; /// diff --git a/src/ReportPortal.Client/Abstractions/Requests/StartTestItemRequest.cs b/src/ReportPortal.Client/Abstractions/Requests/StartTestItemRequest.cs index 084ae58a..fab85254 100644 --- a/src/ReportPortal.Client/Abstractions/Requests/StartTestItemRequest.cs +++ b/src/ReportPortal.Client/Abstractions/Requests/StartTestItemRequest.cs @@ -29,7 +29,6 @@ public class StartTestItemRequest /// /// Date time when new test item is created. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime StartTime { get; set; } = DateTime.UtcNow; /// diff --git a/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs index ee50d58c..5278a27c 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs @@ -45,13 +45,11 @@ public class LaunchResponse /// /// Gets or sets the start time of the launch. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime StartTime { get; set; } /// /// Gets or sets the end time of the launch. /// - [JsonConverter(typeof(NullableDateTimeUnixEpochConverter))] public DateTime? EndTime { get; set; } /// diff --git a/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs index e750a2ed..aa5eea67 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs @@ -34,7 +34,6 @@ public class LogItemResponse /// /// Gets or sets the time when the log item was created. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime Time { get; set; } /// diff --git a/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs index 9716d3f5..c62f621c 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs @@ -40,13 +40,11 @@ public class TestItemResponse /// /// Gets or sets the start time of the test item. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime StartTime { get; set; } /// /// Gets or sets the end time of the test item. /// - [JsonConverter(typeof(NullableDateTimeUnixEpochConverter))] public DateTime? EndTime { get; set; } /// @@ -191,7 +189,6 @@ public class ExternalSystemIssue /// /// Gets or sets the submit date of the external system issue. /// - [JsonConverter(typeof(DateTimeUnixEpochConverter))] public DateTime SubmitDate { get; set; } /// diff --git a/src/ReportPortal.Client/Converters/DateTimeUnixEpochConverter.cs b/src/ReportPortal.Client/Converters/DateTimeUnixEpochConverter.cs deleted file mode 100644 index 9dd8872a..00000000 --- a/src/ReportPortal.Client/Converters/DateTimeUnixEpochConverter.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace ReportPortal.Client.Converters -{ - sealed class DateTimeUnixEpochConverter : JsonConverter - { - private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var unixTime = reader.GetInt64(); - - return UNIX_EPOCH.AddMilliseconds(unixTime); - } - - public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) - { - var unixTime = Convert.ToInt64((value - UNIX_EPOCH).TotalMilliseconds); - - writer.WriteNumberValue(unixTime); - } - } - - sealed class NullableDateTimeUnixEpochConverter : JsonConverter - { - private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var unixTime = reader.GetInt64(); - - return UNIX_EPOCH.AddMilliseconds(unixTime); - } - - public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options) - { - var unixTime = Convert.ToInt64((value - UNIX_EPOCH).Value.TotalMilliseconds); - - writer.WriteNumberValue(unixTime); - } - } -}