< Summary - Jellyfin

Information
Class: Jellyfin.Extensions.Json.Converters.JsonCommaDelimitedCollectionConverterFactory
Assembly: Jellyfin.Extensions
File(s): /srv/git/jellyfin/src/Jellyfin.Extensions/Json/Converters/JsonCommaDelimitedCollectionConverterFactory.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 31
Line coverage: 100%
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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CanConvert(...)83.33%66100%
CreateConverter(...)100%22100%

File(s)

/srv/git/jellyfin/src/Jellyfin.Extensions/Json/Converters/JsonCommaDelimitedCollectionConverterFactory.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 comma 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 JsonCommaDelimitedCollectionConverterFactory : JsonConverterFactory
 15    {
 16        /// <inheritdoc />
 17        public override bool CanConvert(Type typeToConvert)
 18        {
 2519            return typeToConvert.IsArray
 2520                || (typeToConvert.IsGenericType
 2521                    && (typeToConvert.GetGenericTypeDefinition().IsAssignableFrom(typeof(IReadOnlyCollection<>)) || type
 22        }
 23
 24        /// <inheritdoc />
 25        public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
 26        {
 2327            var structType = typeToConvert.GetElementType() ?? typeToConvert.GenericTypeArguments[0];
 2328            return (JsonConverter?)Activator.CreateInstance(typeof(JsonCommaDelimitedCollectionConverter<>).MakeGenericT
 29        }
 30    }
 31}