diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 19902b26a0..0c0ba74533 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
@@ -83,12 +81,12 @@ namespace Emby.Server.Implementations.Dto
private ILiveTvManager LivetvManager => _livetvManagerFactory.Value;
///
- public IReadOnlyList GetBaseItemDtos(IReadOnlyList items, DtoOptions options, User user = null, BaseItem owner = null)
+ public IReadOnlyList GetBaseItemDtos(IReadOnlyList items, DtoOptions options, User? user = null, BaseItem? owner = null)
{
var accessibleItems = user is null ? items : items.Where(x => x.IsVisible(user)).ToList();
var returnItems = new BaseItemDto[accessibleItems.Count];
- List<(BaseItem, BaseItemDto)> programTuples = null;
- List<(BaseItemDto, LiveTvChannel)> channelTuples = null;
+ List<(BaseItem, BaseItemDto)>? programTuples = null;
+ List<(BaseItemDto, LiveTvChannel)>? channelTuples = null;
for (int index = 0; index < accessibleItems.Count; index++)
{
@@ -137,7 +135,7 @@ namespace Emby.Server.Implementations.Dto
return returnItems;
}
- public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
+ public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User? user = null, BaseItem? owner = null)
{
var dto = GetBaseItemDtoInternal(item, options, user, owner);
if (item is LiveTvChannel tvChannel)
@@ -167,7 +165,7 @@ namespace Emby.Server.Implementations.Dto
return dto;
}
- private static IList GetTaggedItems(IItemByName byName, User user, DtoOptions options)
+ private static IList GetTaggedItems(IItemByName byName, User? user, DtoOptions options)
{
return byName.GetTaggedItems(
new InternalItemsQuery(user)
@@ -177,7 +175,7 @@ namespace Emby.Server.Implementations.Dto
});
}
- private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
+ private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User? user = null, BaseItem? owner = null)
{
var dto = new BaseItemDto
{
@@ -292,7 +290,7 @@ namespace Emby.Server.Implementations.Dto
}
var path = mediaSource.Path;
- string fileExtensionContainer = null;
+ string? fileExtensionContainer = null;
if (!string.IsNullOrEmpty(path))
{
@@ -316,7 +314,8 @@ namespace Emby.Server.Implementations.Dto
}
}
- public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, User user = null)
+ ///
+ public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List? taggedItems, User? user = null)
{
var dto = GetBaseItemDtoInternal(item, options, user);
@@ -486,10 +485,10 @@ namespace Emby.Server.Implementations.Dto
return images
.Select(p => GetImageCacheTag(item, p))
.Where(i => i is not null)
- .ToArray();
+ .ToArray()!; // null values got filtered out
}
- private string GetImageCacheTag(BaseItem item, ItemImageInfo image)
+ private string? GetImageCacheTag(BaseItem item, ItemImageInfo image)
{
try
{
@@ -508,7 +507,7 @@ namespace Emby.Server.Implementations.Dto
/// The dto.
/// The item.
/// The requesting user.
- private void AttachPeople(BaseItemDto dto, BaseItem item, User user = null)
+ private void AttachPeople(BaseItemDto dto, BaseItem item, User? user = null)
{
// Ordering by person type to ensure actors and artists are at the front.
// This is taking advantage of the fact that they both begin with A
@@ -552,7 +551,7 @@ namespace Emby.Server.Implementations.Dto
var list = new List();
- var dictionary = people.Select(p => p.Name)
+ Dictionary dictionary = people.Select(p => p.Name)
.Distinct(StringComparer.OrdinalIgnoreCase).Select(c =>
{
try
@@ -565,9 +564,9 @@ namespace Emby.Server.Implementations.Dto
return null;
}
}).Where(i => i is not null)
- .Where(i => user is null || i.IsVisible(user))
- .DistinctBy(x => x.Name, StringComparer.OrdinalIgnoreCase)
- .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
+ .Where(i => user is null || i!.IsVisible(user))
+ .DistinctBy(x => x!.Name, StringComparer.OrdinalIgnoreCase)
+ .ToDictionary(i => i!.Name, StringComparer.OrdinalIgnoreCase)!; // null values got filtered out
for (var i = 0; i < people.Count; i++)
{
@@ -580,7 +579,7 @@ namespace Emby.Server.Implementations.Dto
Type = person.Type
};
- if (dictionary.TryGetValue(person.Name, out Person entity))
+ if (dictionary.TryGetValue(person.Name, out Person? entity))
{
baseItemPerson.PrimaryImageTag = GetTagAndFillBlurhash(dto, entity, ImageType.Primary);
baseItemPerson.Id = entity.Id;
@@ -650,7 +649,7 @@ namespace Emby.Server.Implementations.Dto
return _libraryManager.GetGenreId(name);
}
- private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ImageType imageType, int imageIndex = 0)
+ private string? GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ImageType imageType, int imageIndex = 0)
{
var image = item.GetImageInfo(imageType, imageIndex);
if (image is not null)
@@ -661,9 +660,14 @@ namespace Emby.Server.Implementations.Dto
return null;
}
- private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ItemImageInfo image)
+ private string? GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ItemImageInfo image)
{
var tag = GetImageCacheTag(item, image);
+ if (tag is null)
+ {
+ return null;
+ }
+
if (!string.IsNullOrEmpty(image.BlurHash))
{
dto.ImageBlurHashes ??= new Dictionary>();
@@ -716,7 +720,7 @@ namespace Emby.Server.Implementations.Dto
/// The item.
/// The owner.
/// The options.
- private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem owner, DtoOptions options)
+ private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem? owner, DtoOptions options)
{
if (options.ContainsField(ItemFields.DateCreated))
{
@@ -1097,7 +1101,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- BaseItem[] allExtras = null;
+ BaseItem[]? allExtras = null;
if (options.ContainsField(ItemFields.SpecialFeatureCount))
{
@@ -1134,7 +1138,7 @@ namespace Emby.Server.Implementations.Dto
dto.SeasonId = episode.SeasonId;
dto.SeriesId = episode.SeriesId;
- Series episodeSeries = null;
+ Series? episodeSeries = null;
// this block will add the series poster for episodes without a poster
// TODO maybe remove the if statement entirely
@@ -1162,8 +1166,10 @@ namespace Emby.Server.Implementations.Dto
}
// Add SeriesInfo
- if (item is Series series)
+ Series? series;
+ if (item is Series tmp)
{
+ series = tmp;
dto.AirDays = series.AirDays;
dto.AirTime = series.AirTime;
dto.Status = series.Status?.ToString();
@@ -1264,7 +1270,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- private BaseItem GetImageDisplayParent(BaseItem currentItem, BaseItem originalItem)
+ private BaseItem? GetImageDisplayParent(BaseItem currentItem, BaseItem originalItem)
{
if (currentItem is MusicAlbum musicAlbum)
{
@@ -1285,7 +1291,7 @@ namespace Emby.Server.Implementations.Dto
return parent;
}
- private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem owner)
+ private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem? owner)
{
if (!item.SupportsInheritedParentImages)
{
@@ -1305,7 +1311,7 @@ namespace Emby.Server.Implementations.Dto
return;
}
- BaseItem parent = null;
+ BaseItem? parent = null;
var isFirst = true;
var imageTags = dto.ImageTags;
@@ -1378,7 +1384,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- private string GetMappedPath(BaseItem item, BaseItem ownerItem)
+ private string GetMappedPath(BaseItem item, BaseItem? ownerItem)
{
var path = item.Path;
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs
index 0cf36f57ec..6c3d011036 100644
--- a/Jellyfin.Api/Controllers/LiveTvController.cs
+++ b/Jellyfin.Api/Controllers/LiveTvController.cs
@@ -688,7 +688,7 @@ public class LiveTvController : BaseJellyfinApiController
}
}
- var dtoOptions = new DtoOptions { Fields = body.Fields }
+ var dtoOptions = new DtoOptions { Fields = body.Fields ?? [] }
.AddClientFields(User)
.AddAdditionalDtoOptions(body.EnableImages, body.EnableUserData, body.ImageTypeLimit, body.EnableImageTypes ?? []);
return await _liveTvManager.GetPrograms(query, dtoOptions, CancellationToken.None).ConfigureAwait(false);
diff --git a/Jellyfin.Api/Extensions/DtoExtensions.cs b/Jellyfin.Api/Extensions/DtoExtensions.cs
index 3d17dbda18..f52b58babf 100644
--- a/Jellyfin.Api/Extensions/DtoExtensions.cs
+++ b/Jellyfin.Api/Extensions/DtoExtensions.cs
@@ -26,8 +26,6 @@ public static class DtoExtensions
internal static DtoOptions AddClientFields(
this DtoOptions dtoOptions, ClaimsPrincipal user)
{
- dtoOptions.Fields ??= Array.Empty();
-
string? client = user.GetClient();
// No client in claim
diff --git a/MediaBrowser.Controller/Dto/DtoOptions.cs b/MediaBrowser.Controller/Dto/DtoOptions.cs
index ecc833154d..cb638cf90b 100644
--- a/MediaBrowser.Controller/Dto/DtoOptions.cs
+++ b/MediaBrowser.Controller/Dto/DtoOptions.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;