< Summary - Jellyfin

Information
Class: Jellyfin.Extensions.Json.Converters.JsonPipeDelimitedCollectionConverterFactory
Assembly: Jellyfin.Extensions
File(s): /srv/git/jellyfin/src/Jellyfin.Extensions/Json/Converters/JsonPipeDelimitedCollectionConverterFactory.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 31
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CanConvert(...)0%4260%
CreateConverter(...)0%620%

File(s)

/srv/git/jellyfin/src/Jellyfin.Extensions/Json/Converters/JsonPipeDelimitedCollectionConverterFactory.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Text.Json;
 4using System.Text.Json.Serialization;
 5
 6namespace Jellyfin.Extensions.Json.Converters
 7{
 8    /// <summary>
 9    /// Json Pipe delimited collection converter factory.
 10    /// </summary>
 11    /// <remarks>
 12    /// This must be applied as an attribute, adding to the JsonConverter list causes stack overflow.
 13    /// </remarks>
 14    public class JsonPipeDelimitedCollectionConverterFactory : JsonConverterFactory
 15    {
 16        /// <inheritdoc />
 17        public override bool CanConvert(Type typeToConvert)
 18        {
 019            return typeToConvert.IsArray
 020                || (typeToConvert.IsGenericType
 021                    && (typeToConvert.GetGenericTypeDefinition().IsAssignableFrom(typeof(IReadOnlyCollection<>)) || type
 22        }
 23
 24        /// <inheritdoc />
 25        public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
 26        {
 027            var structType = typeToConvert.GetElementType() ?? typeToConvert.GenericTypeArguments[0];
 028            return (JsonConverter?)Activator.CreateInstance(typeof(JsonPipeDelimitedCollectionConverter<>).MakeGenericTy
 29        }
 30    }
 31}