< Summary

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

File(s)

D:\runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Value\ReadOnlyMemoryByteConverter.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.Nodes;
 5using System.Text.Json.Schema;
 6
 7namespace System.Text.Json.Serialization.Converters
 8{
 9    internal sealed class ReadOnlyMemoryByteConverter : JsonConverter<ReadOnlyMemory<byte>>
 10    {
 111        public override bool HandleNull => true;
 12
 13        public override ReadOnlyMemory<byte> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions o
 014        {
 015            return reader.TokenType is JsonTokenType.Null ? default : reader.GetBytesFromBase64();
 016        }
 17
 18        public override void Write(Utf8JsonWriter writer, ReadOnlyMemory<byte> value, JsonSerializerOptions options)
 019        {
 020            writer.WriteBase64StringValue(value.Span);
 021        }
 22
 023        internal override JsonSchema? GetSchema(JsonNumberHandling _) => new() { Type = JsonSchemaType.String, ContentEn
 24
 025        internal override JsonValueType GetSupportedJsonValueTypes(JsonNumberHandling _) => JsonValueType.String;
 26    }
 27}