< 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: 114
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 3/3/2026 - 12:13:24 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: 114 3/3/2026 - 12:13:24 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: 114

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()
 69230            : this(true)
 31        {
 69232        }
 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        {
 95940            ImageTypeLimit = int.MaxValue;
 95941            EnableImages = true;
 95942            EnableUserData = true;
 95943            AddCurrentProgram = true;
 44
 95945            Fields = allFields ? AllItemFields : [];
 95946            ImageTypes = AllImageTypes;
 95947        }
 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 or sets a value indicating whether an episode's portrait poster (its season's primary
 86        /// image, falling back to the series') should replace the episode's own (16:9) primary image.
 87        /// Used by views that render episodes as poster cards, e.g. "Latest".
 88        /// </summary>
 89        public bool PreferEpisodeParentPoster { get; set; }
 90
 91        /// <summary>
 92        /// Gets a value indicating whether the specified field is populated.
 93        /// </summary>
 94        /// <param name="field">The field to check.</param>
 95        /// <returns><c>true</c> if the field is populated; otherwise, <c>false</c>.</returns>
 96        public bool ContainsField(ItemFields field)
 135197            => Fields.Contains(field);
 98
 99        /// <summary>
 100        /// Gets the number of images to return for the specified image type.
 101        /// </summary>
 102        /// <param name="type">The image type.</param>
 103        /// <returns>The image limit for the type, or 0 if the type is not enabled.</returns>
 104        public int GetImageLimit(ImageType type)
 105        {
 33106            if (EnableImages && ImageTypes.Contains(type))
 107            {
 33108                return ImageTypeLimit;
 109            }
 110
 0111            return 0;
 112        }
 113    }
 114}