< Summary

Line coverage
17%
Covered lines: 3
Uncovered lines: 14
Coverable lines: 17
Total lines: 37
Line coverage: 17.6%
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%2250%
Write(...)0%220%
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/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)
 1211        {
 1212            if (reader.TokenType == JsonTokenType.Null)
 013            {
 014                return null;
 15            }
 16
 1217            return reader.GetBytesFromBase64();
 018        }
 19
 20        public override void Write(Utf8JsonWriter writer, byte[]? value, JsonSerializerOptions options)
 021        {
 022            if (value is 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, ContentEn
 33
 034        internal override JsonValueType GetSupportedJsonValueTypes(JsonNumberHandling _) => JsonValueType.String;
 35    }
 36}
 37