< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Dto.DtoOptions
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Dto/DtoOptions.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 121
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/16/2026 - 12:15:55 AM Line coverage: 95.4% (21/22) Branch coverage: 66.6% (4/6) Total lines: 686/2/2026 - 12:15:49 AM Line coverage: 95.4% (21/22) Branch coverage: 66.6% (4/6) Total lines: 1147/18/2026 - 12:15:19 AM Line coverage: 95.4% (21/22) Branch coverage: 66.6% (4/6) Total lines: 10710/29/2026 - 12:17:11 AM Line coverage: 100% (27/27) Branch coverage: 100% (6/6) Total lines: 121 5/16/2026 - 12:15:55 AM Line coverage: 95.4% (21/22) Branch coverage: 66.6% (4/6) Total lines: 686/2/2026 - 12:15:49 AM Line coverage: 95.4% (21/22) Branch coverage: 66.6% (4/6) Total lines: 1147/18/2026 - 12:15:19 AM Line coverage: 95.4% (21/22) Branch coverage: 66.6% (4/6) Total lines: 10710/29/2026 - 12:17:11 AM Line coverage: 100% (27/27) Branch coverage: 100% (6/6) Total lines: 121

Coverage delta

Coverage delta 34 -34

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
.ctor(...)100%22100%
get_StoredColumnsOnly()100%11100%
ContainsField(...)100%11100%
GetImageLimit(...)100%44100%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Dto/DtoOptions.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using MediaBrowser.Model.Entities;
 5using MediaBrowser.Model.Querying;
 6
 7namespace MediaBrowser.Controller.Dto
 8{
 9    /// <summary>
 10    /// Options that control which fields and images are populated when building a <see cref="MediaBrowser.Model.Dto.Bas
 11    /// </summary>
 12    public class DtoOptions
 13    {
 414        private static readonly ItemFields[] DefaultExcludedFields =
 415        [
 416            ItemFields.SeasonUserData,
 417            ItemFields.RefreshState
 418        ];
 19
 420        private static readonly ImageType[] AllImageTypes = Enum.GetValues<ImageType>();
 21
 422        private static readonly ItemFields[] AllItemFields = Enum.GetValues<ItemFields>()
 423            .Except(DefaultExcludedFields)
 424            .ToArray();
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="DtoOptions"/> class with all fields enabled.
 28        /// </summary>
 29        public DtoOptions()
 114430            : this(true)
 31        {
 114432        }
 33
 34        /// <summary>
 35        /// Initializes a new instance of the <see cref="DtoOptions"/> class.
 36        /// </summary>
 37        /// <param name="allFields">Whether to populate all available fields.</param>
 38        public DtoOptions(bool allFields)
 39        {
 160640            ImageTypeLimit = int.MaxValue;
 160641            EnableImages = true;
 160642            EnableUserData = true;
 160643            AddCurrentProgram = true;
 44
 160645            Fields = allFields ? AllItemFields : [];
 160646            ImageTypes = AllImageTypes;
 160647        }
 48
 49        /// <summary>
 50        /// Gets options that populate nothing beyond the item's own stored columns.
 51        /// </summary>
 52        /// <remarks>
 53        /// Each enabled field group is a collection the item query left-joins, so the rows returned are
 54        /// the product of the item's provider, image and user data counts. Never use this for items that
 55        /// get saved back: saving rewrites the owned rows from what the instance holds.
 56        /// </remarks>
 157        public static DtoOptions StoredColumnsOnly => new(false)
 158        {
 159            EnableImages = false,
 160            EnableUserData = false
 161        };
 62
 63        /// <summary>
 64        /// Gets or sets the fields to populate on the DTO.
 65        /// </summary>
 66        public IReadOnlyList<ItemFields> Fields { get; set; }
 67
 68        /// <summary>
 69        /// Gets or sets the image types to populate on the DTO.
 70        /// </summary>
 71        public IReadOnlyList<ImageType> ImageTypes { get; set; }
 72
 73        /// <summary>
 74        /// Gets or sets the maximum number of images to return per image type.
 75        /// </summary>
 76        public int ImageTypeLimit { get; set; }
 77
 78        /// <summary>
 79        /// Gets or sets a value indicating whether image information is populated.
 80        /// </summary>
 81        public bool EnableImages { get; set; }
 82
 83        /// <summary>
 84        /// Gets or sets a value indicating whether program recording information is populated.
 85        /// </summary>
 86        public bool AddProgramRecordingInfo { get; set; }
 87
 88        /// <summary>
 89        /// Gets or sets a value indicating whether user data is populated.
 90        /// </summary>
 91        public bool EnableUserData { get; set; }
 92
 93        /// <summary>
 94        /// Gets or sets a value indicating whether the currently airing program is populated.
 95        /// </summary>
 96        public bool AddCurrentProgram { get; set; }
 97
 98        /// <summary>
 99        /// Gets a value indicating whether the specified field is populated.
 100        /// </summary>
 101        /// <param name="field">The field to check.</param>
 102        /// <returns><c>true</c> if the field is populated; otherwise, <c>false</c>.</returns>
 103        public bool ContainsField(ItemFields field)
 2323104            => Fields.Contains(field);
 105
 106        /// <summary>
 107        /// Gets the number of images to return for the specified image type.
 108        /// </summary>
 109        /// <param name="type">The image type.</param>
 110        /// <returns>The image limit for the type, or 0 if the type is not enabled.</returns>
 111        public int GetImageLimit(ImageType type)
 112        {
 88113            if (EnableImages && ImageTypes.Contains(type))
 114            {
 71115                return ImageTypeLimit;
 116            }
 117
 17118            return 0;
 119        }
 120    }
 121}