< Summary

Information
Line coverage
14%
Covered lines: 2
Uncovered lines: 12
Coverable lines: 14
Total lines: 34
Line coverage: 14.2%
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%

File(s)

C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\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)
 65212        {
 65213            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    }
 34}