< Summary

Line coverage
13%
Covered lines: 2
Uncovered lines: 13
Coverable lines: 15
Total lines: 37
Line coverage: 13.3%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Read(...)100%1166.66%
Write(...)100%110%
ReadAsPropertyNameCore(...)100%110%
WriteAsPropertyNameCore(...)100%110%
GetSchema(...)100%110%
GetSupportedJsonValueTypes(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/DateTimeConverter.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Text.Json.Schema;
 6
 7namespace System.Text.Json.Serialization.Converters
 8{
 9    internal sealed class DateTimeConverter : JsonPrimitiveConverter<DateTime>
 10    {
 11        public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 1612        {
 1613            return reader.GetDateTime();
 014        }
 15
 16        public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
 017        {
 018            writer.WriteStringValue(value);
 019        }
 20
 21        internal override DateTime ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerO
 022        {
 023            Debug.Assert(reader.TokenType == JsonTokenType.PropertyName);
 024            return reader.GetDateTimeNoValidation();
 025        }
 26
 27        internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions opti
 028        {
 029            writer.WritePropertyName(value);
 030        }
 31
 032        internal override JsonSchema? GetSchema(JsonNumberHandling _) => new JsonSchema { Type = JsonSchemaType.String, 
 33
 034        internal override JsonValueType GetSupportedJsonValueTypes(JsonNumberHandling _) => JsonValueType.String;
 35    }
 36}
 37