diff options
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/Cryptography/PasswordHash.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/AudioOptions.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ContainerProfile.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ResolutionNormalizer.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/SearchCriteria.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 87 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamInfo.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Model/Drawing/DrawingUtils.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/BaseItemPerson.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/MediaSourceInfo.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/ProviderIdsExtensions.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/MediaBrowser.Model.csproj | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/MimeTypes.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Model/Notifications/NotificationOptions.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model/Updates/VersionInfo.cs | 2 |
16 files changed, 73 insertions, 96 deletions
diff --git a/MediaBrowser.Model/Cryptography/PasswordHash.cs b/MediaBrowser.Model/Cryptography/PasswordHash.cs index 32a34d23c..80a30684a 100644 --- a/MediaBrowser.Model/Cryptography/PasswordHash.cs +++ b/MediaBrowser.Model/Cryptography/PasswordHash.cs @@ -29,12 +29,7 @@ namespace MediaBrowser.Model.Cryptography public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters) { - ArgumentNullException.ThrowIfNull(id); - - if (id.Length == 0) - { - throw new ArgumentException("String can't be empty", nameof(id)); - } + ArgumentException.ThrowIfNullOrEmpty(id); Id = id; _hash = hash; diff --git a/MediaBrowser.Model/Dlna/AudioOptions.cs b/MediaBrowser.Model/Dlna/AudioOptions.cs index 33755e746..df4018fdd 100644 --- a/MediaBrowser.Model/Dlna/AudioOptions.cs +++ b/MediaBrowser.Model/Dlna/AudioOptions.cs @@ -77,7 +77,7 @@ namespace MediaBrowser.Model.Dlna return MaxBitrate; } - if (Profile == null) + if (Profile is null) { return null; } diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs index c6befdd85..927df8e4e 100644 --- a/MediaBrowser.Model/Dlna/ContainerProfile.cs +++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Model.Dlna public static bool ContainsContainer(string? profileContainers, string? inputContainer) { var isNegativeList = false; - if (profileContainers != null && profileContainers.StartsWith('-')) + if (profileContainers is not null && profileContainers.StartsWith('-')) { isNegativeList = true; profileContainers = profileContainers.Substring(1); @@ -52,7 +52,7 @@ namespace MediaBrowser.Model.Dlna public static bool ContainsContainer(string[]? profileContainers, bool isNegativeList, string? inputContainer) { - if (profileContainers == null || profileContainers.Length == 0) + if (profileContainers is null || profileContainers.Length == 0) { // Empty profiles always support all containers/codecs return true; diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs index 1a9576361..1d5d0b1de 100644 --- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs +++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs @@ -192,7 +192,7 @@ namespace MediaBrowser.Model.Dlna var orgPnValues = new List<string>(); - if (mediaProfile != null && !string.IsNullOrEmpty(mediaProfile.OrgPn)) + if (mediaProfile is not null && !string.IsNullOrEmpty(mediaProfile.OrgPn)) { orgPnValues.AddRange(mediaProfile.OrgPn.Split(',', StringSplitOptions.RemoveEmptyEntries)); } diff --git a/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs b/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs index 94071b419..ce422a228 100644 --- a/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs +++ b/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs @@ -39,7 +39,7 @@ namespace MediaBrowser.Model.Dlna } var resolutionConfig = GetResolutionConfiguration(outputBitrate); - if (resolutionConfig != null) + if (resolutionConfig is not null) { var originvalValue = maxWidth; diff --git a/MediaBrowser.Model/Dlna/SearchCriteria.cs b/MediaBrowser.Model/Dlna/SearchCriteria.cs index b1fc48c08..77d6a55ea 100644 --- a/MediaBrowser.Model/Dlna/SearchCriteria.cs +++ b/MediaBrowser.Model/Dlna/SearchCriteria.cs @@ -9,10 +9,7 @@ namespace MediaBrowser.Model.Dlna { public SearchCriteria(string search) { - if (search.Length == 0) - { - throw new ArgumentException("String can't be empty.", nameof(search)); - } + ArgumentException.ThrowIfNullOrEmpty(search); SearchType = SearchType.Unknown; diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 6e9b943f7..af35e98ee 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -53,7 +53,7 @@ namespace MediaBrowser.Model.Dlna foreach (MediaSourceInfo i in mediaSources) { StreamInfo streamInfo = BuildAudioItem(i, options); - if (streamInfo != null) + if (streamInfo is not null) { streams.Add(streamInfo); } @@ -86,7 +86,7 @@ namespace MediaBrowser.Model.Dlna foreach (MediaSourceInfo i in mediaSources) { var streamInfo = BuildVideoItem(i, options); - if (streamInfo != null) + if (streamInfo is not null) { streams.Add(streamInfo); } @@ -245,9 +245,9 @@ namespace MediaBrowser.Model.Dlna var formats = ContainerProfile.SplitValue(inputContainer); - if (profile != null) + if (profile is not null) { - var playProfiles = playProfile == null ? profile.DirectPlayProfiles : new[] { playProfile }; + var playProfiles = playProfile is null ? profile.DirectPlayProfiles : new[] { playProfile }; foreach (var format in formats) { foreach (var directPlayProfile in playProfiles) @@ -330,7 +330,7 @@ namespace MediaBrowser.Model.Dlna } } - if (transcodingProfile != null) + if (transcodingProfile is not null) { if (!item.SupportsTranscoding) { @@ -370,7 +370,7 @@ namespace MediaBrowser.Model.Dlna var directPlayProfile = options.Profile.DirectPlayProfiles .FirstOrDefault(x => x.Type == DlnaProfileType.Audio && IsAudioDirectPlaySupported(x, item, audioStream)); - if (directPlayProfile == null) + if (directPlayProfile is null) { _logger.LogDebug( "Profile: {0}, No audio direct play profiles found for {1} with codec {2}", @@ -422,7 +422,7 @@ namespace MediaBrowser.Model.Dlna private static TranscodeReason GetTranscodeReasonsFromDirectPlayProfile(MediaSourceInfo item, MediaStream videoStream, MediaStream audioStream, IEnumerable<DirectPlayProfile> directPlayProfiles) { - var mediaType = videoStream == null ? DlnaProfileType.Audio : DlnaProfileType.Video; + var mediaType = videoStream is null ? DlnaProfileType.Audio : DlnaProfileType.Video; var containerSupported = false; var audioSupported = false; @@ -436,9 +436,9 @@ namespace MediaBrowser.Model.Dlna { containerSupported = true; - videoSupported = videoStream == null || profile.SupportsVideoCodec(videoStream.Codec); + videoSupported = videoStream is null || profile.SupportsVideoCodec(videoStream.Codec); - audioSupported = audioStream == null || profile.SupportsAudioCodec(audioStream.Codec); + audioSupported = audioStream is null || profile.SupportsAudioCodec(audioStream.Codec); if (videoSupported && audioSupported) { @@ -580,13 +580,13 @@ namespace MediaBrowser.Model.Dlna var subtitleStream = playlistItem.SubtitleStreamIndex.HasValue ? item.GetMediaStream(MediaStreamType.Subtitle, playlistItem.SubtitleStreamIndex.Value) : null; var audioStream = item.GetDefaultAudioStream(options.AudioStreamIndex ?? item.DefaultAudioStreamIndex); - if (audioStream != null) + if (audioStream is not null) { playlistItem.AudioStreamIndex = audioStream.Index; } // Collect candidate audio streams - ICollection<MediaStream> candidateAudioStreams = audioStream == null ? Array.Empty<MediaStream>() : new[] { audioStream }; + ICollection<MediaStream> candidateAudioStreams = audioStream is null ? Array.Empty<MediaStream>() : new[] { audioStream }; if (!options.AudioStreamIndex.HasValue || options.AudioStreamIndex < 0) { if (audioStream?.IsDefault == true) @@ -643,7 +643,7 @@ namespace MediaBrowser.Model.Dlna else if (directPlay == PlayMethod.DirectStream) { playlistItem.AudioStreamIndex = audioStream?.Index; - if (audioStream != null) + if (audioStream is not null) { playlistItem.AudioCodecs = ContainerProfile.SplitValue(directPlayProfile.AudioCodec); } @@ -652,7 +652,7 @@ namespace MediaBrowser.Model.Dlna BuildStreamVideoItem(playlistItem, options, item, videoStream, audioStream, candidateAudioStreams, directPlayProfile.Container, directPlayProfile.VideoCodec, directPlayProfile.AudioCodec); } - if (subtitleStream != null) + if (subtitleStream is not null) { var subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, directPlay.Value, _transcoderSupport, directPlayProfile.Container, null); @@ -678,7 +678,7 @@ namespace MediaBrowser.Model.Dlna // Can't direct play, find the transcoding profile // If we do this for direct-stream we will overwrite the info var transcodingProfile = GetVideoTranscodeProfile(item, options, videoStream, audioStream, candidateAudioStreams, subtitleStream, playlistItem); - if (transcodingProfile != null) + if (transcodingProfile is not null) { SetStreamInfoOptionsFromTranscodingProfile(item, playlistItem, transcodingProfile); @@ -686,7 +686,7 @@ namespace MediaBrowser.Model.Dlna playlistItem.PlayMethod = PlayMethod.Transcode; - if (subtitleStream != null) + if (subtitleStream is not null) { var subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.Transcode, _transcoderSupport, transcodingProfile.Container, transcodingProfile.Protocol); @@ -729,8 +729,8 @@ namespace MediaBrowser.Model.Dlna if (options.AllowVideoStreamCopy) { // prefer direct copy profile - float videoFramerate = videoStream == null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; - TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : item.Timestamp; + float videoFramerate = videoStream is null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; + TransportStreamTimestamp? timestamp = videoStream is null ? TransportStreamTimestamp.None : item.Timestamp; int? numAudioStreams = item.GetStreamCount(MediaStreamType.Audio); int? numVideoStreams = item.GetStreamCount(MediaStreamType.Video); @@ -768,7 +768,7 @@ namespace MediaBrowser.Model.Dlna // Prefer matching video codecs var videoCodecs = ContainerProfile.SplitValue(videoCodec); var directVideoCodec = ContainerProfile.ContainsContainer(videoCodecs, videoStream?.Codec) ? videoStream?.Codec : null; - if (directVideoCodec != null) + if (directVideoCodec is not null) { // merge directVideoCodec to videoCodecs Array.Resize(ref videoCodecs, videoCodecs.Length + 1); @@ -780,12 +780,12 @@ namespace MediaBrowser.Model.Dlna // Copy video codec options as a starting point, this applies to transcode and direct-stream playlistItem.MaxFramerate = videoStream?.AverageFrameRate; var qualifier = videoStream?.Codec; - if (videoStream?.Level != null) + if (videoStream?.Level is not null) { playlistItem.SetOption(qualifier, "level", videoStream.Level.Value.ToString(CultureInfo.InvariantCulture)); } - if (videoStream?.BitDepth != null) + if (videoStream?.BitDepth is not null) { playlistItem.SetOption(qualifier, "videobitdepth", videoStream.BitDepth.Value.ToString(CultureInfo.InvariantCulture)); } @@ -795,7 +795,7 @@ namespace MediaBrowser.Model.Dlna playlistItem.SetOption(qualifier, "profile", videoStream.Profile.ToLowerInvariant()); } - if (videoStream != null && videoStream.Level != 0) + if (videoStream is not null && videoStream.Level != 0) { playlistItem.SetOption(qualifier, "level", videoStream.Level.ToString()); } @@ -804,7 +804,7 @@ namespace MediaBrowser.Model.Dlna var audioCodecs = ContainerProfile.SplitValue(audioCodec); var directAudioStream = candidateAudioStreams.FirstOrDefault(stream => ContainerProfile.ContainsContainer(audioCodecs, stream.Codec)); playlistItem.AudioCodecs = audioCodecs; - if (directAudioStream != null) + if (directAudioStream is not null) { audioStream = directAudioStream; playlistItem.AudioStreamIndex = audioStream.Index; @@ -832,13 +832,13 @@ namespace MediaBrowser.Model.Dlna double? videoLevel = videoStream?.Level; string videoProfile = videoStream?.Profile; string videoRangeType = videoStream?.VideoRangeType; - float videoFramerate = videoStream == null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; + float videoFramerate = videoStream is null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; bool? isAnamorphic = videoStream?.IsAnamorphic; bool? isInterlaced = videoStream?.IsInterlaced; string videoCodecTag = videoStream?.CodecTag; bool? isAvc = videoStream?.IsAVC; - TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : item.Timestamp; + TransportStreamTimestamp? timestamp = videoStream is null ? TransportStreamTimestamp.None : item.Timestamp; int? packetLength = videoStream?.PacketLength; int? refFrames = videoStream?.RefFrames; @@ -870,12 +870,12 @@ namespace MediaBrowser.Model.Dlna int audioBitrate = GetAudioBitrate(options.GetMaxBitrate(false) ?? 0, playlistItem.TargetAudioCodec, audioStream, playlistItem); playlistItem.AudioBitrate = Math.Min(playlistItem.AudioBitrate ?? audioBitrate, audioBitrate); - bool? isSecondaryAudio = audioStream == null ? null : item.IsSecondaryAudio(audioStream); - int? inputAudioBitrate = audioStream == null ? null : audioStream.BitRate; - int? audioChannels = audioStream == null ? null : audioStream.Channels; - string audioProfile = audioStream == null ? null : audioStream.Profile; - int? inputAudioSampleRate = audioStream == null ? null : audioStream.SampleRate; - int? inputAudioBitDepth = audioStream == null ? null : audioStream.BitDepth; + bool? isSecondaryAudio = audioStream is null ? null : item.IsSecondaryAudio(audioStream); + int? inputAudioBitrate = audioStream is null ? null : audioStream.BitRate; + int? audioChannels = audioStream is null ? null : audioStream.Channels; + string audioProfile = audioStream is null ? null : audioStream.Profile; + int? inputAudioSampleRate = audioStream is null ? null : audioStream.SampleRate; + int? inputAudioBitDepth = audioStream is null ? null : audioStream.BitDepth; var appliedAudioConditions = options.Profile.CodecProfiles .Where(i => i.Type == CodecType.VideoAudio && @@ -965,7 +965,7 @@ namespace MediaBrowser.Model.Dlna int defaultBitrate; int encoderAudioBitrateLimit = int.MaxValue; - if (audioStream == null) + if (audioStream is null) { defaultBitrate = 192000; } @@ -982,7 +982,7 @@ namespace MediaBrowser.Model.Dlna && audioStream.Channels.HasValue && audioStream.Channels.Value <= targetAudioChannels.Value && !string.IsNullOrEmpty(audioStream.Codec) - && targetAudioCodecs != null + && targetAudioCodecs is not null && targetAudioCodecs.Length > 0 && !Array.Exists(targetAudioCodecs, elem => string.Equals(audioStream.Codec, elem, StringComparison.OrdinalIgnoreCase))) { @@ -1080,13 +1080,13 @@ namespace MediaBrowser.Model.Dlna double? videoLevel = videoStream?.Level; string videoProfile = videoStream?.Profile; string videoRangeType = videoStream?.VideoRangeType; - float videoFramerate = videoStream == null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; + float videoFramerate = videoStream is null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; bool? isAnamorphic = videoStream?.IsAnamorphic; bool? isInterlaced = videoStream?.IsInterlaced; string videoCodecTag = videoStream?.CodecTag; bool? isAvc = videoStream?.IsAVC; - TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : mediaSource.Timestamp; + TransportStreamTimestamp? timestamp = videoStream is null ? TransportStreamTimestamp.None : mediaSource.Timestamp; int? packetLength = videoStream?.PacketLength; int? refFrames = videoStream?.RefFrames; @@ -1119,7 +1119,7 @@ namespace MediaBrowser.Model.Dlna var audioStreamMatches = candidateAudioStreams.ToDictionary(s => s, audioStream => CheckVideoAudioStreamDirectPlay(options, mediaSource, container, audioStream)); TranscodeReason subtitleProfileReasons = 0; - if (subtitleStream != null) + if (subtitleStream is not null) { var subtitleProfile = GetSubtitleProfile(mediaSource, subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.DirectPlay, _transcoderSupport, container, null); @@ -1177,7 +1177,7 @@ namespace MediaBrowser.Model.Dlna if (candidateAudioStreams.Any()) { selectedAudioStream = candidateAudioStreams.FirstOrDefault(audioStream => directPlayProfile.SupportsAudioCodec(audioStream.Codec)); - if (selectedAudioStream == null) + if (selectedAudioStream is null) { directPlayProfileReasons |= TranscodeReason.AudioCodecNotSupported; } @@ -1206,7 +1206,7 @@ namespace MediaBrowser.Model.Dlna { playMethod = PlayMethod.DirectPlay; } - else if (directStreamFailureReasons == 0 && isEligibleForDirectStream && mediaSource.SupportsDirectStream && directPlayProfile != null) + else if (directStreamFailureReasons == 0 && isEligibleForDirectStream && mediaSource.SupportsDirectStream && directPlayProfile is not null) { playMethod = PlayMethod.DirectStream; } @@ -1218,12 +1218,12 @@ namespace MediaBrowser.Model.Dlna .ThenByDescending(analysis => analysis.Rank) .ThenBy(analysis => analysis.Order) .ToArray() - .ToLookup(analysis => analysis.Result.PlayMethod != null); + .ToLookup(analysis => analysis.Result.PlayMethod is not null); var profileMatch = analyzedProfiles[true] .Select(analysis => analysis.Result) .FirstOrDefault(); - if (profileMatch.Profile != null) + if (profileMatch.Profile is not null) { return profileMatch; } @@ -1496,17 +1496,14 @@ namespace MediaBrowser.Model.Dlna throw new ArgumentException("ItemId is required"); } - if (string.IsNullOrEmpty(options.DeviceId)) - { - throw new ArgumentException("DeviceId is required"); - } + ArgumentException.ThrowIfNullOrEmpty(options.DeviceId); - if (options.Profile == null) + if (options.Profile is null) { throw new ArgumentException("Profile is required"); } - if (options.MediaSources == null) + if (options.MediaSources is null) { throw new ArgumentException("MediaSources is required"); } diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 5cfa2e7e3..3b5509907 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -215,7 +215,7 @@ namespace MediaBrowser.Model.Dlna var stream = TargetVideoStream; return MaxFramerate.HasValue && !IsDirectStream ? MaxFramerate - : stream == null ? null : stream.AverageFrameRate ?? stream.RealFrameRate; + : stream is null ? null : stream.AverageFrameRate ?? stream.RealFrameRate; } } @@ -460,7 +460,7 @@ namespace MediaBrowser.Model.Dlna return !IsDirectStream ? defaultValue - : MediaSource == null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None; + : MediaSource is null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None; } } @@ -521,7 +521,7 @@ namespace MediaBrowser.Model.Dlna { var videoStream = TargetVideoStream; - if (videoStream != null && videoStream.Width.HasValue && videoStream.Height.HasValue) + if (videoStream is not null && videoStream.Width.HasValue && videoStream.Height.HasValue) { ImageDimensions size = new ImageDimensions(videoStream.Width.Value, videoStream.Height.Value); @@ -540,7 +540,7 @@ namespace MediaBrowser.Model.Dlna { var videoStream = TargetVideoStream; - if (videoStream != null && videoStream.Width.HasValue && videoStream.Height.HasValue) + if (videoStream is not null && videoStream.Width.HasValue && videoStream.Height.HasValue) { ImageDimensions size = new ImageDimensions(videoStream.Width.Value, videoStream.Height.Value); @@ -620,10 +620,7 @@ namespace MediaBrowser.Model.Dlna public string ToUrl(string baseUrl, string accessToken) { - if (string.IsNullOrEmpty(baseUrl)) - { - throw new ArgumentNullException(nameof(baseUrl)); - } + ArgumentException.ThrowIfNullOrEmpty(baseUrl); var list = new List<string>(); foreach (NameValuePair pair in BuildParams(this, accessToken)) @@ -664,10 +661,7 @@ namespace MediaBrowser.Model.Dlna private string GetUrl(string baseUrl, string queryString) { - if (string.IsNullOrEmpty(baseUrl)) - { - throw new ArgumentNullException(nameof(baseUrl)); - } + ArgumentException.ThrowIfNullOrEmpty(baseUrl); string extension = string.IsNullOrEmpty(Container) ? string.Empty : "." + Container; diff --git a/MediaBrowser.Model/Drawing/DrawingUtils.cs b/MediaBrowser.Model/Drawing/DrawingUtils.cs index 556792768..2040d26bb 100644 --- a/MediaBrowser.Model/Drawing/DrawingUtils.cs +++ b/MediaBrowser.Model/Drawing/DrawingUtils.cs @@ -71,18 +71,18 @@ namespace MediaBrowser.Model.Drawing int? fillHeight) { // Return original size if input is invalid. - if ((fillWidth == null || fillWidth == 0) - && (fillHeight == null || fillHeight == 0)) + if ((fillWidth is null || fillWidth == 0) + && (fillHeight is null || fillHeight == 0)) { return size; } - if (fillWidth == null || fillWidth == 0) + if (fillWidth is null || fillWidth == 0) { fillWidth = 1; } - if (fillHeight == null || fillHeight == 0) + if (fillHeight is null || fillHeight == 0) { fillHeight = 1; } diff --git a/MediaBrowser.Model/Dto/BaseItemPerson.cs b/MediaBrowser.Model/Dto/BaseItemPerson.cs index 6b920b0ef..9c65a2308 100644 --- a/MediaBrowser.Model/Dto/BaseItemPerson.cs +++ b/MediaBrowser.Model/Dto/BaseItemPerson.cs @@ -52,6 +52,6 @@ namespace MediaBrowser.Model.Dto /// </summary> /// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value> [JsonIgnore] - public bool HasPrimaryImage => PrimaryImageTag != null; + public bool HasPrimaryImage => PrimaryImageTag is not null; } } diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index c348e83ae..520832aee 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -134,7 +134,7 @@ namespace MediaBrowser.Model.Dto public void InferTotalBitrate(bool force = false) { - if (MediaStreams == null) + if (MediaStreams is null) { return; } diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index d3b8400f3..cf453d62c 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Model.Entities { ArgumentNullException.ThrowIfNull(instance); - if (instance.ProviderIds == null) + if (instance.ProviderIds is null) { id = null; return false; diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 4172e9825..98179e486 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -14,7 +14,7 @@ </PropertyGroup> <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> + <TargetFramework>net7.0</TargetFramework> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateDocumentationFile>true</GenerateDocumentationFile> <PublishRepositoryUrl>true</PublishRepositoryUrl> @@ -24,7 +24,7 @@ </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> - <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors> </PropertyGroup> <PropertyGroup Condition=" '$(Stability)'=='Unstable'"> @@ -34,13 +34,13 @@ <ItemGroup> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> - <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" /> + <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> <PackageReference Include="MimeTypes" Version="2.4.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="System.Globalization" Version="4.3.0" /> - <PackageReference Include="System.Text.Json" Version="6.0.7" /> + <PackageReference Include="System.Text.Json" Version="7.0.0" /> </ItemGroup> <ItemGroup> diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs index 3b03466e9..8157dc0c2 100644 --- a/MediaBrowser.Model/Net/MimeTypes.cs +++ b/MediaBrowser.Model/Net/MimeTypes.cs @@ -140,10 +140,7 @@ namespace MediaBrowser.Model.Net [return: NotNullIfNotNull("defaultValue")] public static string? GetMimeType(string filename, string? defaultValue = null) { - if (filename.Length == 0) - { - throw new ArgumentException("String can't be empty.", nameof(filename)); - } + ArgumentException.ThrowIfNullOrEmpty(filename); var ext = Path.GetExtension(filename); @@ -168,10 +165,7 @@ namespace MediaBrowser.Model.Net public static string? ToExtension(string mimeType) { - if (mimeType.Length == 0) - { - throw new ArgumentException("String can't be empty.", nameof(mimeType)); - } + ArgumentException.ThrowIfNullOrEmpty(mimeType); // handle text/html; charset=UTF-8 mimeType = mimeType.AsSpan().LeftPart(';').ToString(); diff --git a/MediaBrowser.Model/Notifications/NotificationOptions.cs b/MediaBrowser.Model/Notifications/NotificationOptions.cs index d1b5491bd..804f51e16 100644 --- a/MediaBrowser.Model/Notifications/NotificationOptions.cs +++ b/MediaBrowser.Model/Notifications/NotificationOptions.cs @@ -86,14 +86,14 @@ namespace MediaBrowser.Model.Notifications { NotificationOption opt = GetOptions(type); - return opt != null && opt.Enabled; + return opt is not null && opt.Enabled; } public bool IsServiceEnabled(string service, string notificationType) { NotificationOption opt = GetOptions(notificationType); - return opt == null + return opt is null || !opt.DisabledServices.Contains(service, StringComparison.OrdinalIgnoreCase); } @@ -101,7 +101,7 @@ namespace MediaBrowser.Model.Notifications { NotificationOption opt = GetOptions(type); - return opt != null + return opt is not null && opt.Enabled && !opt.DisabledMonitorUsers.Contains(userId.ToString("N"), StringComparison.OrdinalIgnoreCase); } @@ -110,7 +110,7 @@ namespace MediaBrowser.Model.Notifications { NotificationOption opt = GetOptions(type); - if (opt != null && opt.Enabled) + if (opt is not null && opt.Enabled) { if (opt.SendToUserMode == SendToUserType.All) { diff --git a/MediaBrowser.Model/Updates/VersionInfo.cs b/MediaBrowser.Model/Updates/VersionInfo.cs index 03a540dde..320199f98 100644 --- a/MediaBrowser.Model/Updates/VersionInfo.cs +++ b/MediaBrowser.Model/Updates/VersionInfo.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Model.Updates [JsonPropertyName("version")] public string Version { - get => _version == null ? string.Empty : _version.ToString(); + get => _version is null ? string.Empty : _version.ToString(); set => _version = SysVersion.Parse(value); } |
