< Summary - Jellyfin

Information
Class: Jellyfin.LiveTv.Listings.SchedulesDirectDtos.ImageDataArrayConverter
Assembly: Jellyfin.LiveTv
File(s): /srv/git/jellyfin/src/Jellyfin.LiveTv/Listings/SchedulesDirectDtos/ImageDataArrayConverter.cs
Line coverage
70%
Covered lines: 7
Uncovered lines: 3
Coverable lines: 10
Total lines: 42
Line coverage: 70%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/6/2026 - 12:15:23 AM Line coverage: 70% (7/10) Branch coverage: 87.5% (7/8) Total lines: 42 5/6/2026 - 12:15:23 AM Line coverage: 70% (7/10) Branch coverage: 87.5% (7/8) Total lines: 42

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Read(...)87.5%9877.77%
Write(...)100%210%

File(s)

/srv/git/jellyfin/src/Jellyfin.LiveTv/Listings/SchedulesDirectDtos/ImageDataArrayConverter.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Text.Json;
 4using System.Text.Json.Serialization;
 5
 6namespace Jellyfin.LiveTv.Listings.SchedulesDirectDtos;
 7
 8/// <summary>
 9/// Converter for the <c>data</c> field in SD image responses.
 10/// The Schedules Direct API may return a non-array value (e.g. a string error message)
 11/// instead of the expected image data array for programs with errors.
 12/// This converter returns an empty list for any non-array value.
 13/// </summary>
 14public sealed class ImageDataArrayConverter : JsonConverter<IReadOnlyList<ImageDataDto>>
 15{
 16    /// <inheritdoc />
 17    public override IReadOnlyList<ImageDataDto> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOption
 18    {
 119        if (reader.TokenType == JsonTokenType.StartArray)
 20        {
 121            var result = new List<ImageDataDto>();
 522            while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
 23            {
 424                var item = JsonSerializer.Deserialize<ImageDataDto>(ref reader, options);
 425                if (item is not null)
 26                {
 427                    result.Add(item);
 28                }
 29            }
 30
 131            return result;
 32        }
 33
 34        // Not an array (string error, null, object, etc.) — skip and return empty.
 035        reader.TrySkip();
 036        return [];
 37    }
 38
 39    /// <inheritdoc />
 40    public override void Write(Utf8JsonWriter writer, IReadOnlyList<ImageDataDto> value, JsonSerializerOptions options)
 041        => JsonSerializer.Serialize(writer, value, options);
 42}