< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Dto.DtoOptions
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Dto/DtoOptions.cs
Line coverage
95%
Covered lines: 21
Uncovered lines: 1
Coverable lines: 22
Total lines: 107
Line coverage: 95.4%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 4/15/2026 - 12:14:34 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: 107 4/15/2026 - 12:14:34 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: 107

Coverage delta

Coverage delta 1 -1

Metrics

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

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    {
 314        private static readonly ItemFields[] DefaultExcludedFields =
 315        [
 316            ItemFields.SeasonUserData,
 317            ItemFields.RefreshState
 318        ];
 19
 320        private static readonly ImageType[] AllImageTypes = Enum.GetValues<ImageType>();
 21
 322        private static readonly ItemFields[] AllItemFields = Enum.GetValues<ItemFields>()
 323            .Except(DefaultExcludedFields)
 324            .ToArray();
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="DtoOptions"/> class with all fields enabled.
 28        /// </summary>
 29        public DtoOptions()
 70230            : this(true)
 31        {
 70232        }
 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        {
 96840            ImageTypeLimit = int.MaxValue;
 96841            EnableImages = true;
 96842            EnableUserData = true;
 96843            AddCurrentProgram = true;
 44
 96845            Fields = allFields ? AllItemFields : [];
 96846            ImageTypes = AllImageTypes;
 96847        }
 48
 49        /// <summary>
 50        /// Gets or sets the fields to populate on the DTO.
 51        /// </summary>
 52        public IReadOnlyList<ItemFields> Fields { get; set; }
 53
 54        /// <summary>
 55        /// Gets or sets the image types to populate on the DTO.
 56        /// </summary>
 57        public IReadOnlyList<ImageType> ImageTypes { get; set; }
 58
 59        /// <summary>
 60        /// Gets or sets the maximum number of images to return per image type.
 61        /// </summary>
 62        public int ImageTypeLimit { get; set; }
 63
 64        /// <summary>
 65        /// Gets or sets a value indicating whether image information is populated.
 66        /// </summary>
 67        public bool EnableImages { get; set; }
 68
 69        /// <summary>
 70        /// Gets or sets a value indicating whether program recording information is populated.
 71        /// </summary>
 72        public bool AddProgramRecordingInfo { get; set; }
 73
 74        /// <summary>
 75        /// Gets or sets a value indicating whether user data is populated.
 76        /// </summary>
 77        public bool EnableUserData { get; set; }
 78
 79        /// <summary>
 80        /// Gets or sets a value indicating whether the currently airing program is populated.
 81        /// </summary>
 82        public bool AddCurrentProgram { get; set; }
 83
 84        /// <summary>
 85        /// Gets a value indicating whether the specified field is populated.
 86        /// </summary>
 87        /// <param name="field">The field to check.</param>
 88        /// <returns><c>true</c> if the field is populated; otherwise, <c>false</c>.</returns>
 89        public bool ContainsField(ItemFields field)
 135790            => Fields.Contains(field);
 91
 92        /// <summary>
 93        /// Gets the number of images to return for the specified image type.
 94        /// </summary>
 95        /// <param name="type">The image type.</param>
 96        /// <returns>The image limit for the type, or 0 if the type is not enabled.</returns>
 97        public int GetImageLimit(ImageType type)
 98        {
 3699            if (EnableImages && ImageTypes.Contains(type))
 100            {
 36101                return ImageTypeLimit;
 102            }
 103
 0104            return 0;
 105        }
 106    }
 107}