< Summary

Information
Line coverage
25%
Covered lines: 4
Uncovered lines: 12
Coverable lines: 16
Total lines: 34
Line coverage: 25%
Branch coverage
25%
Covered branches: 1
Total branches: 4
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Read(...)50%2266.66%
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\ByteArrayConverter.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;
 5
 6namespace System.Text.Json.Serialization.Converters
 7{
 8    internal sealed class ByteArrayConverter : JsonConverter<byte[]?>
 9    {
 10        public override byte[]? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 63411        {
 63412            if (reader.TokenType == JsonTokenType.Null)
 013            {
 014                return null;
 15            }
 16
 63417            return reader.GetBytesFromBase64();
 12018        }
 19
 20        public override void Write(Utf8JsonWriter writer, byte[]? value, JsonSerializerOptions options)
 021        {
 022            if (value == null)
 023            {
 024                writer.WriteNullValue();
 025            }
 26            else
 027            {
 028                writer.WriteBase64StringValue(value);
 029            }
 030        }
 31
 032        internal override JsonSchema? GetSchema(JsonNumberHandling _) => new() { Type = JsonSchemaType.String };
 33    }
 34}