< Summary

Information
Class: System.Text.Json.Serialization.Converters.JsonDocumentConverter
Assembly: System.Text.Json
File(s): D:\runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Value\JsonDocumentConverter.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 29
Line coverage: 0%
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%110%
Write(...)0%220%
GetSchema(...)100%110%

File(s)

D:\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    {
 011        public override bool HandleNull => true;
 12
 13        public override JsonDocument Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 
 014            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}