< Summary

Information
Line coverage
20%
Covered lines: 2
Uncovered lines: 8
Coverable lines: 10
Total lines: 29
Line coverage: 20%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Read(...)100%11100%
Write(...)0%220%
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\JsonDocumentConverter.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.Text.Json.Schema;
 5using System.Text.Json.Nodes;
 6
 7namespace System.Text.Json.Serialization.Converters
 8{
 9    internal sealed class JsonDocumentConverter : JsonConverter<JsonDocument?>
 10    {
 111        public override bool HandleNull => true;
 12
 13        public override JsonDocument Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 
 66214            JsonDocument.ParseValue(ref reader, options.AllowDuplicateProperties);
 15
 16        public override void Write(Utf8JsonWriter writer, JsonDocument? value, JsonSerializerOptions options)
 017        {
 018            if (value is null)
 019            {
 020                writer.WriteNullValue();
 021                return;
 22            }
 23
 024            value.WriteTo(writer);
 025        }
 26
 027        internal override JsonSchema? GetSchema(JsonNumberHandling _) => JsonSchema.CreateTrueSchema();
 28    }
 29}