aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2022-12-07 17:40:24 +0100
committerShadowghost <Ghost_of_Stone@web.de>2022-12-07 17:40:24 +0100
commit2c86bd1875e6e85d5867618e992d850453dae663 (patch)
tree671070fb246fd3821bf6f1e58a01c402a2f969d1
parentdd5f90802e71083347b6095eb79a9de0b9d34615 (diff)
parent3cb7fe50127b1a8158186b390836ee25ae5a50fd (diff)
Merge branch 'master' into network-rewrite
-rw-r--r--.ci/azure-pipelines-abi.yml2
-rw-r--r--.ci/azure-pipelines-main.yml31
-rw-r--r--.ci/azure-pipelines-package.yml4
-rw-r--r--.ci/azure-pipelines-test.yml4
-rw-r--r--.github/workflows/automation.yml1
-rw-r--r--.github/workflows/codeql-analysis.yml10
-rw-r--r--.github/workflows/commands.yml4
-rw-r--r--.github/workflows/openapi.yml17
-rw-r--r--.github/workflows/repo-stale.yaml1
-rw-r--r--.gitignore1
-rw-r--r--.vscode/launch.json10
-rw-r--r--DvdLib/DvdLib.csproj2
-rw-r--r--Emby.Dlna/ContentDirectory/ContentDirectoryService.cs4
-rw-r--r--Emby.Dlna/ContentDirectory/ControlHandler.cs2
-rw-r--r--Emby.Dlna/Didl/DidlBuilder.cs32
-rw-r--r--Emby.Dlna/DlnaManager.cs42
-rw-r--r--Emby.Dlna/Emby.Dlna.csproj6
-rw-r--r--Emby.Dlna/Eventing/DlnaEventManager.cs2
-rw-r--r--Emby.Dlna/IDlnaEventManager.cs1
-rw-r--r--Emby.Dlna/Main/DlnaEntryPoint.cs14
-rw-r--r--Emby.Dlna/PlayTo/Device.cs151
-rw-r--r--Emby.Dlna/PlayTo/PlayToController.cs42
-rw-r--r--Emby.Dlna/PlayTo/PlayToManager.cs4
-rw-r--r--Emby.Dlna/PlayTo/PlaylistItemFactory.cs4
-rw-r--r--Emby.Dlna/PlayTo/TransportCommands.cs6
-rw-r--r--Emby.Dlna/Server/DescriptionXmlBuilder.cs11
-rw-r--r--Emby.Dlna/Service/BaseControlHandler.cs2
-rw-r--r--Emby.Dlna/Service/BaseService.cs1
-rw-r--r--Emby.Dlna/Ssdp/DeviceDiscovery.cs8
-rw-r--r--Emby.Drawing/Emby.Drawing.csproj6
-rw-r--r--Emby.Drawing/ImageProcessor.cs19
-rw-r--r--Emby.Naming/AudioBook/AudioBookListResolver.cs4
-rw-r--r--Emby.Naming/AudioBook/AudioBookNameParser.cs2
-rw-r--r--Emby.Naming/Emby.Naming.csproj4
-rw-r--r--Emby.Naming/ExternalFiles/ExternalPathParser.cs4
-rw-r--r--Emby.Naming/TV/EpisodePathParser.cs2
-rw-r--r--Emby.Naming/TV/SeriesPathParser.cs2
-rw-r--r--Emby.Naming/Video/ExtraRuleResolver.cs2
-rw-r--r--Emby.Naming/Video/VideoListResolver.cs6
-rw-r--r--Emby.Naming/Video/VideoResolver.cs2
-rw-r--r--Emby.Notifications/Emby.Notifications.csproj2
-rw-r--r--Emby.Notifications/NotificationEntryPoint.cs2
-rw-r--r--Emby.Notifications/NotificationManager.cs4
-rw-r--r--Emby.Photos/Emby.Photos.csproj2
-rw-r--r--Emby.Photos/PhotoProvider.cs12
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs6
-rw-r--r--Emby.Server.Implementations/AppBase/ConfigurationHelper.cs2
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs8
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs33
-rw-r--r--Emby.Server.Implementations/Collections/CollectionImageProvider.cs6
-rw-r--r--Emby.Server.Implementations/Collections/CollectionManager.cs14
-rw-r--r--Emby.Server.Implementations/ConfigurationOptions.cs2
-rw-r--r--Emby.Server.Implementations/Cryptography/CryptographyProvider.cs38
-rw-r--r--Emby.Server.Implementations/Data/BaseSqliteRepository.cs2
-rw-r--r--Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs2
-rw-r--r--Emby.Server.Implementations/Data/SqliteExtensions.cs2
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs117
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserDataRepository.cs10
-rw-r--r--Emby.Server.Implementations/Data/TypeMapper.cs7
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs82
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj14
-rw-r--r--Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs10
-rw-r--r--Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs10
-rw-r--r--Emby.Server.Implementations/HttpServer/WebSocketConnection.cs4
-rw-r--r--Emby.Server.Implementations/IO/FileRefresher.cs22
-rw-r--r--Emby.Server.Implementations/IO/LibraryMonitor.cs22
-rw-r--r--Emby.Server.Implementations/IO/ManagedFileSystem.cs58
-rw-r--r--Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs16
-rw-r--r--Emby.Server.Implementations/IO/StreamHelper.cs2
-rw-r--r--Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs10
-rw-r--r--Emby.Server.Implementations/Images/DynamicImageProvider.cs6
-rw-r--r--Emby.Server.Implementations/Images/PlaylistImageProvider.cs6
-rw-r--r--Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs4
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs185
-rw-r--r--Emby.Server.Implementations/Library/LiveStreamHelper.cs8
-rw-r--r--Emby.Server.Implementations/Library/MediaSourceManager.cs50
-rw-r--r--Emby.Server.Implementations/Library/MediaStreamSelector.cs2
-rw-r--r--Emby.Server.Implementations/Library/ResolverHelper.cs15
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs10
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs4
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs20
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs12
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs6
-rw-r--r--Emby.Server.Implementations/Library/SearchEngine.cs5
-rw-r--r--Emby.Server.Implementations/Library/UserDataManager.cs2
-rw-r--r--Emby.Server.Implementations/Library/UserViewManager.cs10
-rw-r--r--Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs82
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs5
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs7
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs92
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs8
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs46
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs46
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs19
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs8
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs2
-rw-r--r--Emby.Server.Implementations/Localization/Core/da.json8
-rw-r--r--Emby.Server.Implementations/Localization/Core/ka.json83
-rw-r--r--Emby.Server.Implementations/Localization/Core/sv.json3
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs19
-rw-r--r--Emby.Server.Implementations/MediaEncoder/EncodingManager.cs2
-rw-r--r--Emby.Server.Implementations/Net/UdpSocket.cs4
-rw-r--r--Emby.Server.Implementations/Playlists/PlaylistManager.cs17
-rw-r--r--Emby.Server.Implementations/Playlists/PlaylistsFolder.cs2
-rw-r--r--Emby.Server.Implementations/Plugins/PluginManager.cs23
-rw-r--r--Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs23
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs22
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/TaskManager.cs6
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs2
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs4
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs108
-rw-r--r--Emby.Server.Implementations/Session/SessionWebSocketListener.cs6
-rw-r--r--Emby.Server.Implementations/Session/WebSocketController.cs2
-rw-r--r--Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs6
-rw-r--r--Emby.Server.Implementations/Sorting/DatePlayedComparer.cs2
-rw-r--r--Emby.Server.Implementations/Sorting/PlayCountComparer.cs2
-rw-r--r--Emby.Server.Implementations/Sorting/PremiereDateComparer.cs2
-rw-r--r--Emby.Server.Implementations/Sorting/ProductionYearComparer.cs2
-rw-r--r--Emby.Server.Implementations/SyncPlay/Group.cs6
-rw-r--r--Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs22
-rw-r--r--Emby.Server.Implementations/TV/TVSeriesManager.cs20
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs26
-rw-r--r--Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs2
-rw-r--r--Jellyfin.Api/Auth/BaseAuthorizationHandler.cs4
-rw-r--r--Jellyfin.Api/Controllers/ArtistsController.cs4
-rw-r--r--Jellyfin.Api/Controllers/ConfigurationController.cs2
-rw-r--r--Jellyfin.Api/Controllers/DashboardController.cs4
-rw-r--r--Jellyfin.Api/Controllers/DevicesController.cs6
-rw-r--r--Jellyfin.Api/Controllers/DisplayPreferencesController.cs2
-rw-r--r--Jellyfin.Api/Controllers/DlnaController.cs6
-rw-r--r--Jellyfin.Api/Controllers/DlnaServerController.cs2
-rw-r--r--Jellyfin.Api/Controllers/DynamicHlsController.cs26
-rw-r--r--Jellyfin.Api/Controllers/EnvironmentController.cs2
-rw-r--r--Jellyfin.Api/Controllers/FilterController.cs2
-rw-r--r--Jellyfin.Api/Controllers/HlsSegmentController.cs4
-rw-r--r--Jellyfin.Api/Controllers/ImageByNameController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ImageController.cs69
-rw-r--r--Jellyfin.Api/Controllers/ItemLookupController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ItemRefreshController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ItemUpdateController.cs22
-rw-r--r--Jellyfin.Api/Controllers/ItemsController.cs6
-rw-r--r--Jellyfin.Api/Controllers/LibraryController.cs44
-rw-r--r--Jellyfin.Api/Controllers/LibraryStructureController.cs2
-rw-r--r--Jellyfin.Api/Controllers/LiveTvController.cs6
-rw-r--r--Jellyfin.Api/Controllers/MediaInfoController.cs10
-rw-r--r--Jellyfin.Api/Controllers/PackageController.cs4
-rw-r--r--Jellyfin.Api/Controllers/PersonsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/PlaylistsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/PlaystateController.cs2
-rw-r--r--Jellyfin.Api/Controllers/PluginsController.cs18
-rw-r--r--Jellyfin.Api/Controllers/RemoteImageController.cs6
-rw-r--r--Jellyfin.Api/Controllers/ScheduledTasksController.cs8
-rw-r--r--Jellyfin.Api/Controllers/SearchController.cs14
-rw-r--r--Jellyfin.Api/Controllers/SessionController.cs5
-rw-r--r--Jellyfin.Api/Controllers/StartupController.cs2
-rw-r--r--Jellyfin.Api/Controllers/SubtitleController.cs4
-rw-r--r--Jellyfin.Api/Controllers/TvShowsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/UserController.cs14
-rw-r--r--Jellyfin.Api/Controllers/UserLibraryController.cs6
-rw-r--r--Jellyfin.Api/Controllers/UserViewsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/VideoAttachmentsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/VideosController.cs10
-rw-r--r--Jellyfin.Api/Controllers/YearsController.cs4
-rw-r--r--Jellyfin.Api/Helpers/AudioHelper.cs8
-rw-r--r--Jellyfin.Api/Helpers/DynamicHlsHelper.cs60
-rw-r--r--Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs16
-rw-r--r--Jellyfin.Api/Helpers/HlsHelpers.cs4
-rw-r--r--Jellyfin.Api/Helpers/MediaInfoHelper.cs14
-rw-r--r--Jellyfin.Api/Helpers/ProgressiveFileStream.cs4
-rw-r--r--Jellyfin.Api/Helpers/RequestHelpers.cs2
-rw-r--r--Jellyfin.Api/Helpers/StreamingHelpers.cs64
-rw-r--r--Jellyfin.Api/Helpers/TranscodingJobHelper.cs28
-rw-r--r--Jellyfin.Api/Jellyfin.Api.csproj8
-rw-r--r--Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs2
-rw-r--r--Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs2
-rw-r--r--Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs2
-rw-r--r--Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs6
-rw-r--r--Jellyfin.Api/Models/PlaybackDtos/TranscodingThrottler.cs2
-rw-r--r--Jellyfin.Api/Models/StreamingDtos/StreamState.cs2
-rw-r--r--Jellyfin.Data/Entities/ActivityLog.cs11
-rw-r--r--Jellyfin.Data/Entities/Group.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/Artwork.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/Chapter.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/ItemMetadata.cs11
-rw-r--r--Jellyfin.Data/Entities/Libraries/MediaFile.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/MetadataProvider.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/Person.cs5
-rw-r--r--Jellyfin.Data/Entities/Libraries/Release.cs5
-rw-r--r--Jellyfin.Data/Entities/User.cs25
-rw-r--r--Jellyfin.Data/Jellyfin.Data.csproj4
-rw-r--r--Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj2
-rw-r--r--Jellyfin.Drawing.Skia/SkiaEncoder.cs24
-rw-r--r--Jellyfin.Drawing.Skia/SkiaHelper.cs2
-rw-r--r--Jellyfin.Drawing.Skia/SplashscreenBuilder.cs2
-rw-r--r--Jellyfin.Drawing.Skia/StripCollageBuilder.cs4
-rw-r--r--Jellyfin.Networking/Jellyfin.Networking.csproj2
-rw-r--r--Jellyfin.Server.Implementations/Devices/DeviceManager.cs14
-rw-r--r--Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs6
-rw-r--r--Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs8
-rw-r--r--Jellyfin.Server.Implementations/Events/EventManager.cs2
-rw-r--r--Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs2
-rw-r--r--Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj12
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthenticationManager.cs2
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthorizationContext.cs8
-rw-r--r--Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs4
-rw-r--r--Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs4
-rw-r--r--Jellyfin.Server.Implementations/Users/UserManager.cs20
-rw-r--r--Jellyfin.Server/Filters/FileResponseFilter.cs2
-rw-r--r--Jellyfin.Server/Filters/SecurityRequirementsOperationFilter.cs6
-rw-r--r--Jellyfin.Server/Formatters/CssOutputFormatter.cs2
-rw-r--r--Jellyfin.Server/Formatters/XmlOutputFormatter.cs2
-rw-r--r--Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs4
-rw-r--r--Jellyfin.Server/Jellyfin.Server.csproj12
-rw-r--r--Jellyfin.Server/Middleware/ExceptionMiddleware.cs2
-rw-r--r--Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs2
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs4
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs2
-rw-r--r--Jellyfin.Server/Program.cs31
-rw-r--r--Jellyfin.Server/StartupOptions.cs8
-rw-r--r--MediaBrowser.Common/Events/EventHelper.cs4
-rw-r--r--MediaBrowser.Common/Extensions/HttpContextExtensions.cs4
-rw-r--r--MediaBrowser.Common/MediaBrowser.Common.csproj8
-rw-r--r--MediaBrowser.Common/Plugins/BasePluginOfT.cs4
-rw-r--r--MediaBrowser.Common/Plugins/LocalPlugin.cs8
-rw-r--r--MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs8
-rw-r--r--MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs2
-rw-r--r--MediaBrowser.Controller/Entities/AggregateFolder.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Audio.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs2
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs68
-rw-r--r--MediaBrowser.Controller/Entities/BaseItemExtensions.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Extensions.cs9
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs42
-rw-r--r--MediaBrowser.Controller/Entities/InternalItemsQuery.cs4
-rw-r--r--MediaBrowser.Controller/Entities/ItemImageInfo.cs2
-rw-r--r--MediaBrowser.Controller/Entities/Movies/Movie.cs2
-rw-r--r--MediaBrowser.Controller/Entities/PeopleHelper.cs12
-rw-r--r--MediaBrowser.Controller/Entities/TV/Episode.cs24
-rw-r--r--MediaBrowser.Controller/Entities/TV/Season.cs18
-rw-r--r--MediaBrowser.Controller/Entities/TV/Series.cs12
-rw-r--r--MediaBrowser.Controller/Entities/UserItemData.cs2
-rw-r--r--MediaBrowser.Controller/Entities/UserRootFolder.cs4
-rw-r--r--MediaBrowser.Controller/Entities/UserViewBuilder.cs28
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs8
-rw-r--r--MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs8
-rw-r--r--MediaBrowser.Controller/IO/FileData.cs5
-rw-r--r--MediaBrowser.Controller/Library/ItemResolveArgs.cs31
-rw-r--r--MediaBrowser.Controller/Library/NameExtensions.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvChannel.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvProgram.cs2
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj10
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs99
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs18
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs2
-rw-r--r--MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs4
-rw-r--r--MediaBrowser.Controller/Playlists/Playlist.cs2
-rw-r--r--MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs3
-rw-r--r--MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs4
-rw-r--r--MediaBrowser.Controller/Providers/MetadataResult.cs4
-rw-r--r--MediaBrowser.Controller/Resolvers/ItemResolver.cs2
-rw-r--r--MediaBrowser.Controller/Session/SessionInfo.cs14
-rw-r--r--MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs4
-rw-r--r--MediaBrowser.LocalMetadata/BaseXmlProvider.cs4
-rw-r--r--MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs2
-rw-r--r--MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs6
-rw-r--r--MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj2
-rw-r--r--MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs8
-rw-r--r--MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs2
-rw-r--r--MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs2
-rw-r--r--MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs4
-rw-r--r--MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs25
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs2
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs4
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs8
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs19
-rw-r--r--MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj8
-rw-r--r--MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs6
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs52
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs33
-rw-r--r--MediaBrowser.Model/Cryptography/PasswordHash.cs7
-rw-r--r--MediaBrowser.Model/Dlna/AudioOptions.cs2
-rw-r--r--MediaBrowser.Model/Dlna/ContainerProfile.cs4
-rw-r--r--MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs2
-rw-r--r--MediaBrowser.Model/Dlna/ResolutionNormalizer.cs2
-rw-r--r--MediaBrowser.Model/Dlna/SearchCriteria.cs5
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs87
-rw-r--r--MediaBrowser.Model/Dlna/StreamInfo.cs18
-rw-r--r--MediaBrowser.Model/Drawing/DrawingUtils.cs8
-rw-r--r--MediaBrowser.Model/Dto/BaseItemPerson.cs2
-rw-r--r--MediaBrowser.Model/Dto/MediaSourceInfo.cs2
-rw-r--r--MediaBrowser.Model/Entities/ProviderIdsExtensions.cs2
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj8
-rw-r--r--MediaBrowser.Model/Net/MimeTypes.cs10
-rw-r--r--MediaBrowser.Model/Notifications/NotificationOptions.cs8
-rw-r--r--MediaBrowser.Model/Updates/VersionInfo.cs2
-rw-r--r--MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs2
-rw-r--r--MediaBrowser.Providers/Manager/ImageSaver.cs17
-rw-r--r--MediaBrowser.Providers/Manager/ItemImageProvider.cs10
-rw-r--r--MediaBrowser.Providers/Manager/MetadataService.cs27
-rw-r--r--MediaBrowser.Providers/Manager/ProviderManager.cs16
-rw-r--r--MediaBrowser.Providers/MediaBrowser.Providers.csproj10
-rw-r--r--MediaBrowser.Providers/MediaInfo/AudioFileProber.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs20
-rw-r--r--MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/ProbeProvider.cs8
-rw-r--r--MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs4
-rw-r--r--MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/Music/AlbumMetadataService.cs1
-rw-r--r--MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs29
-rw-r--r--MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzArtistProvider.cs28
-rw-r--r--MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs20
-rw-r--r--MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs8
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs22
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs10
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs6
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs30
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs24
-rw-r--r--MediaBrowser.Providers/Subtitles/SubtitleManager.cs6
-rw-r--r--MediaBrowser.Providers/TV/SeriesMetadataService.cs4
-rw-r--r--MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj2
-rw-r--r--MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs21
-rw-r--r--MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs4
-rw-r--r--MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs4
-rw-r--r--MediaBrowser.XbmcMetadata/Providers/BaseVideoNfoProvider.cs4
-rw-r--r--MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs10
-rw-r--r--README.md4
-rw-r--r--RSSDP/RSSDP.csproj2
-rw-r--r--build.yaml3
-rw-r--r--deployment/Dockerfile.macos.amd64 (renamed from deployment/Dockerfile.macos)2
-rw-r--r--deployment/Dockerfile.macos.arm6426
-rwxr-xr-xdeployment/build.macos.amd64 (renamed from deployment/build.macos)2
-rwxr-xr-xdeployment/build.macos.arm6431
-rw-r--r--fuzz/Emby.Server.Implementations.Fuzz/Emby.Server.Implementations.Fuzz.csproj4
-rw-r--r--fuzz/Jellyfin.Server.Fuzz/Jellyfin.Server.Fuzz.csproj2
-rw-r--r--jellyfin.ruleset2
-rw-r--r--src/Jellyfin.Extensions/AlphanumericComparator.cs6
-rw-r--r--src/Jellyfin.Extensions/Jellyfin.Extensions.csproj2
-rw-r--r--src/Jellyfin.MediaEncoding.Hls/Cache/CacheDecorator.cs2
-rw-r--r--src/Jellyfin.MediaEncoding.Hls/Jellyfin.MediaEncoding.Hls.csproj4
-rw-r--r--src/Jellyfin.MediaEncoding.Keyframes/Jellyfin.MediaEncoding.Keyframes.csproj4
-rw-r--r--tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj6
-rw-r--r--tests/Jellyfin.Api.Tests/TestHelpers.cs2
-rw-r--r--tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj2
-rw-r--r--tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs25
-rw-r--r--tests/Jellyfin.Controller.Tests/Jellyfin.Controller.Tests.csproj2
-rw-r--r--tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj2
-rw-r--r--tests/Jellyfin.Extensions.Tests/Jellyfin.Extensions.Tests.csproj2
-rw-r--r--tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj2
-rw-r--r--tests/Jellyfin.MediaEncoding.Keyframes.Tests/Jellyfin.MediaEncoding.Keyframes.Tests.csproj2
-rw-r--r--tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj2
-rw-r--r--tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs6
-rw-r--r--tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj2
-rw-r--r--tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj2
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs2
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs2
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs8
-rw-r--r--tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj2
-rw-r--r--tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj2
-rw-r--r--tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs12
-rw-r--r--tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs14
-rw-r--r--tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs4
-rw-r--r--tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs2
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj2
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs2
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs4
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj6
-rw-r--r--tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj6
-rw-r--r--tests/Jellyfin.XbmcMetadata.Tests/Jellyfin.XbmcMetadata.Tests.csproj2
397 files changed, 2090 insertions, 2340 deletions
diff --git a/.ci/azure-pipelines-abi.yml b/.ci/azure-pipelines-abi.yml
index cf74a4201..4b82eedb4 100644
--- a/.ci/azure-pipelines-abi.yml
+++ b/.ci/azure-pipelines-abi.yml
@@ -7,7 +7,7 @@ parameters:
default: "ubuntu-latest"
- name: DotNetSdkVersion
type: string
- default: 6.0.x
+ default: 7.0.x
jobs:
- job: CompatibilityCheck
diff --git a/.ci/azure-pipelines-main.yml b/.ci/azure-pipelines-main.yml
index b7112ba24..020d7fff4 100644
--- a/.ci/azure-pipelines-main.yml
+++ b/.ci/azure-pipelines-main.yml
@@ -1,7 +1,7 @@
parameters:
LinuxImage: 'ubuntu-latest'
RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj'
- DotNetSdkVersion: 6.0.x
+ DotNetSdkVersion: 7.0.x
jobs:
- job: Build
@@ -20,35 +20,6 @@ jobs:
submodules: true
persistCredentials: true
- - task: DownloadPipelineArtifact@2
- displayName: 'Download Web Branch'
- condition: in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion')
- inputs:
- path: '$(Agent.TempDirectory)'
- artifact: 'jellyfin-web-production'
- source: 'specific'
- project: 'jellyfin'
- pipeline: 'Jellyfin Web'
- runBranch: variables['Build.SourceBranch']
-
- - task: DownloadPipelineArtifact@2
- displayName: 'Download Web Target'
- condition: eq(variables['Build.Reason'], 'PullRequest')
- inputs:
- path: '$(Agent.TempDirectory)'
- artifact: 'jellyfin-web-production'
- source: 'specific'
- project: 'jellyfin'
- pipeline: 'Jellyfin Web'
- runBranch: variables['System.PullRequest.TargetBranch']
-
- - task: ExtractFiles@1
- displayName: 'Extract Web Client'
- inputs:
- archiveFilePatterns: '$(Agent.TempDirectory)/*.zip'
- destinationFolder: '$(Build.SourcesDirectory)/MediaBrowser.WebDashboard'
- cleanDestinationFolder: false
-
- task: UseDotNet@2
displayName: 'Update DotNet'
inputs:
diff --git a/.ci/azure-pipelines-package.yml b/.ci/azure-pipelines-package.yml
index 926d1d322..83504fefe 100644
--- a/.ci/azure-pipelines-package.yml
+++ b/.ci/azure-pipelines-package.yml
@@ -205,10 +205,10 @@ jobs:
steps:
- task: UseDotNet@2
- displayName: 'Use .NET 6.0 sdk'
+ displayName: 'Use .NET 7.0 sdk'
inputs:
packageType: 'sdk'
- version: '6.0.x'
+ version: '7.0.x'
- task: DotNetCoreCLI@2
displayName: 'Build Stable Nuget packages'
diff --git a/.ci/azure-pipelines-test.yml b/.ci/azure-pipelines-test.yml
index cc94dc2c5..81362aab2 100644
--- a/.ci/azure-pipelines-test.yml
+++ b/.ci/azure-pipelines-test.yml
@@ -10,7 +10,7 @@ parameters:
default: "tests/**/*Tests.csproj"
- name: DotNetSdkVersion
type: string
- default: 6.0.x
+ default: 7.0.x
jobs:
- job: Test
@@ -94,5 +94,5 @@ jobs:
displayName: 'Publish OpenAPI Artifact'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
inputs:
- targetPath: "tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json"
+ targetPath: "tests/Jellyfin.Server.Integration.Tests/bin/Release/net7.0/openapi.json"
artifactName: 'OpenAPI Spec'
diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml
index 0989df64b..2dc7fb5a3 100644
--- a/.github/workflows/automation.yml
+++ b/.github/workflows/automation.yml
@@ -7,6 +7,7 @@ on:
pull_request_target:
issue_comment:
+permissions: {}
jobs:
label:
name: Labeling
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index adca9680f..f385aecb6 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -21,17 +21,17 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
- - name: Setup .NET Core
+ - name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '7.0.x'
- name: Initialize CodeQL
- uses: github/codeql-action/init@312e093a1892bd801f026f1090904ee8e460b9b6 # v2
+ uses: github/codeql-action/init@b2a92eb56d8cb930006a1c6ed86b0782dd8a4297 # v2
with:
languages: ${{ matrix.language }}
queries: +security-extended
- name: Autobuild
- uses: github/codeql-action/autobuild@312e093a1892bd801f026f1090904ee8e460b9b6 # v2
+ uses: github/codeql-action/autobuild@b2a92eb56d8cb930006a1c6ed86b0782dd8a4297 # v2
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@312e093a1892bd801f026f1090904ee8e460b9b6 # v2
+ uses: github/codeql-action/analyze@b2a92eb56d8cb930006a1c6ed86b0782dd8a4297 # v2
diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml
index a29519b29..f7fbc4706 100644
--- a/.github/workflows/commands.yml
+++ b/.github/workflows/commands.yml
@@ -9,6 +9,7 @@ on:
- labeled
- synchronize
+permissions: {}
jobs:
rebase:
name: Rebase
@@ -34,6 +35,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
check-backport:
+ permissions:
+ contents: read
+
name: Check Backport
if: ${{ ( github.event.issue.pull_request && contains(github.event.comment.body, '@jellyfin-bot check backport') ) || github.event.label.name == 'stable backport' || contains(github.event.pull_request.labels.*.name, 'stable backport' ) }}
runs-on: ubuntu-latest
diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml
index 390d140fd..d7ace118b 100644
--- a/.github/workflows/openapi.yml
+++ b/.github/workflows/openapi.yml
@@ -5,6 +5,8 @@ on:
- master
pull_request_target:
+permissions: {}
+
jobs:
openapi-head:
name: OpenAPI - HEAD
@@ -16,10 +18,10 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- - name: Setup .NET Core
+ - name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '7.0.x'
- name: Generate openapi.json
run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
- name: Upload openapi.json
@@ -28,7 +30,7 @@ jobs:
name: openapi-head
retention-days: 14
if-no-files-found: error
- path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
+ path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net7.0/openapi.json
openapi-base:
name: OpenAPI - BASE
@@ -40,10 +42,10 @@ jobs:
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
with:
ref: ${{ github.base_ref }}
- - name: Setup .NET Core
+ - name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '7.0.x'
- name: Generate openapi.json
run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
- name: Upload openapi.json
@@ -52,9 +54,12 @@ jobs:
name: openapi-base
retention-days: 14
if-no-files-found: error
- path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
+ path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net7.0/openapi.json
openapi-diff:
+ permissions:
+ pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
+
name: OpenAPI - Difference
if: ${{ github.event_name == 'pull_request_target' }}
runs-on: ubuntu-latest
diff --git a/.github/workflows/repo-stale.yaml b/.github/workflows/repo-stale.yaml
index f7a77f02b..1c6fe1492 100644
--- a/.github/workflows/repo-stale.yaml
+++ b/.github/workflows/repo-stale.yaml
@@ -5,6 +5,7 @@ on:
- cron: '30 1 * * *'
workflow_dispatch:
+permissions: {}
jobs:
stale:
runs-on: ubuntu-latest
diff --git a/.gitignore b/.gitignore
index fd8e1f314..d5a0367bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -273,7 +273,6 @@ BenchmarkDotNet.Artifacts
# Ignore web artifacts from native builds
web/
web-src.*
-MediaBrowser.WebDashboard/jellyfin-web
apiclient/generated
# Omnisharp crash logs
diff --git a/.vscode/launch.json b/.vscode/launch.json
index b82956a72..55e6508a9 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -2,11 +2,11 @@
"version": "0.2.0",
"configurations": [
{
- "name": ".NET Core Launch (console)",
+ "name": ".NET Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
- "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net6.0/jellyfin.dll",
+ "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net7.0/jellyfin.dll",
"args": [],
"cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole",
@@ -18,11 +18,11 @@
}
},
{
- "name": ".NET Core Launch (nowebclient)",
+ "name": ".NET Launch (nowebclient)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
- "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net6.0/jellyfin.dll",
+ "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net7.0/jellyfin.dll",
"args": ["--nowebclient"],
"cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole",
@@ -30,7 +30,7 @@
"internalConsoleOptions": "openOnSessionStart"
},
{
- "name": ".NET Core Attach",
+ "name": ".NET Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
diff --git a/DvdLib/DvdLib.csproj b/DvdLib/DvdLib.csproj
index 755d29160..1053c0089 100644
--- a/DvdLib/DvdLib.csproj
+++ b/DvdLib/DvdLib.csproj
@@ -10,7 +10,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AnalysisMode>AllDisabledByDefault</AnalysisMode>
diff --git a/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs b/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs
index 319a9f550..389e971a6 100644
--- a/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs
+++ b/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs
@@ -141,7 +141,7 @@ namespace Emby.Dlna.ContentDirectory
{
var user = _userManager.GetUserById(Guid.Parse(profile.UserId));
- if (user != null)
+ if (user is not null)
{
return user;
}
@@ -153,7 +153,7 @@ namespace Emby.Dlna.ContentDirectory
{
var user = _userManager.GetUserById(Guid.Parse(userId));
- if (user != null)
+ if (user is not null)
{
return user;
}
diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs
index fc69960fd..abd594a3a 100644
--- a/Emby.Dlna/ContentDirectory/ControlHandler.cs
+++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs
@@ -1048,7 +1048,7 @@ namespace Emby.Dlna.ContentDirectory
ParentId = parent?.Id ?? Guid.Empty,
GroupItems = true
},
- query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToArray();
+ query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i is not null).ToArray();
return ToResult(query.StartIndex, items);
}
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index 8e3a335c6..e9041186f 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/Emby.Dlna/Didl/DidlBuilder.cs
@@ -153,7 +153,7 @@ namespace Emby.Dlna.Didl
writer.WriteAttributeString("restricted", "1");
writer.WriteAttributeString("id", clientId);
- if (context != null)
+ if (context is not null)
{
writer.WriteAttributeString("parentID", GetClientId(context, contextStubType));
}
@@ -191,7 +191,7 @@ namespace Emby.Dlna.Didl
private void AddVideoResource(XmlWriter writer, BaseItem video, string deviceId, Filter filter, StreamInfo streamInfo = null)
{
- if (streamInfo == null)
+ if (streamInfo is null)
{
var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user);
@@ -263,7 +263,7 @@ namespace Emby.Dlna.Didl
.FirstOrDefault(i => string.Equals(info.Format, i.Format, StringComparison.OrdinalIgnoreCase)
&& i.Method == SubtitleDeliveryMethod.External);
- if (subtitleProfile == null)
+ if (subtitleProfile is null)
{
return false;
}
@@ -392,7 +392,7 @@ namespace Emby.Dlna.Didl
var filename = url.Substring(0, url.IndexOf('?', StringComparison.Ordinal));
- var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
+ var mimeType = mediaProfile is null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType;
@@ -533,7 +533,7 @@ namespace Emby.Dlna.Didl
{
writer.WriteStartElement(string.Empty, "res", NsDidl);
- if (streamInfo == null)
+ if (streamInfo is null)
{
var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user);
@@ -598,7 +598,7 @@ namespace Emby.Dlna.Didl
var filename = url.Substring(0, url.IndexOf('?', StringComparison.Ordinal));
- var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
+ var mimeType = mediaProfile is null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType;
@@ -652,7 +652,7 @@ namespace Emby.Dlna.Didl
{
writer.WriteAttributeString("id", clientId);
- if (context != null)
+ if (context is not null)
{
writer.WriteAttributeString("parentID", GetClientId(context, null));
}
@@ -695,13 +695,13 @@ namespace Emby.Dlna.Didl
}
// Not a samsung device
- if (secAttribute == null)
+ if (secAttribute is null)
{
return;
}
var userdata = _userDataManager.GetUserData(user, item);
- var playbackPositionTicks = (streamInfo != null && streamInfo.StartPositionTicks > 0) ? streamInfo.StartPositionTicks : userdata.PlaybackPositionTicks;
+ var playbackPositionTicks = (streamInfo is not null && streamInfo.StartPositionTicks > 0) ? streamInfo.StartPositionTicks : userdata.PlaybackPositionTicks;
if (playbackPositionTicks > 0)
{
@@ -909,14 +909,14 @@ namespace Emby.Dlna.Didl
AddValue(writer, "dc", "creator", artist, NsDc);
// If it doesn't support album artists (musicvideo), then tag as both
- if (hasAlbumArtists == null)
+ if (hasAlbumArtists is null)
{
AddAlbumArtist(writer, artist);
}
}
}
- if (hasAlbumArtists != null)
+ if (hasAlbumArtists is not null)
{
foreach (var albumArtist in hasAlbumArtists.AlbumArtists)
{
@@ -973,7 +973,7 @@ namespace Emby.Dlna.Didl
{
ImageDownloadInfo imageInfo = GetImageInfo(item);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return;
}
@@ -1036,7 +1036,7 @@ namespace Emby.Dlna.Didl
{
var imageInfo = GetImageInfo(item);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return;
}
@@ -1093,7 +1093,7 @@ namespace Emby.Dlna.Didl
if (item is Audio audioItem)
{
var album = audioItem.AlbumEntity;
- return album != null && album.HasImage(ImageType.Primary)
+ return album is not null && album.HasImage(ImageType.Primary)
? GetImageInfo(album, ImageType.Primary)
: null;
}
@@ -1106,7 +1106,7 @@ namespace Emby.Dlna.Didl
// For other item types check parents, but be aware that image retrieved from a parent may be not suitable for this media item.
var parentWithImage = GetFirstParentWithImageBelowUserRoot(item);
- if (parentWithImage != null)
+ if (parentWithImage is not null)
{
return GetImageInfo(parentWithImage, ImageType.Primary);
}
@@ -1116,7 +1116,7 @@ namespace Emby.Dlna.Didl
private BaseItem GetFirstParentWithImageBelowUserRoot(BaseItem item)
{
- if (item == null)
+ if (item is null)
{
return null;
}
diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs
index 2ea2c130f..99b3e6e7e 100644
--- a/Emby.Dlna/DlnaManager.cs
+++ b/Emby.Dlna/DlnaManager.cs
@@ -105,9 +105,9 @@ namespace Emby.Dlna
ArgumentNullException.ThrowIfNull(deviceInfo);
var profile = GetProfiles()
- .FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification));
+ .FirstOrDefault(i => i.Identification is not null && IsMatch(deviceInfo, i.Identification));
- if (profile == null)
+ if (profile is null)
{
_logger.LogInformation("No matching device profile found. The default will need to be used. \n{@Profile}", deviceInfo);
}
@@ -171,8 +171,8 @@ namespace Emby.Dlna
{
ArgumentNullException.ThrowIfNull(headers);
- var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification));
- if (profile == null)
+ var profile = GetProfiles().FirstOrDefault(i => i.Identification is not null && IsMatch(headers, i.Identification));
+ if (profile is null)
{
_logger.LogDebug("No matching device profile found. {@Headers}", headers);
}
@@ -199,6 +199,11 @@ namespace Emby.Dlna
if (headers.TryGetValue(header.Name, out StringValues value))
{
+ if (StringValues.IsNullOrEmpty(value))
+ {
+ return false;
+ }
+
switch (header.Match)
{
case HeaderMatchType.Equals:
@@ -208,7 +213,8 @@ namespace Emby.Dlna
// _logger.LogDebug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch);
return isMatch;
case HeaderMatchType.Regex:
- return Regex.IsMatch(value, header.Value, RegexOptions.IgnoreCase);
+ // Can't be null, we checked above the switch statement
+ return Regex.IsMatch(value!, header.Value, RegexOptions.IgnoreCase);
default:
throw new ArgumentException("Unrecognized HeaderMatchType");
}
@@ -224,7 +230,7 @@ namespace Emby.Dlna
return _fileSystem.GetFilePaths(path)
.Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase))
.Select(i => ParseProfileFile(i, type))
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList()!; // We just filtered out all the nulls
}
catch (IOException)
@@ -265,14 +271,11 @@ namespace Emby.Dlna
/// <inheritdoc />
public DeviceProfile? GetProfile(string id)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
var info = GetProfileInfosInternal().FirstOrDefault(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase));
- if (info == null)
+ if (info is null)
{
return null;
}
@@ -371,10 +374,7 @@ namespace Emby.Dlna
{
profile = ReserializeProfile(profile);
- if (string.IsNullOrEmpty(profile.Name))
- {
- throw new ArgumentException("Profile is missing Name");
- }
+ ArgumentException.ThrowIfNullOrEmpty(profile.Name);
var newFilename = _fileSystem.GetValidFilename(profile.Name) + ".xml";
var path = Path.Combine(UserProfilesPath, newFilename);
@@ -387,15 +387,9 @@ namespace Emby.Dlna
{
profile = ReserializeProfile(profile);
- if (string.IsNullOrEmpty(profile.Id))
- {
- throw new ArgumentException("Profile is missing Id");
- }
+ ArgumentException.ThrowIfNullOrEmpty(profile.Id);
- if (string.IsNullOrEmpty(profile.Name))
- {
- throw new ArgumentException("Profile is missing Name");
- }
+ ArgumentException.ThrowIfNullOrEmpty(profile.Name);
var current = GetProfileInfosInternal().First(i => string.Equals(i.Info.Id, profileId, StringComparison.OrdinalIgnoreCase));
if (current.Info.Type == DeviceProfileType.System)
@@ -470,7 +464,7 @@ namespace Emby.Dlna
var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant();
var stream = _assembly.GetManifestResourceStream(resource);
- if (stream == null)
+ if (stream is null)
{
return null;
}
diff --git a/Emby.Dlna/Emby.Dlna.csproj b/Emby.Dlna/Emby.Dlna.csproj
index d59b43ef0..7ffb7118a 100644
--- a/Emby.Dlna/Emby.Dlna.csproj
+++ b/Emby.Dlna/Emby.Dlna.csproj
@@ -17,13 +17,13 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<!-- Code Analyzers-->
@@ -80,7 +80,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup>
</Project>
diff --git a/Emby.Dlna/Eventing/DlnaEventManager.cs b/Emby.Dlna/Eventing/DlnaEventManager.cs
index 68895a7fe..c0eacf5d8 100644
--- a/Emby.Dlna/Eventing/DlnaEventManager.cs
+++ b/Emby.Dlna/Eventing/DlnaEventManager.cs
@@ -35,7 +35,7 @@ namespace Emby.Dlna.Eventing
public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl)
{
var subscription = GetSubscription(subscriptionId, false);
- if (subscription != null)
+ if (subscription is not null)
{
subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;
int timeoutSeconds = subscription.TimeoutSeconds;
diff --git a/Emby.Dlna/IDlnaEventManager.cs b/Emby.Dlna/IDlnaEventManager.cs
index eea030d6d..bb1eeb963 100644
--- a/Emby.Dlna/IDlnaEventManager.cs
+++ b/Emby.Dlna/IDlnaEventManager.cs
@@ -1,3 +1,4 @@
+#nullable disable
#pragma warning disable CS1591
namespace Emby.Dlna
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs
index 7c26262fe..ec483199d 100644
--- a/Emby.Dlna/Main/DlnaEntryPoint.cs
+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs
@@ -198,7 +198,7 @@ namespace Emby.Dlna.Main
{
try
{
- if (_communicationsServer == null)
+ if (_communicationsServer is null)
{
var enableMultiSocketBinding = OperatingSystem.IsWindows() ||
OperatingSystem.IsLinux();
@@ -221,7 +221,7 @@ namespace Emby.Dlna.Main
{
try
{
- if (communicationsServer != null)
+ if (communicationsServer is not null)
{
((DeviceDiscovery)_deviceDiscovery).Start(communicationsServer);
}
@@ -252,7 +252,7 @@ namespace Emby.Dlna.Main
return;
}
- if (_publisher != null)
+ if (_publisher is not null)
{
return;
}
@@ -378,7 +378,7 @@ namespace Emby.Dlna.Main
{
lock (_syncLock)
{
- if (_manager != null)
+ if (_manager is not null)
{
return;
}
@@ -413,7 +413,7 @@ namespace Emby.Dlna.Main
{
lock (_syncLock)
{
- if (_manager != null)
+ if (_manager is not null)
{
try
{
@@ -432,7 +432,7 @@ namespace Emby.Dlna.Main
public void DisposeDevicePublisher()
{
- if (_publisher != null)
+ if (_publisher is not null)
{
_logger.LogInformation("Disposing SsdpDevicePublisher");
_publisher.Dispose();
@@ -452,7 +452,7 @@ namespace Emby.Dlna.Main
DisposePlayToManager();
DisposeDeviceDiscovery();
- if (_communicationsServer != null)
+ if (_communicationsServer is not null)
{
_logger.LogInformation("Disposing SsdpCommunicationsServer");
_communicationsServer.Dispose();
diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs
index 34981bd3f..9c476119d 100644
--- a/Emby.Dlna/PlayTo/Device.cs
+++ b/Emby.Dlna/PlayTo/Device.cs
@@ -220,14 +220,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetMute");
- if (command == null)
+ if (command is null)
{
return false;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
return false;
}
@@ -260,14 +260,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -291,14 +291,14 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Seek");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -324,7 +324,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogDebug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", Properties.Name, url, header);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI");
- if (command == null)
+ if (command is null)
{
return;
}
@@ -337,7 +337,7 @@ namespace Emby.Dlna.PlayTo
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -381,7 +381,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogDebug("{PropertyName} - SetNextAvTransport Uri: {Url} DlnaHeaders: {Header}", Properties.Name, url, header);
var command = avCommands.ServiceActions.FirstOrDefault(c => string.Equals(c.Name, "SetNextAVTransportURI", StringComparison.OrdinalIgnoreCase));
- if (command == null)
+ if (command is null)
{
return;
}
@@ -394,7 +394,7 @@ namespace Emby.Dlna.PlayTo
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -418,13 +418,13 @@ namespace Emby.Dlna.PlayTo
private Task SetPlay(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Play");
- if (command == null)
+ if (command is null)
{
return Task.CompletedTask;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -440,7 +440,7 @@ namespace Emby.Dlna.PlayTo
public async Task SetPlay(CancellationToken cancellationToken)
{
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (avCommands == null)
+ if (avCommands is null)
{
return;
}
@@ -455,7 +455,7 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Stop");
- if (command == null)
+ if (command is null)
{
return;
}
@@ -479,7 +479,7 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Pause");
- if (command == null)
+ if (command is null)
{
return;
}
@@ -513,7 +513,7 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (avCommands == null)
+ if (avCommands is null)
{
return;
}
@@ -538,12 +538,12 @@ namespace Emby.Dlna.PlayTo
var currentObject = tuple.Track;
- if (tuple.Success && currentObject == null)
+ if (tuple.Success && currentObject is null)
{
currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false);
}
- if (currentObject != null)
+ if (currentObject is not null)
{
UpdateMediaInfo(currentObject, transportState.Value);
}
@@ -585,7 +585,7 @@ namespace Emby.Dlna.PlayTo
if (_connectFailureCount >= 3)
{
var action = OnDeviceUnavailable;
- if (action != null)
+ if (action is not null)
{
_logger.LogDebug("Disposing device due to loss of connection");
action();
@@ -607,14 +607,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetVolume");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
return;
}
@@ -626,12 +626,12 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return;
}
- var volume = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetVolumeResponse").Select(i => i.Element("CurrentVolume")).FirstOrDefault(i => i != null);
+ var volume = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetVolumeResponse").Select(i => i.Element("CurrentVolume")).FirstOrDefault(i => i is not null);
var volumeValue = volume?.Value;
if (string.IsNullOrWhiteSpace(volumeValue))
@@ -657,14 +657,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetMute");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
return;
}
@@ -676,14 +676,14 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return;
}
var valueNode = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetMuteResponse")
.Select(i => i.Element("CurrentMute"))
- .FirstOrDefault(i => i != null);
+ .FirstOrDefault(i => i is not null);
IsMuted = string.Equals(valueNode?.Value, "1", StringComparison.OrdinalIgnoreCase);
}
@@ -691,13 +691,13 @@ namespace Emby.Dlna.PlayTo
private async Task<TransportState?> GetTransportInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetTransportInfo");
- if (command == null)
+ if (command is null)
{
return null;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
return null;
}
@@ -709,17 +709,17 @@ namespace Emby.Dlna.PlayTo
avCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return null;
}
var transportState =
- result.Document.Descendants(UPnpNamespaces.AvTransport + "GetTransportInfoResponse").Select(i => i.Element("CurrentTransportState")).FirstOrDefault(i => i != null);
+ result.Document.Descendants(UPnpNamespaces.AvTransport + "GetTransportInfoResponse").Select(i => i.Element("CurrentTransportState")).FirstOrDefault(i => i is not null);
var transportStateValue = transportState?.Value;
- if (transportStateValue != null
+ if (transportStateValue is not null
&& Enum.TryParse(transportStateValue, true, out TransportState state))
{
return state;
@@ -731,19 +731,19 @@ namespace Emby.Dlna.PlayTo
private async Task<UBaseObject> GetMediaInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo");
- if (command == null)
+ if (command is null)
{
return null;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (rendererCommands == null)
+ if (rendererCommands is null)
{
return null;
}
@@ -755,14 +755,14 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return null;
}
var track = result.Document.Descendants("CurrentURIMetaData").FirstOrDefault();
- if (track == null)
+ if (track is null)
{
return null;
}
@@ -778,7 +778,7 @@ namespace Emby.Dlna.PlayTo
track = result.Document.Descendants("CurrentURI").FirstOrDefault();
- if (track == null)
+ if (track is null)
{
return null;
}
@@ -801,21 +801,21 @@ namespace Emby.Dlna.PlayTo
private async Task<(bool Success, UBaseObject Track)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo");
- if (command == null)
+ if (command is null)
{
return (false, null);
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (rendererCommands == null)
+ if (rendererCommands is null)
{
return (false, null);
}
@@ -827,15 +827,15 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return (false, null);
}
- var trackUriElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i != null);
+ var trackUriElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i is not null);
var trackUri = trackUriElem?.Value;
- var durationElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i != null);
+ var durationElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i is not null);
var duration = durationElem?.Value;
if (!string.IsNullOrWhiteSpace(duration)
@@ -848,7 +848,7 @@ namespace Emby.Dlna.PlayTo
Duration = null;
}
- var positionElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i != null);
+ var positionElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i is not null);
var position = positionElem?.Value;
if (!string.IsNullOrWhiteSpace(position) && !string.Equals(position, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase))
@@ -858,7 +858,7 @@ namespace Emby.Dlna.PlayTo
var track = result.Document.Descendants("TrackMetaData").FirstOrDefault();
- if (track == null)
+ if (track is null)
{
// If track is null, some vendors do this, use GetMediaInfo instead.
return (true, null);
@@ -882,7 +882,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogError(ex, "Uncaught exception while parsing xml");
}
- if (uPnpResponse == null)
+ if (uPnpResponse is null)
{
_logger.LogError("Failed to parse xml: \n {Xml}", trackString);
return (true, null);
@@ -959,11 +959,11 @@ namespace Emby.Dlna.PlayTo
var resElement = container.Element(UPnpNamespaces.Res);
- if (resElement != null)
+ if (resElement is not null)
{
var info = resElement.Attribute(UPnpNamespaces.ProtocolInfo);
- if (info != null && !string.IsNullOrWhiteSpace(info.Value))
+ if (info is not null && !string.IsNullOrWhiteSpace(info.Value))
{
return info.Value.Split(':');
}
@@ -974,7 +974,7 @@ namespace Emby.Dlna.PlayTo
private async Task<TransportCommands> GetAVProtocolAsync(CancellationToken cancellationToken)
{
- if (AvCommands != null)
+ if (AvCommands is not null)
{
return AvCommands;
}
@@ -985,7 +985,7 @@ namespace Emby.Dlna.PlayTo
}
var avService = GetAvTransportService();
- if (avService == null)
+ if (avService is null)
{
return null;
}
@@ -995,7 +995,7 @@ namespace Emby.Dlna.PlayTo
var httpClient = new DlnaHttpClient(_logger, _httpClientFactory);
var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false);
- if (document == null)
+ if (document is null)
{
return null;
}
@@ -1006,7 +1006,7 @@ namespace Emby.Dlna.PlayTo
private async Task<TransportCommands> GetRenderingProtocolAsync(CancellationToken cancellationToken)
{
- if (RendererCommands != null)
+ if (RendererCommands is not null)
{
return RendererCommands;
}
@@ -1017,17 +1017,14 @@ namespace Emby.Dlna.PlayTo
}
var avService = GetServiceRenderingControl();
- if (avService == null)
- {
- throw new ArgumentException("Device AvService is null");
- }
+ ArgumentNullException.ThrowIfNull(avService);
string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl);
var httpClient = new DlnaHttpClient(_logger, _httpClientFactory);
_logger.LogDebug("Dlna Device.GetRenderingProtocolAsync");
var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false);
- if (document == null)
+ if (document is null)
{
return null;
}
@@ -1062,7 +1059,7 @@ namespace Emby.Dlna.PlayTo
var ssdpHttpClient = new DlnaHttpClient(logger, httpClientFactory);
var document = await ssdpHttpClient.GetDataAsync(url.ToString(), cancellationToken).ConfigureAwait(false);
- if (document == null)
+ if (document is null)
{
return null;
}
@@ -1070,13 +1067,13 @@ namespace Emby.Dlna.PlayTo
var friendlyNames = new List<string>();
var name = document.Descendants(UPnpNamespaces.Ud.GetName("friendlyName")).FirstOrDefault();
- if (name != null && !string.IsNullOrWhiteSpace(name.Value))
+ if (name is not null && !string.IsNullOrWhiteSpace(name.Value))
{
friendlyNames.Add(name.Value);
}
var room = document.Descendants(UPnpNamespaces.Ud.GetName("roomName")).FirstOrDefault();
- if (room != null && !string.IsNullOrWhiteSpace(room.Value))
+ if (room is not null && !string.IsNullOrWhiteSpace(room.Value))
{
friendlyNames.Add(room.Value);
}
@@ -1088,74 +1085,74 @@ namespace Emby.Dlna.PlayTo
};
var model = document.Descendants(UPnpNamespaces.Ud.GetName("modelName")).FirstOrDefault();
- if (model != null)
+ if (model is not null)
{
deviceProperties.ModelName = model.Value;
}
var modelNumber = document.Descendants(UPnpNamespaces.Ud.GetName("modelNumber")).FirstOrDefault();
- if (modelNumber != null)
+ if (modelNumber is not null)
{
deviceProperties.ModelNumber = modelNumber.Value;
}
var uuid = document.Descendants(UPnpNamespaces.Ud.GetName("UDN")).FirstOrDefault();
- if (uuid != null)
+ if (uuid is not null)
{
deviceProperties.UUID = uuid.Value;
}
var manufacturer = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturer")).FirstOrDefault();
- if (manufacturer != null)
+ if (manufacturer is not null)
{
deviceProperties.Manufacturer = manufacturer.Value;
}
var manufacturerUrl = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturerURL")).FirstOrDefault();
- if (manufacturerUrl != null)
+ if (manufacturerUrl is not null)
{
deviceProperties.ManufacturerUrl = manufacturerUrl.Value;
}
var presentationUrl = document.Descendants(UPnpNamespaces.Ud.GetName("presentationURL")).FirstOrDefault();
- if (presentationUrl != null)
+ if (presentationUrl is not null)
{
deviceProperties.PresentationUrl = presentationUrl.Value;
}
var modelUrl = document.Descendants(UPnpNamespaces.Ud.GetName("modelURL")).FirstOrDefault();
- if (modelUrl != null)
+ if (modelUrl is not null)
{
deviceProperties.ModelUrl = modelUrl.Value;
}
var serialNumber = document.Descendants(UPnpNamespaces.Ud.GetName("serialNumber")).FirstOrDefault();
- if (serialNumber != null)
+ if (serialNumber is not null)
{
deviceProperties.SerialNumber = serialNumber.Value;
}
var modelDescription = document.Descendants(UPnpNamespaces.Ud.GetName("modelDescription")).FirstOrDefault();
- if (modelDescription != null)
+ if (modelDescription is not null)
{
deviceProperties.ModelDescription = modelDescription.Value;
}
var icon = document.Descendants(UPnpNamespaces.Ud.GetName("icon")).FirstOrDefault();
- if (icon != null)
+ if (icon is not null)
{
deviceProperties.Icon = CreateIcon(icon);
}
foreach (var services in document.Descendants(UPnpNamespaces.Ud.GetName("serviceList")))
{
- if (services == null)
+ if (services is null)
{
continue;
}
var servicesList = services.Descendants(UPnpNamespaces.Ud.GetName("service"));
- if (servicesList == null)
+ if (servicesList is null)
{
continue;
}
@@ -1164,7 +1161,7 @@ namespace Emby.Dlna.PlayTo
{
var service = Create(element);
- if (service != null)
+ if (service is not null)
{
deviceProperties.Services.Add(service);
}
@@ -1212,14 +1209,14 @@ namespace Emby.Dlna.PlayTo
var previousMediaInfo = CurrentMediaInfo;
CurrentMediaInfo = mediaInfo;
- if (mediaInfo == null)
+ if (mediaInfo is null)
{
- if (previousMediaInfo != null)
+ if (previousMediaInfo is not null)
{
OnPlaybackStop(previousMediaInfo);
}
}
- else if (previousMediaInfo == null)
+ else if (previousMediaInfo is null)
{
if (state != TransportState.STOPPED)
{
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs
index 65367e24f..4cda1d8b7 100644
--- a/Emby.Dlna/PlayTo/PlayToController.cs
+++ b/Emby.Dlna/PlayTo/PlayToController.cs
@@ -84,7 +84,7 @@ namespace Emby.Dlna.PlayTo
_mediaEncoder = mediaEncoder;
}
- public bool IsSessionActive => !_disposed && _device != null;
+ public bool IsSessionActive => !_disposed && _device is not null;
public bool SupportsMediaControl => IsSessionActive;
@@ -156,7 +156,7 @@ namespace Emby.Dlna.PlayTo
try
{
var streamInfo = StreamParams.ParseFromUrl(e.OldMediaInfo.Url, _libraryManager, _mediaSourceManager);
- if (streamInfo.Item != null)
+ if (streamInfo.Item is not null)
{
var positionTicks = GetProgressPositionTicks(streamInfo);
@@ -164,7 +164,7 @@ namespace Emby.Dlna.PlayTo
}
streamInfo = StreamParams.ParseFromUrl(e.NewMediaInfo.Url, _libraryManager, _mediaSourceManager);
- if (streamInfo.Item == null)
+ if (streamInfo.Item is null)
{
return;
}
@@ -199,7 +199,7 @@ namespace Emby.Dlna.PlayTo
{
var streamInfo = StreamParams.ParseFromUrl(e.MediaInfo.Url, _libraryManager, _mediaSourceManager);
- if (streamInfo.Item == null)
+ if (streamInfo.Item is null)
{
return;
}
@@ -210,7 +210,7 @@ namespace Emby.Dlna.PlayTo
var mediaSource = await streamInfo.GetMediaSource(CancellationToken.None).ConfigureAwait(false);
- var duration = mediaSource == null
+ var duration = mediaSource is null
? _device.Duration?.Ticks
: mediaSource.RunTimeTicks;
@@ -268,7 +268,7 @@ namespace Emby.Dlna.PlayTo
{
var info = StreamParams.ParseFromUrl(e.MediaInfo.Url, _libraryManager, _mediaSourceManager);
- if (info.Item != null)
+ if (info.Item is not null)
{
var progress = GetProgressInfo(info);
@@ -299,7 +299,7 @@ namespace Emby.Dlna.PlayTo
var info = StreamParams.ParseFromUrl(mediaUrl, _libraryManager, _mediaSourceManager);
- if (info.Item != null)
+ if (info.Item is not null)
{
var progress = GetProgressInfo(info);
@@ -441,11 +441,11 @@ namespace Emby.Dlna.PlayTo
{
var media = _device.CurrentMediaInfo;
- if (media != null)
+ if (media is not null)
{
var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager);
- if (info.Item != null && !EnableClientSideSeek(info))
+ if (info.Item is not null && !EnableClientSideSeek(info))
{
var user = _session.UserId.Equals(default)
? null
@@ -760,11 +760,11 @@ namespace Emby.Dlna.PlayTo
{
var media = _device.CurrentMediaInfo;
- if (media != null)
+ if (media is not null)
{
var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager);
- if (info.Item != null)
+ if (info.Item is not null)
{
var newPosition = GetProgressPositionTicks(info) ?? 0;
@@ -791,11 +791,11 @@ namespace Emby.Dlna.PlayTo
{
var media = _device.CurrentMediaInfo;
- if (media != null)
+ if (media is not null)
{
var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager);
- if (info.Item != null)
+ if (info.Item is not null)
{
var newPosition = GetProgressPositionTicks(info) ?? 0;
@@ -865,7 +865,7 @@ namespace Emby.Dlna.PlayTo
throw new ObjectDisposedException(GetType().Name);
}
- if (_device == null)
+ if (_device is null)
{
return Task.CompletedTask;
}
@@ -916,7 +916,7 @@ namespace Emby.Dlna.PlayTo
public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken)
{
- if (_mediaSource != null)
+ if (_mediaSource is not null)
{
return _mediaSource;
}
@@ -926,7 +926,7 @@ namespace Emby.Dlna.PlayTo
return null;
}
- if (_mediaSourceManager != null)
+ if (_mediaSourceManager is not null)
{
_mediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false);
}
@@ -936,10 +936,7 @@ namespace Emby.Dlna.PlayTo
private static Guid GetItemId(string url)
{
- if (string.IsNullOrEmpty(url))
- {
- throw new ArgumentNullException(nameof(url));
- }
+ ArgumentException.ThrowIfNullOrEmpty(url);
var parts = url.Split('/');
@@ -962,10 +959,7 @@ namespace Emby.Dlna.PlayTo
public static StreamParams ParseFromUrl(string url, ILibraryManager libraryManager, IMediaSourceManager mediaSourceManager)
{
- if (string.IsNullOrEmpty(url))
- {
- throw new ArgumentNullException(nameof(url));
- }
+ ArgumentException.ThrowIfNullOrEmpty(url);
var request = new StreamParams
{
diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs
index 294bda5b6..f4a9a90af 100644
--- a/Emby.Dlna/PlayTo/PlayToManager.cs
+++ b/Emby.Dlna/PlayTo/PlayToManager.cs
@@ -176,10 +176,10 @@ namespace Emby.Dlna.PlayTo
var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
- if (controller == null)
+ if (controller is null)
{
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClientFactory, _logger, cancellationToken).ConfigureAwait(false);
- if (device == null)
+ if (device is null)
{
_logger.LogError("Ignoring device as xml response is invalid.");
return;
diff --git a/Emby.Dlna/PlayTo/PlaylistItemFactory.cs b/Emby.Dlna/PlayTo/PlaylistItemFactory.cs
index 657491303..53cd05cfd 100644
--- a/Emby.Dlna/PlayTo/PlaylistItemFactory.cs
+++ b/Emby.Dlna/PlayTo/PlaylistItemFactory.cs
@@ -29,7 +29,7 @@ namespace Emby.Dlna.PlayTo
var directPlay = profile.DirectPlayProfiles
.FirstOrDefault(i => i.Type == DlnaProfileType.Photo && IsSupported(i, item));
- if (directPlay != null)
+ if (directPlay is not null)
{
playlistItem.StreamInfo.PlayMethod = PlayMethod.DirectStream;
playlistItem.StreamInfo.Container = Path.GetExtension(item.Path);
@@ -40,7 +40,7 @@ namespace Emby.Dlna.PlayTo
var transcodingProfile = profile.TranscodingProfiles
.FirstOrDefault(i => i.Type == DlnaProfileType.Photo);
- if (transcodingProfile != null)
+ if (transcodingProfile is not null)
{
playlistItem.StreamInfo.PlayMethod = PlayMethod.Transcode;
playlistItem.StreamInfo.Container = "." + transcodingProfile.Container.TrimStart('.');
diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.cs
index 9c3a9103b..c46372732 100644
--- a/Emby.Dlna/PlayTo/TransportCommands.cs
+++ b/Emby.Dlna/PlayTo/TransportCommands.cs
@@ -31,7 +31,7 @@ namespace Emby.Dlna.PlayTo
var stateValues = document.Descendants(UPnpNamespaces.ServiceStateTable).FirstOrDefault();
- if (stateValues != null)
+ if (stateValues is not null)
{
foreach (var container in stateValues.Elements(UPnpNamespaces.Svc + "stateVariable"))
{
@@ -77,7 +77,7 @@ namespace Emby.Dlna.PlayTo
var element = container.Descendants(UPnpNamespaces.Svc + "allowedValueList")
.FirstOrDefault();
- if (element != null)
+ if (element is not null)
{
var values = element.Descendants(UPnpNamespaces.Svc + "allowedValue");
@@ -167,7 +167,7 @@ namespace Emby.Dlna.PlayTo
{
var state = StateVariables.FirstOrDefault(a => string.Equals(a.Name, argument.RelatedStateVariable, StringComparison.OrdinalIgnoreCase));
- if (state != null)
+ if (state is not null)
{
var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ??
(state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value);
diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs
index 8adaaea77..d00df781d 100644
--- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs
+++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs
@@ -22,15 +22,8 @@ namespace Emby.Dlna.Server
public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId)
{
- if (string.IsNullOrEmpty(serverUdn))
- {
- throw new ArgumentNullException(nameof(serverUdn));
- }
-
- if (string.IsNullOrEmpty(serverAddress))
- {
- throw new ArgumentNullException(nameof(serverAddress));
- }
+ ArgumentException.ThrowIfNullOrEmpty(serverUdn);
+ ArgumentException.ThrowIfNullOrEmpty(serverAddress);
_profile = profile;
_serverUdn = serverUdn;
diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs
index 9c423b395..bff5307a4 100644
--- a/Emby.Dlna/Service/BaseControlHandler.cs
+++ b/Emby.Dlna/Service/BaseControlHandler.cs
@@ -173,7 +173,7 @@ namespace Emby.Dlna.Service
}
}
- if (localName != null && namespaceURI != null)
+ if (localName is not null && namespaceURI is not null)
{
return new ControlRequestInfo(localName, namespaceURI);
}
diff --git a/Emby.Dlna/Service/BaseService.cs b/Emby.Dlna/Service/BaseService.cs
index 68fd98758..67e7bf6a6 100644
--- a/Emby.Dlna/Service/BaseService.cs
+++ b/Emby.Dlna/Service/BaseService.cs
@@ -1,3 +1,4 @@
+#nullable disable
#pragma warning disable CS1591
using System.Net.Http;
diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.cs
index 391dda147..8a4e5ff45 100644
--- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs
+++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs
@@ -71,7 +71,7 @@ namespace Emby.Dlna.Ssdp
{
lock (_syncLock)
{
- if (_listenerCount > 0 && _deviceLocator == null && _commsServer != null)
+ if (_listenerCount > 0 && _deviceLocator is null && _commsServer is not null)
{
_deviceLocator = new SsdpDeviceLocator(_commsServer);
@@ -97,7 +97,7 @@ namespace Emby.Dlna.Ssdp
{
var originalHeaders = e.DiscoveredDevice.ResponseHeaders;
- var headerDict = originalHeaders == null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
+ var headerDict = originalHeaders is null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
@@ -116,7 +116,7 @@ namespace Emby.Dlna.Ssdp
{
var originalHeaders = e.DiscoveredDevice.ResponseHeaders;
- var headerDict = originalHeaders == null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
+ var headerDict = originalHeaders is null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
@@ -136,7 +136,7 @@ namespace Emby.Dlna.Ssdp
if (!_disposed)
{
_disposed = true;
- if (_deviceLocator != null)
+ if (_deviceLocator is not null)
{
_deviceLocator.Dispose();
_deviceLocator = null;
diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj
index 8f64b0b21..5bf226408 100644
--- a/Emby.Drawing/Emby.Drawing.csproj
+++ b/Emby.Drawing/Emby.Drawing.csproj
@@ -6,15 +6,11 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- </PropertyGroup>
-
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index 11256dafd..5a49e876a 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -436,7 +436,7 @@ namespace Emby.Drawing
/// <inheritdoc />
public string? GetImageCacheTag(User user)
{
- if (user.ProfileImage == null)
+ if (user.ProfileImage is null)
{
return null;
}
@@ -503,20 +503,9 @@ namespace Emby.Drawing
/// </exception>
public string GetCachePath(string path, string uniqueName, string fileExtension)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
-
- if (string.IsNullOrEmpty(uniqueName))
- {
- throw new ArgumentNullException(nameof(uniqueName));
- }
-
- if (string.IsNullOrEmpty(fileExtension))
- {
- throw new ArgumentNullException(nameof(fileExtension));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
+ ArgumentException.ThrowIfNullOrEmpty(uniqueName);
+ ArgumentException.ThrowIfNullOrEmpty(fileExtension);
var filename = uniqueName.GetMD5() + fileExtension;
diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs
index 6e491185d..bdae20b6b 100644
--- a/Emby.Naming/AudioBook/AudioBookListResolver.cs
+++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs
@@ -69,13 +69,13 @@ namespace Emby.Naming.AudioBook
extras = new List<AudioBookFileInfo>();
alternativeVersions = new List<AudioBookFileInfo>();
- var haveChaptersOrPages = stackFiles.Any(x => x.ChapterNumber != null || x.PartNumber != null);
+ var haveChaptersOrPages = stackFiles.Any(x => x.ChapterNumber is not null || x.PartNumber is not null);
var groupedBy = stackFiles.GroupBy(file => new { file.ChapterNumber, file.PartNumber });
var nameWithReplacedDots = nameParserResult.Name.Replace(' ', '.');
foreach (var group in groupedBy)
{
- if (group.Key.ChapterNumber == null && group.Key.PartNumber == null)
+ if (group.Key.ChapterNumber is null && group.Key.PartNumber is null)
{
if (group.Count() > 1 || haveChaptersOrPages)
{
diff --git a/Emby.Naming/AudioBook/AudioBookNameParser.cs b/Emby.Naming/AudioBook/AudioBookNameParser.cs
index 120482bc2..97b34199e 100644
--- a/Emby.Naming/AudioBook/AudioBookNameParser.cs
+++ b/Emby.Naming/AudioBook/AudioBookNameParser.cs
@@ -33,7 +33,7 @@ namespace Emby.Naming.AudioBook
var match = new Regex(expression, RegexOptions.IgnoreCase).Match(name);
if (match.Success)
{
- if (result.Name == null)
+ if (result.Name is null)
{
var value = match.Groups["name"];
if (value.Success)
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index ca002b981..80bc57a5d 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
@@ -16,7 +16,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Stability)'=='Unstable'">
diff --git a/Emby.Naming/ExternalFiles/ExternalPathParser.cs b/Emby.Naming/ExternalFiles/ExternalPathParser.cs
index 1fa4fa537..953129671 100644
--- a/Emby.Naming/ExternalFiles/ExternalPathParser.cs
+++ b/Emby.Naming/ExternalFiles/ExternalPathParser.cs
@@ -94,12 +94,12 @@ namespace Emby.Naming.ExternalFiles
// Try to translate to three character code
var culture = _localizationManager.FindLanguageInfo(currentSliceWithoutSeparator);
- if (culture != null && pathInfo.Language == null)
+ if (culture is not null && pathInfo.Language is null)
{
pathInfo.Language = culture.ThreeLetterISOLanguageName;
extraString = extraString.Replace(currentSlice, string.Empty, StringComparison.OrdinalIgnoreCase);
}
- else if (culture != null && pathInfo.Language == "hin")
+ else if (culture is not null && pathInfo.Language == "hin")
{
// Hindi language code "hi" collides with a hearing impaired flag - use as Hindi only if no other language is set
pathInfo.IsHearingImpaired = true;
diff --git a/Emby.Naming/TV/EpisodePathParser.cs b/Emby.Naming/TV/EpisodePathParser.cs
index 6d0597356..d706be280 100644
--- a/Emby.Naming/TV/EpisodePathParser.cs
+++ b/Emby.Naming/TV/EpisodePathParser.cs
@@ -76,7 +76,7 @@ namespace Emby.Naming.TV
}
}
- if (result != null && fillExtendedInfo)
+ if (result is not null && fillExtendedInfo)
{
FillAdditional(path, result);
diff --git a/Emby.Naming/TV/SeriesPathParser.cs b/Emby.Naming/TV/SeriesPathParser.cs
index 23067e6a4..94b4b5c82 100644
--- a/Emby.Naming/TV/SeriesPathParser.cs
+++ b/Emby.Naming/TV/SeriesPathParser.cs
@@ -28,7 +28,7 @@ namespace Emby.Naming.TV
}
}
- if (result != null)
+ if (result is not null)
{
if (!string.IsNullOrEmpty(result.SeriesName))
{
diff --git a/Emby.Naming/Video/ExtraRuleResolver.cs b/Emby.Naming/Video/ExtraRuleResolver.cs
index 0970e509a..21d0da364 100644
--- a/Emby.Naming/Video/ExtraRuleResolver.cs
+++ b/Emby.Naming/Video/ExtraRuleResolver.cs
@@ -76,7 +76,7 @@ namespace Emby.Naming.Video
}
}
- if (result.ExtraType != null)
+ if (result.ExtraType is not null)
{
return result;
}
diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs
index 11f82525f..804832040 100644
--- a/Emby.Naming/Video/VideoListResolver.cs
+++ b/Emby.Naming/Video/VideoListResolver.cs
@@ -26,7 +26,7 @@ namespace Emby.Naming.Video
// Filter out all extras, otherwise they could cause stacks to not be resolved
// See the unit test TestStackedWithTrailer
var nonExtras = videoInfos
- .Where(i => i.ExtraType == null)
+ .Where(i => i.ExtraType is null)
.Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });
var stackResult = StackResolver.Resolve(nonExtras, namingOptions).ToList();
@@ -42,7 +42,7 @@ namespace Emby.Naming.Video
continue;
}
- if (current.ExtraType == null)
+ if (current.ExtraType is null)
{
standaloneMedia.Add(current);
}
@@ -109,7 +109,7 @@ namespace Emby.Naming.Video
for (var i = 0; i < videos.Count; i++)
{
var video = videos[i];
- if (video.ExtraType != null)
+ if (video.ExtraType is not null)
{
continue;
}
diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs
index de8e177d8..858e9dd2f 100644
--- a/Emby.Naming/Video/VideoResolver.cs
+++ b/Emby.Naming/Video/VideoResolver.cs
@@ -87,7 +87,7 @@ namespace Emby.Naming.Video
name = cleanDateTimeResult.Name;
year = cleanDateTimeResult.Year;
- if (extraResult.ExtraType == null
+ if (extraResult.ExtraType is null
&& TryCleanString(name, namingOptions, out var newName))
{
name = newName;
diff --git a/Emby.Notifications/Emby.Notifications.csproj b/Emby.Notifications/Emby.Notifications.csproj
index b797a5194..138965c89 100644
--- a/Emby.Notifications/Emby.Notifications.csproj
+++ b/Emby.Notifications/Emby.Notifications.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/Emby.Notifications/NotificationEntryPoint.cs b/Emby.Notifications/NotificationEntryPoint.cs
index 668c059b4..3763b1e92 100644
--- a/Emby.Notifications/NotificationEntryPoint.cs
+++ b/Emby.Notifications/NotificationEntryPoint.cs
@@ -141,7 +141,7 @@ namespace Emby.Notifications
lock (_libraryChangedSyncLock)
{
- if (_libraryUpdateTimer == null)
+ if (_libraryUpdateTimer is null)
{
_libraryUpdateTimer = new Timer(
LibraryUpdateTimerCallback,
diff --git a/Emby.Notifications/NotificationManager.cs b/Emby.Notifications/NotificationManager.cs
index ac90cc8ec..a5a76b2af 100644
--- a/Emby.Notifications/NotificationManager.cs
+++ b/Emby.Notifications/NotificationManager.cs
@@ -68,7 +68,7 @@ namespace Emby.Notifications
var users = GetUserIds(request, options)
.Select(i => _userManager.GetUserById(i))
- .Where(i => relatedItem == null || relatedItem.IsVisibleStandalone(i))
+ .Where(i => relatedItem is null || relatedItem.IsVisibleStandalone(i))
.ToArray();
var title = request.Name;
@@ -113,7 +113,7 @@ namespace Emby.Notifications
}
}
- if (options != null && !string.IsNullOrEmpty(request.NotificationType))
+ if (options is not null && !string.IsNullOrEmpty(request.NotificationType))
{
var config = GetConfiguration();
diff --git a/Emby.Photos/Emby.Photos.csproj b/Emby.Photos/Emby.Photos.csproj
index e1688dc6e..34bc8f32f 100644
--- a/Emby.Photos/Emby.Photos.csproj
+++ b/Emby.Photos/Emby.Photos.csproj
@@ -19,7 +19,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs
index cef82b4d6..f54066c57 100644
--- a/Emby.Photos/PhotoProvider.cs
+++ b/Emby.Photos/PhotoProvider.cs
@@ -27,7 +27,7 @@ namespace Emby.Photos
private readonly IImageProcessor _imageProcessor;
// These are causing taglib to hang
- private readonly string[] _includeExtensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff", ".cr2" };
+ private readonly string[] _includeExtensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff", ".cr2", ".webp", ".avif" };
/// <summary>
/// Initializes a new instance of the <see cref="PhotoProvider" /> class.
@@ -49,7 +49,7 @@ namespace Emby.Photos
if (item.IsFileProtocol)
{
var file = directoryService.GetFile(item.Path);
- return file != null && file.LastWriteTimeUtc != item.DateModified;
+ return file is not null && file.LastWriteTimeUtc != item.DateModified;
}
return false;
@@ -70,20 +70,20 @@ namespace Emby.Photos
if (file.GetTag(TagTypes.TiffIFD) is IFDTag tag)
{
var structure = tag.Structure;
- if (structure != null
+ if (structure is not null
&& structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) is SubIFDEntry exif)
{
var exifStructure = exif.Structure;
- if (exifStructure != null)
+ if (exifStructure is not null)
{
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
- if (entry != null)
+ if (entry is not null)
{
item.Aperture = (double)entry.Value.Numerator / entry.Value.Denominator;
}
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
- if (entry != null)
+ if (entry is not null)
{
item.ShutterSpeed = (double)entry.Value.Numerator / entry.Value.Denominator;
}
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index 26b4649dd..985a127d5 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -131,7 +131,7 @@ namespace Emby.Server.Implementations.AppBase
{
_configuration = value;
- _configurationLoaded = value != null;
+ _configurationLoaded = value is not null;
}
}
@@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.AppBase
{
IConfigurationFactory factory = Activator.CreateInstance<T>();
- if (_configurationFactories == null)
+ if (_configurationFactories is null)
{
_configurationFactories = new[] { factory };
}
@@ -306,7 +306,7 @@ namespace Emby.Server.Implementations.AppBase
configurationManager._configurationStores,
i => string.Equals(i.Key, k, StringComparison.OrdinalIgnoreCase));
- if (configurationInfo == null)
+ if (configurationInfo is null)
{
throw new ResourceNotFoundException("Configuration with key " + k + " not found.");
}
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
index f923e59ef..1c8477605 100644
--- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
+++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
@@ -43,7 +43,7 @@ namespace Emby.Server.Implementations.AppBase
Span<byte> newBytes = stream.GetBuffer().AsSpan(0, (int)stream.Length);
// If the file didn't exist before, or if something has changed, re-save
- if (buffer == null || !newBytes.SequenceEqual(buffer))
+ if (buffer is null || !newBytes.SequenceEqual(buffer))
{
var directory = Path.GetDirectoryName(path) ?? throw new ArgumentException($"Provided path ({path}) is not valid.", nameof(path));
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index d4bf8a418..4733b39ab 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -196,7 +196,7 @@ namespace Emby.Server.Implementations
/// <summary>
/// Gets a value indicating whether this instance can self restart.
/// </summary>
- public bool CanSelfRestart => _startupOptions.RestartPath != null;
+ public bool CanSelfRestart => _startupOptions.RestartPath is not null;
public bool CoreStartupHasCompleted { get; private set; }
@@ -311,7 +311,7 @@ namespace Emby.Server.Implementations
public X509Certificate2 Certificate { get; private set; }
/// <inheritdoc/>
- public bool ListenWithHttps => Certificate != null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
+ public bool ListenWithHttps => Certificate is not null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
public string FriendlyName =>
string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName)
@@ -403,7 +403,7 @@ namespace Emby.Server.Implementations
// Convert to list so this isn't executed for each iteration
var parts = GetExportTypes<T>()
.Select(CreateInstanceSafe)
- .Where(i => i != null)
+ .Where(i => i is not null)
.Cast<T>()
.ToList();
@@ -424,7 +424,7 @@ namespace Emby.Server.Implementations
// Convert to list so this isn't executed for each iteration
var parts = GetExportTypes<T>()
.Select(i => defaultFunc(i))
- .Where(i => i != null)
+ .Where(i => i is not null)
.Cast<T>()
.ToList();
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs
index 6837cce5c..85ccbc028 100644
--- a/Emby.Server.Implementations/Channels/ChannelManager.cs
+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs
@@ -129,7 +129,7 @@ namespace Emby.Server.Implementations.Channels
public Task DeleteItem(BaseItem item)
{
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
- if (internalChannel == null)
+ if (internalChannel is null)
{
throw new ArgumentException(nameof(item.ChannelId));
}
@@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.Channels
.ToList();
}
- if (user != null)
+ if (user is not null)
{
channels = channels.Where(i =>
{
@@ -253,7 +253,7 @@ namespace Emby.Server.Implementations.Channels
if (query.StartIndex.HasValue || query.Limit.HasValue)
{
int startIndex = query.StartIndex ?? 0;
- int count = query.Limit == null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex);
+ int count = query.Limit is null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex);
all = all.GetRange(startIndex, count);
}
@@ -355,7 +355,7 @@ namespace Emby.Server.Implementations.Channels
{
var path = Path.Combine(item.GetInternalMetadataPath(), "channelmediasourceinfos.json");
- if (mediaSources == null || mediaSources.Count == 0)
+ if (mediaSources is null || mediaSources.Count == 0)
{
try
{
@@ -447,7 +447,7 @@ namespace Emby.Server.Implementations.Channels
var item = _libraryManager.GetItemById(id) as Channel;
- if (item == null)
+ if (item is null)
{
item = new Channel
{
@@ -601,10 +601,7 @@ namespace Emby.Server.Implementations.Channels
private Guid GetInternalChannelId(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel));
}
@@ -739,7 +736,7 @@ namespace Emby.Server.Implementations.Channels
query.GroupByPresentationUniqueKey = false;
// null if came from cache
- if (itemsResult != null)
+ if (itemsResult is not null)
{
var items = itemsResult.Items;
var itemsLen = items.Count;
@@ -761,7 +758,7 @@ namespace Emby.Server.Implementations.Channels
foreach (var deadId in deadIds)
{
var deadItem = _libraryManager.GetItemById(deadId);
- if (deadItem != null)
+ if (deadItem is not null)
{
_libraryManager.DeleteItem(
deadItem,
@@ -813,7 +810,7 @@ namespace Emby.Server.Implementations.Channels
{
await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (cachedResult != null)
+ if (cachedResult is not null)
{
return null;
}
@@ -836,7 +833,7 @@ namespace Emby.Server.Implementations.Channels
{
await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (cachedResult != null)
+ if (cachedResult is not null)
{
return null;
}
@@ -861,7 +858,7 @@ namespace Emby.Server.Implementations.Channels
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
- if (result == null)
+ if (result is null)
{
throw new InvalidOperationException("Channel returned a null result from GetChannelItems");
}
@@ -955,7 +952,7 @@ namespace Emby.Server.Implementations.Channels
_logger.LogError(ex, "Error retrieving channel item from database");
}
- if (item == null)
+ if (item is null)
{
item = new T();
isNew = true;
@@ -1156,7 +1153,7 @@ namespace Emby.Server.Implementations.Channels
{
_libraryManager.CreateItem(item, parentFolder);
- if (info.People != null && info.People.Count > 0)
+ if (info.People is not null && info.People.Count > 0)
{
_libraryManager.UpdatePeople(item, info.People);
}
@@ -1193,7 +1190,7 @@ namespace Emby.Server.Implementations.Channels
var result = GetAllChannels()
.FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(channel.ChannelId) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase));
- if (result == null)
+ if (result is null)
{
throw new ResourceNotFoundException("No channel provider found for channel " + channel.Name);
}
@@ -1206,7 +1203,7 @@ namespace Emby.Server.Implementations.Channels
var result = GetAllChannels()
.FirstOrDefault(i => internalChannelId.Equals(GetInternalChannelId(i.Name)));
- if (result == null)
+ if (result is null)
{
throw new ResourceNotFoundException("No channel provider found for channel id " + internalChannelId);
}
diff --git a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs
index ca8409402..c31bb4fb9 100644
--- a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs
+++ b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs
@@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.Collections
var episode = subItem as Episode;
var series = episode?.Series;
- if (series != null && series.HasImage(ImageType.Primary))
+ if (series is not null && series.HasImage(ImageType.Primary))
{
return series;
}
@@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Collections
var parent = subItem.GetOwner() ?? subItem.GetParent();
- if (parent != null && parent.HasImage(ImageType.Primary))
+ if (parent is not null && parent.HasImage(ImageType.Primary))
{
if (parent is MusicAlbum)
{
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Collections
return null;
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.GroupBy(x => x!.Id) // We removed the null values
.Select(x => x.First())
.ToList()!; // Again... the list doesn't contain any null values
diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs
index 187e0c9b3..b53c8ca51 100644
--- a/Emby.Server.Implementations/Collections/CollectionManager.cs
+++ b/Emby.Server.Implementations/Collections/CollectionManager.cs
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Collections
internal async Task<Folder?> EnsureLibraryFolder(string path, bool createIfNeeded)
{
var existingFolder = FindFolders(path).FirstOrDefault();
- if (existingFolder != null)
+ if (existingFolder is not null)
{
return existingFolder;
}
@@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.Collections
{
var folder = GetCollectionsFolder(false).GetAwaiter().GetResult();
- return folder == null
+ return folder is null
? Enumerable.Empty<BoxSet>()
: folder.GetChildren(user, true).OfType<BoxSet>();
}
@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Collections
var parentFolder = await GetCollectionsFolder(true).ConfigureAwait(false);
- if (parentFolder == null)
+ if (parentFolder is null)
{
throw new ArgumentException(nameof(parentFolder));
}
@@ -216,7 +216,7 @@ namespace Emby.Server.Implementations.Collections
{
var item = _libraryManager.GetItemById(id);
- if (item == null)
+ if (item is null)
{
throw new ArgumentException("No item exists with the supplied Id");
}
@@ -265,9 +265,9 @@ namespace Emby.Server.Implementations.Collections
{
var childItem = _libraryManager.GetItemById(guidId);
- var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value.Equals(guidId)) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase)));
+ var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value.Equals(guidId)) || (childItem is not null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase)));
- if (child == null)
+ if (child is null)
{
_logger.LogWarning("No collection title exists with the supplied Id");
continue;
@@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Collections
list.Add(child);
- if (childItem != null)
+ if (childItem is not null)
{
itemList.Add(childItem);
}
diff --git a/Emby.Server.Implementations/ConfigurationOptions.cs b/Emby.Server.Implementations/ConfigurationOptions.cs
index 01dc728c1..f0a4c8ffb 100644
--- a/Emby.Server.Implementations/ConfigurationOptions.cs
+++ b/Emby.Server.Implementations/ConfigurationOptions.cs
@@ -11,7 +11,7 @@ namespace Emby.Server.Implementations
/// <summary>
/// Gets a new copy of the default configuration options.
/// </summary>
- public static Dictionary<string, string> DefaultConfiguration => new Dictionary<string, string>
+ public static Dictionary<string, string?> DefaultConfiguration => new Dictionary<string, string?>
{
{ HostWebClientKey, bool.TrueString },
{ DefaultRedirectKey, "web/index.html" },
diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
index e9c005cea..5380c45d8 100644
--- a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
+++ b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
@@ -2,8 +2,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
-using System.Text;
-using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Cryptography;
using static MediaBrowser.Model.Cryptography.Constants;
@@ -14,25 +12,6 @@ namespace Emby.Server.Implementations.Cryptography
/// </summary>
public class CryptographyProvider : ICryptoProvider
{
- // TODO: remove when not needed for backwards compat
- private static readonly HashSet<string> _supportedHashMethods = new HashSet<string>()
- {
- "MD5",
- "System.Security.Cryptography.MD5",
- "SHA",
- "SHA1",
- "System.Security.Cryptography.SHA1",
- "SHA256",
- "SHA-256",
- "System.Security.Cryptography.SHA256",
- "SHA384",
- "SHA-384",
- "System.Security.Cryptography.SHA384",
- "SHA512",
- "SHA-512",
- "System.Security.Cryptography.SHA512"
- };
-
/// <inheritdoc />
public string DefaultHashMethod => "PBKDF2-SHA512";
@@ -80,22 +59,7 @@ namespace Emby.Server.Implementations.Cryptography
DefaultOutputLength));
}
- if (!_supportedHashMethods.Contains(hash.Id))
- {
- throw new CryptographicException($"Requested hash method is not supported: {hash.Id}");
- }
-
- using var h = HashAlgorithm.Create(hash.Id) ?? throw new ResourceNotFoundException($"Unknown hash method: {hash.Id}.");
- var bytes = Encoding.UTF8.GetBytes(password.ToArray());
- if (hash.Salt.Length == 0)
- {
- return hash.Hash.SequenceEqual(h.ComputeHash(bytes));
- }
-
- byte[] salted = new byte[bytes.Length + hash.Salt.Length];
- Array.Copy(bytes, salted, bytes.Length);
- hash.Salt.CopyTo(salted.AsSpan(bytes.Length));
- return hash.Hash.SequenceEqual(h.ComputeHash(salted));
+ throw new NotSupportedException($"Can't verify hash with id: {hash.Id}");
}
/// <inheritdoc />
diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
index 450688491..ff9aa4c2a 100644
--- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
+++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
@@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.Data
protected ManagedConnection GetConnection(bool readOnly = false)
{
WriteLock.Wait();
- if (WriteConnection != null)
+ if (WriteConnection is not null)
{
return new ManagedConnection(WriteConnection, WriteLock);
}
diff --git a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
index 3de9d6371..4516b89dc 100644
--- a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
+++ b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
@@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.Data
var item = _libraryManager.GetItemById(itemId);
- if (item != null)
+ if (item is not null)
{
_logger.LogInformation("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty);
diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs
index 736b8125d..4055b0ba1 100644
--- a/Emby.Server.Implementations/Data/SqliteExtensions.cs
+++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs
@@ -253,7 +253,7 @@ namespace Emby.Server.Implementations.Data
{
if (statement.BindParameters.TryGetValue(name, out IBindParameter bindParam))
{
- if (value == null)
+ if (value is null)
{
bindParam.BindNull();
}
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 4f0a15df1..fa9d7dea2 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -691,7 +691,7 @@ namespace Emby.Server.Implementations.Data
private string GetPathToSave(string path)
{
- if (path == null)
+ if (path is null)
{
return null;
}
@@ -890,7 +890,7 @@ namespace Emby.Server.Implementations.Data
saveItemStatement.TryBind("@UnratedType", item.GetBlockUnratedType().ToString());
- if (topParent == null)
+ if (topParent is null)
{
saveItemStatement.TryBindNull("@TopParentId");
}
@@ -1146,7 +1146,7 @@ namespace Emby.Server.Implementations.Data
{
var image = ItemImageInfoFromValueString(part);
- if (image != null)
+ if (image is not null)
{
result[position++] = image;
}
@@ -1414,7 +1414,7 @@ namespace Emby.Server.Implementations.Data
var type = _typeMapper.GetType(typeString);
- if (type == null)
+ if (type is null)
{
return null;
}
@@ -1433,7 +1433,7 @@ namespace Emby.Server.Implementations.Data
}
}
- if (item == null)
+ if (item is null)
{
try
{
@@ -1444,7 +1444,7 @@ namespace Emby.Server.Implementations.Data
}
}
- if (item == null)
+ if (item is null)
{
return null;
}
@@ -1825,7 +1825,7 @@ namespace Emby.Server.Implementations.Data
var hasSeries = item as IHasSeries;
if (hasSeriesFields)
{
- if (hasSeries != null)
+ if (hasSeries is not null)
{
if (reader.TryGetGuid(index, out var seriesId))
{
@@ -1938,7 +1938,7 @@ namespace Emby.Server.Implementations.Data
if (HasField(query, ItemFields.SeriesPresentationUniqueKey))
{
- if (hasSeries != null)
+ if (hasSeries is not null)
{
if (reader.TryGetString(index, out var seriesPresentationUniqueKey))
{
@@ -2151,7 +2151,7 @@ namespace Emby.Server.Implementations.Data
private static bool EnableJoinUserData(InternalItemsQuery query)
{
- if (query.User == null)
+ if (query.User is null)
{
return false;
}
@@ -2205,7 +2205,7 @@ namespace Emby.Server.Implementations.Data
private bool HasProgramAttributes(InternalItemsQuery query)
{
- if (query.ParentType != null && _programExcludeParentTypes.Contains(query.ParentType.Value))
+ if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
{
return false;
}
@@ -2220,7 +2220,7 @@ namespace Emby.Server.Implementations.Data
private bool HasServiceName(InternalItemsQuery query)
{
- if (query.ParentType != null && _programExcludeParentTypes.Contains(query.ParentType.Value))
+ if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
{
return false;
}
@@ -2235,7 +2235,7 @@ namespace Emby.Server.Implementations.Data
private bool HasStartDate(InternalItemsQuery query)
{
- if (query.ParentType != null && _programExcludeParentTypes.Contains(query.ParentType.Value))
+ if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
{
return false;
}
@@ -2270,7 +2270,7 @@ namespace Emby.Server.Implementations.Data
private bool HasArtistFields(InternalItemsQuery query)
{
- if (query.ParentType != null && _artistExcludeParentTypes.Contains(query.ParentType.Value))
+ if (query.ParentType is not null && _artistExcludeParentTypes.Contains(query.ParentType.Value))
{
return false;
}
@@ -2392,7 +2392,7 @@ namespace Emby.Server.Implementations.Data
columns.Add("UserDatas.rating");
}
- if (query.SimilarTo != null)
+ if (query.SimilarTo is not null)
{
var item = query.SimilarTo;
@@ -2458,7 +2458,6 @@ namespace Emby.Server.Implementations.Data
builder.Append("((CleanName like @SearchTermStartsWith or (OriginalTitle not null and OriginalTitle like @SearchTermStartsWith)) * 10)");
builder.Append("+ ((CleanName = @SearchTermStartsWith COLLATE NOCASE or (OriginalTitle not null and OriginalTitle = @SearchTermStartsWith COLLATE NOCASE)) * 10)");
-
if (query.SearchTerm.Length > 1)
{
builder.Append("+ ((CleanName like @SearchTermContains or (OriginalTitle not null and OriginalTitle like @SearchTermContains)) * 10)");
@@ -2498,7 +2497,7 @@ namespace Emby.Server.Implementations.Data
{
var item = query.SimilarTo;
- if (item == null)
+ if (item is null)
{
return;
}
@@ -2682,7 +2681,7 @@ namespace Emby.Server.Implementations.Data
foreach (var row in statement.ExecuteQuery())
{
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
- if (item != null)
+ if (item is not null)
{
items.Add(item);
}
@@ -2924,7 +2923,7 @@ namespace Emby.Server.Implementations.Data
foreach (var row in statement.ExecuteQuery())
{
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
- if (item != null)
+ if (item is not null)
{
list.Add(item);
}
@@ -2967,7 +2966,7 @@ namespace Emby.Server.Implementations.Data
private string GetOrderByText(InternalItemsQuery query)
{
var orderBy = query.OrderBy;
- bool hasSimilar = query.SimilarTo != null;
+ bool hasSimilar = query.SimilarTo is not null;
bool hasSearch = !string.IsNullOrEmpty(query.SearchTerm);
if (hasSimilar || hasSearch)
@@ -3397,7 +3396,7 @@ namespace Emby.Server.Implementations.Data
}
}
- if (query.SimilarTo != null && query.MinSimilarityScore > 0)
+ if (query.SimilarTo is not null && query.MinSimilarityScore > 0)
{
whereClauses.Add("SimilarityScore > " + (query.MinSimilarityScore - 1).ToString(CultureInfo.InvariantCulture));
}
@@ -3684,7 +3683,7 @@ namespace Emby.Server.Implementations.Data
.Append(paramName)
.Append("))) OR ");
- if (statement != null)
+ if (statement is not null)
{
query.PersonIds[i].TryWriteBytes(idBytes);
statement.TryBind(paramName, idBytes);
@@ -3735,7 +3734,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(nameContains))
{
whereClauses.Add("(CleanName like @NameContains or OriginalTitle like @NameContains)");
- if (statement != null)
+ if (statement is not null)
{
nameContains = FixUnicodeChars(nameContains);
@@ -3866,7 +3865,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ArtistIds" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, artistId);
}
@@ -3887,7 +3886,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ArtistIds" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=1))");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, artistId);
}
@@ -3908,7 +3907,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ArtistIds" + index;
clauses.Add("((select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=" + paramName + ") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1))");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, artistId);
}
@@ -3929,7 +3928,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@AlbumIds" + index;
clauses.Add("Album in (select Name from typedbaseitems where guid=" + paramName + ")");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, albumId);
}
@@ -3950,7 +3949,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ExcludeArtistId" + index;
clauses.Add("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, artistId);
}
@@ -3971,7 +3970,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@GenreId" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=2))");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, genreId);
}
@@ -3990,7 +3989,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in query.Genres)
{
clauses.Add("@Genre" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=2)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@Genre" + index, GetCleanValue(item));
}
@@ -4009,7 +4008,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in tags)
{
clauses.Add("@Tag" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@Tag" + index, GetCleanValue(item));
}
@@ -4028,7 +4027,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in excludeTags)
{
clauses.Add("@ExcludeTag" + index + " not in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@ExcludeTag" + index, GetCleanValue(item));
}
@@ -4050,7 +4049,7 @@ namespace Emby.Server.Implementations.Data
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=3))");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, studioId);
}
@@ -4069,7 +4068,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in query.OfficialRatings)
{
clauses.Add("OfficialRating=@OfficialRating" + index);
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@OfficialRating" + index, item);
}
@@ -4084,7 +4083,7 @@ namespace Emby.Server.Implementations.Data
if (query.MinParentalRating.HasValue)
{
whereClauses.Add("InheritedParentalRatingValue>=@MinParentalRating");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@MinParentalRating", query.MinParentalRating.Value);
}
@@ -4093,7 +4092,7 @@ namespace Emby.Server.Implementations.Data
if (query.MaxParentalRating.HasValue)
{
whereClauses.Add("InheritedParentalRatingValue<=@MaxParentalRating");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
@@ -4150,7 +4149,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoAudioTrackWithLanguage))
{
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Audio' and MediaStreams.Language=@HasNoAudioTrackWithLanguage limit 1) is null)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@HasNoAudioTrackWithLanguage", query.HasNoAudioTrackWithLanguage);
}
@@ -4159,7 +4158,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoInternalSubtitleTrackWithLanguage))
{
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=0 and MediaStreams.Language=@HasNoInternalSubtitleTrackWithLanguage limit 1) is null)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@HasNoInternalSubtitleTrackWithLanguage", query.HasNoInternalSubtitleTrackWithLanguage);
}
@@ -4168,7 +4167,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoExternalSubtitleTrackWithLanguage))
{
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=1 and MediaStreams.Language=@HasNoExternalSubtitleTrackWithLanguage limit 1) is null)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@HasNoExternalSubtitleTrackWithLanguage", query.HasNoExternalSubtitleTrackWithLanguage);
}
@@ -4177,7 +4176,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoSubtitleTrackWithLanguage))
{
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.Language=@HasNoSubtitleTrackWithLanguage limit 1) is null)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@HasNoSubtitleTrackWithLanguage", query.HasNoSubtitleTrackWithLanguage);
}
@@ -4230,7 +4229,7 @@ namespace Emby.Server.Implementations.Data
if (query.Years.Length == 1)
{
whereClauses.Add("ProductionYear=@Years");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@Years", query.Years[0].ToString(CultureInfo.InvariantCulture));
}
@@ -4246,7 +4245,7 @@ namespace Emby.Server.Implementations.Data
if (isVirtualItem.HasValue)
{
whereClauses.Add("IsVirtualItem=@IsVirtualItem");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@IsVirtualItem", isVirtualItem.Value);
}
@@ -4280,7 +4279,7 @@ namespace Emby.Server.Implementations.Data
if (queryMediaTypes.Length == 1)
{
whereClauses.Add("MediaType=@MediaTypes");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@MediaTypes", queryMediaTypes[0]);
}
@@ -4300,7 +4299,7 @@ namespace Emby.Server.Implementations.Data
foreach (var id in query.ItemIds)
{
includeIds.Add("Guid = @IncludeId" + index);
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@IncludeId" + index, id);
}
@@ -4319,7 +4318,7 @@ namespace Emby.Server.Implementations.Data
foreach (var id in query.ExcludeItemIds)
{
excludeIds.Add("Guid <> @ExcludeId" + index);
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@ExcludeId" + index, id);
}
@@ -4330,7 +4329,7 @@ namespace Emby.Server.Implementations.Data
whereClauses.Add(string.Join(" AND ", excludeIds));
}
- if (query.ExcludeProviderIds != null && query.ExcludeProviderIds.Count > 0)
+ if (query.ExcludeProviderIds is not null && query.ExcludeProviderIds.Count > 0)
{
var excludeIds = new List<string>();
@@ -4344,7 +4343,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ExcludeProviderId" + index;
excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
}
@@ -4360,7 +4359,7 @@ namespace Emby.Server.Implementations.Data
}
}
- if (query.HasAnyProviderId != null && query.HasAnyProviderId.Count > 0)
+ if (query.HasAnyProviderId is not null && query.HasAnyProviderId.Count > 0)
{
var hasProviderIds = new List<string>();
@@ -4387,7 +4386,7 @@ namespace Emby.Server.Implementations.Data
hasProviderIds.Add("ProviderIds like " + paramName);
// this replaces the placeholder with a value, here: %key=val%
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
}
@@ -4469,7 +4468,7 @@ namespace Emby.Server.Implementations.Data
{
whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@AncestorId", query.AncestorIds[0]);
}
@@ -4485,7 +4484,7 @@ namespace Emby.Server.Implementations.Data
{
var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey";
whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey);
}
@@ -4495,7 +4494,7 @@ namespace Emby.Server.Implementations.Data
{
whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey);
}
@@ -4504,7 +4503,7 @@ namespace Emby.Server.Implementations.Data
if (query.BlockUnratedItems.Length == 1)
{
whereClauses.Add("(InheritedParentalRatingValue > 0 or UnratedType <> @UnratedType)");
- if (statement != null)
+ if (statement is not null)
{
statement.TryBind("@UnratedType", query.BlockUnratedItems[0].ToString());
}
@@ -4523,7 +4522,7 @@ namespace Emby.Server.Implementations.Data
if (query.ExcludeInheritedTags.Length > 0)
{
var paramName = "@ExcludeInheritedTags";
- if (statement == null)
+ if (statement is null)
{
int index = 0;
string excludedTags = string.Join(',', query.ExcludeInheritedTags.Select(_ => paramName + index++));
@@ -4733,7 +4732,7 @@ namespace Emby.Server.Implementations.Data
return false;
}
- if (query.User == null)
+ if (query.User is null)
{
return false;
}
@@ -4917,7 +4916,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
var whereClauses = new List<string>();
- if (query.User != null && query.IsFavorite.HasValue)
+ if (query.User is not null && query.IsFavorite.HasValue)
{
whereClauses.Add(@"p.Name IN (
SELECT Name FROM TypedBaseItems WHERE UserDataKey IN (
@@ -5294,7 +5293,7 @@ AND Type = @InternalPersonType)");
.Append(" group by PresentationUniqueKey");
if (query.OrderBy.Count != 0
- || query.SimilarTo != null
+ || query.SimilarTo is not null
|| !string.IsNullOrEmpty(query.SearchTerm))
{
stringBuilder.Append(GetOrderByText(query));
@@ -5362,7 +5361,7 @@ AND Type = @InternalPersonType)");
statement.TryBind("@UserId", query.User.InternalId);
}
- if (typeSubQuery != null)
+ if (typeSubQuery is not null)
{
GetWhereClauses(typeSubQuery, null);
}
@@ -5383,7 +5382,7 @@ AND Type = @InternalPersonType)");
foreach (var row in statement.ExecuteQuery())
{
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
- if (item != null)
+ if (item is not null)
{
var countStartColumn = columns.Count - 1;
@@ -5403,7 +5402,7 @@ AND Type = @InternalPersonType)");
statement.TryBind("@UserId", query.User.InternalId);
}
- if (typeSubQuery != null)
+ if (typeSubQuery is not null)
{
GetWhereClauses(typeSubQuery, null);
}
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
index 8d78d644d..5f2c3c9dc 100644
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
@@ -140,10 +140,7 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException(nameof(userId));
}
- if (string.IsNullOrEmpty(key))
- {
- throw new ArgumentNullException(nameof(key));
- }
+ ArgumentException.ThrowIfNullOrEmpty(key);
PersistUserData(userId, key, userData, cancellationToken);
}
@@ -274,10 +271,7 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException(nameof(userId));
}
- if (string.IsNullOrEmpty(key))
- {
- throw new ArgumentNullException(nameof(key));
- }
+ ArgumentException.ThrowIfNullOrEmpty(key);
using (var connection = GetConnection(true))
{
diff --git a/Emby.Server.Implementations/Data/TypeMapper.cs b/Emby.Server.Implementations/Data/TypeMapper.cs
index 064664e1f..9efcea842 100644
--- a/Emby.Server.Implementations/Data/TypeMapper.cs
+++ b/Emby.Server.Implementations/Data/TypeMapper.cs
@@ -23,14 +23,11 @@ namespace Emby.Server.Implementations.Data
/// <exception cref="ArgumentNullException"><c>typeName</c> is null.</exception>
public Type? GetType(string typeName)
{
- if (string.IsNullOrEmpty(typeName))
- {
- throw new ArgumentNullException(nameof(typeName));
- }
+ ArgumentException.ThrowIfNullOrEmpty(typeName);
return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(k))
- .FirstOrDefault(t => t != null));
+ .FirstOrDefault(t => t is not null));
}
}
}
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index f6d37421a..0c6c31982 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -213,7 +213,7 @@ namespace Emby.Server.Implementations.Dto
dto.DisplayPreferencesId = item.DisplayPreferencesId.ToString("N", CultureInfo.InvariantCulture);
}
- if (user != null)
+ if (user is not null)
{
AttachUserSpecificInfo(dto, item, user, options);
}
@@ -235,14 +235,14 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.CanDelete))
{
- dto.CanDelete = user == null
+ dto.CanDelete = user is null
? item.CanDelete()
: item.CanDelete(user);
}
if (options.ContainsField(ItemFields.CanDownload))
{
- dto.CanDownload = user == null
+ dto.CanDownload = user is null
? item.CanDownload()
: item.CanDownload(user);
}
@@ -254,7 +254,7 @@ namespace Emby.Server.Implementations.Dto
var liveTvManager = LivetvManager;
var activeRecording = liveTvManager.GetActiveRecordingInfo(item.Path);
- if (activeRecording != null)
+ if (activeRecording is not null)
{
dto.Type = BaseItemKind.Recording;
dto.CanDownload = false;
@@ -317,7 +317,7 @@ namespace Emby.Server.Implementations.Dto
{
var dto = GetBaseItemDtoInternal(item, options, user);
- if (taggedItems != null && options.ContainsField(ItemFields.ItemCounts))
+ if (taggedItems is not null && options.ContainsField(ItemFields.ItemCounts))
{
SetItemByNameInfo(item, dto, taggedItems);
}
@@ -417,7 +417,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.BasicSyncInfo))
{
- var userCanSync = user != null && user.HasPermission(PermissionKind.EnableContentDownloading);
+ var userCanSync = user is not null && user.HasPermission(PermissionKind.EnableContentDownloading);
if (userCanSync && item.SupportsExternalTransfer)
{
dto.SupportsSync = true;
@@ -460,7 +460,7 @@ namespace Emby.Server.Implementations.Dto
var album = item.AlbumEntity;
- if (album != null)
+ if (album is not null)
{
dto.Album = album.Name;
dto.AlbumId = album.Id;
@@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.Dto
{
return images
.Select(p => GetImageCacheTag(item, p))
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToArray();
}
@@ -570,8 +570,8 @@ namespace Emby.Server.Implementations.Dto
_logger.LogError(ex, "Error getting person {Name}", c);
return null;
}
- }).Where(i => i != null)
- .Where(i => user == null ?
+ }).Where(i => i is not null)
+ .Where(i => user is null ?
true :
i.IsVisible(user))
.GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
@@ -593,13 +593,13 @@ namespace Emby.Server.Implementations.Dto
{
baseItemPerson.PrimaryImageTag = GetTagAndFillBlurhash(dto, entity, ImageType.Primary);
baseItemPerson.Id = entity.Id;
- if (dto.ImageBlurHashes != null)
+ if (dto.ImageBlurHashes is not null)
{
// Only add BlurHash for the person's image.
baseItemPerson.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
foreach (var (imageType, blurHash) in dto.ImageBlurHashes)
{
- if (blurHash != null)
+ if (blurHash is not null)
{
baseItemPerson.ImageBlurHashes[imageType] = new Dictionary<string, string>();
foreach (var (imageId, blurHashValue) in blurHash)
@@ -662,7 +662,7 @@ namespace Emby.Server.Implementations.Dto
private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ImageType imageType, int imageIndex = 0)
{
var image = item.GetImageInfo(imageType, imageIndex);
- if (image != null)
+ if (image is not null)
{
return GetTagAndFillBlurhash(dto, item, image);
}
@@ -782,7 +782,7 @@ namespace Emby.Server.Implementations.Dto
{
var tag = GetTagAndFillBlurhash(dto, item, image);
- if (tag != null)
+ if (tag is not null)
{
dto.ImageTags[image.Type] = tag;
}
@@ -917,7 +917,7 @@ namespace Emby.Server.Implementations.Dto
var albumParent = audio.AlbumEntity;
- if (albumParent != null)
+ if (albumParent is not null)
{
dto.AlbumId = albumParent.Id;
dto.AlbumPrimaryImageTag = GetTagAndFillBlurhash(dto, albumParent, ImageType.Primary);
@@ -967,7 +967,7 @@ namespace Emby.Server.Implementations.Dto
{
EnableImages = false
});
- if (artist != null)
+ if (artist is not null)
{
return new NameGuidPair
{
@@ -977,7 +977,7 @@ namespace Emby.Server.Implementations.Dto
}
return null;
- }).Where(i => i != null).ToArray();
+ }).Where(i => i is not null).ToArray();
}
if (item is IHasAlbumArtist hasAlbumArtist)
@@ -1016,7 +1016,7 @@ namespace Emby.Server.Implementations.Dto
{
EnableImages = false
});
- if (artist != null)
+ if (artist is not null)
{
return new NameGuidPair
{
@@ -1026,7 +1026,7 @@ namespace Emby.Server.Implementations.Dto
}
return null;
- }).Where(i => i != null).ToArray();
+ }).Where(i => i is not null).ToArray();
}
// Add video info
@@ -1073,7 +1073,7 @@ namespace Emby.Server.Implementations.Dto
{
MediaStream[] mediaStreams;
- if (dto.MediaSources != null && dto.MediaSources.Length > 0)
+ if (dto.MediaSources is not null && dto.MediaSources.Length > 0)
{
if (item.SourceType == SourceType.Channel)
{
@@ -1140,10 +1140,10 @@ namespace Emby.Server.Implementations.Dto
// if (options.ContainsField(ItemFields.SeriesPrimaryImage))
{
episodeSeries ??= episode.Series;
- if (episodeSeries != null)
+ if (episodeSeries is not null)
{
dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, episodeSeries, ImageType.Primary);
- if (dto.ImageTags == null || !dto.ImageTags.ContainsKey(ImageType.Primary))
+ if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary))
{
AttachPrimaryImageAspectRatio(dto, episodeSeries);
}
@@ -1153,7 +1153,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.SeriesStudio))
{
episodeSeries ??= episode.Series;
- if (episodeSeries != null)
+ if (episodeSeries is not null)
{
dto.SeriesStudio = episodeSeries.Studios.FirstOrDefault();
}
@@ -1179,7 +1179,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.SeriesStudio))
{
series ??= season.Series;
- if (series != null)
+ if (series is not null)
{
dto.SeriesStudio = series.Studios.FirstOrDefault();
}
@@ -1190,10 +1190,10 @@ namespace Emby.Server.Implementations.Dto
// if (options.ContainsField(ItemFields.SeriesPrimaryImage))
{
series ??= season.Series;
- if (series != null)
+ if (series is not null)
{
dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, series, ImageType.Primary);
- if (dto.ImageTags == null || !dto.ImageTags.ContainsKey(ImageType.Primary))
+ if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary))
{
AttachPrimaryImageAspectRatio(dto, series);
}
@@ -1256,7 +1256,7 @@ namespace Emby.Server.Implementations.Dto
if (item.SourceType == SourceType.Channel)
{
var channel = _libraryManager.GetItemById(item.ChannelId);
- if (channel != null)
+ if (channel is not null)
{
dto.ChannelName = channel.Name;
}
@@ -1268,7 +1268,7 @@ namespace Emby.Server.Implementations.Dto
if (currentItem is MusicAlbum musicAlbum)
{
var artist = musicAlbum.GetMusicArtist(new DtoOptions(false));
- if (artist != null)
+ if (artist is not null)
{
return artist;
}
@@ -1276,7 +1276,7 @@ namespace Emby.Server.Implementations.Dto
var parent = currentItem.DisplayParent ?? currentItem.GetOwner() ?? currentItem.GetParent();
- if (parent == null && originalItem is not UserRootFolder && originalItem is not UserView && originalItem is not AggregateFolder && originalItem is not ICollectionFolder && originalItem is not Channel)
+ if (parent is null && originalItem is not UserRootFolder && originalItem is not UserView && originalItem is not AggregateFolder && originalItem is not ICollectionFolder && originalItem is not Channel)
{
parent = _libraryManager.GetCollectionFolders(originalItem).FirstOrDefault();
}
@@ -1309,53 +1309,53 @@ namespace Emby.Server.Implementations.Dto
var imageTags = dto.ImageTags;
- while ((!(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && logoLimit > 0)
- || (!(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && artLimit > 0)
- || (!(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0)
+ while ((!(imageTags is not null && imageTags.ContainsKey(ImageType.Logo)) && logoLimit > 0)
+ || (!(imageTags is not null && imageTags.ContainsKey(ImageType.Art)) && artLimit > 0)
+ || (!(imageTags is not null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0)
|| parent is Series)
{
parent ??= isFirst ? GetImageDisplayParent(item, item) ?? owner : parent;
- if (parent == null)
+ if (parent is null)
{
break;
}
var allImages = parent.ImageInfos;
- if (logoLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId is null)
+ if (logoLimit > 0 && !(imageTags is not null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId is null)
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Logo);
- if (image != null)
+ if (image is not null)
{
dto.ParentLogoItemId = parent.Id;
dto.ParentLogoImageTag = GetTagAndFillBlurhash(dto, parent, image);
}
}
- if (artLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId is null)
+ if (artLimit > 0 && !(imageTags is not null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId is null)
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Art);
- if (image != null)
+ if (image is not null)
{
dto.ParentArtItemId = parent.Id;
dto.ParentArtImageTag = GetTagAndFillBlurhash(dto, parent, image);
}
}
- if (thumbLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId is null || parent is Series) && parent is not ICollectionFolder && parent is not UserView)
+ if (thumbLimit > 0 && !(imageTags is not null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId is null || parent is Series) && parent is not ICollectionFolder && parent is not UserView)
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Thumb);
- if (image != null)
+ if (image is not null)
{
dto.ParentThumbItemId = parent.Id;
dto.ParentThumbImageTag = GetTagAndFillBlurhash(dto, parent, image);
}
}
- if (backdropLimit > 0 && !((dto.BackdropImageTags != null && dto.BackdropImageTags.Length > 0) || (dto.ParentBackdropImageTags != null && dto.ParentBackdropImageTags.Length > 0)))
+ if (backdropLimit > 0 && !((dto.BackdropImageTags is not null && dto.BackdropImageTags.Length > 0) || (dto.ParentBackdropImageTags is not null && dto.ParentBackdropImageTags.Length > 0)))
{
var images = allImages.Where(i => i.Type == ImageType.Backdrop).Take(backdropLimit).ToList();
@@ -1403,7 +1403,7 @@ namespace Emby.Server.Implementations.Dto
{
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return null;
}
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index eeaa3346d..e3d430c69 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -25,11 +25,11 @@
<ItemGroup>
<PackageReference Include="DiscUtils.Udf" Version="0.16.13" />
<PackageReference Include="Jellyfin.XmlTv" Version="10.8.0" />
- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
- <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
- <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.11" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
<PackageReference Include="Mono.Nat" Version="3.0.4" />
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.0" />
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="3.1.0" />
@@ -41,7 +41,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->
@@ -49,7 +49,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<!-- Code Analyzers-->
diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
index d5e4a636e..25a7029c9 100644
--- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
@@ -191,7 +191,7 @@ namespace Emby.Server.Implementations.EntryPoints
lock (_libraryChangedSyncLock)
{
- if (LibraryUpdateTimer == null)
+ if (LibraryUpdateTimer is null)
{
LibraryUpdateTimer = new Timer(
LibraryUpdateTimerCallback,
@@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.EntryPoints
lock (_libraryChangedSyncLock)
{
- if (LibraryUpdateTimer == null)
+ if (LibraryUpdateTimer is null)
{
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, Timeout.Infinite);
}
@@ -254,7 +254,7 @@ namespace Emby.Server.Implementations.EntryPoints
lock (_libraryChangedSyncLock)
{
- if (LibraryUpdateTimer == null)
+ if (LibraryUpdateTimer is null)
{
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, Timeout.Infinite);
}
@@ -299,7 +299,7 @@ namespace Emby.Server.Implementations.EntryPoints
SendChangeNotifications(_itemsAdded.ToList(), itemsUpdated, _itemsRemoved.ToList(), foldersAddedTo, foldersRemovedFrom, CancellationToken.None).GetAwaiter().GetResult();
- if (LibraryUpdateTimer != null)
+ if (LibraryUpdateTimer is not null)
{
LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null;
@@ -475,7 +475,7 @@ namespace Emby.Server.Implementations.EntryPoints
{
if (dispose)
{
- if (LibraryUpdateTimer != null)
+ if (LibraryUpdateTimer is not null)
{
LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null;
diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
index 82c8d3ab6..42c8f24a1 100644
--- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.EntryPoints
lock (_syncLock)
{
- if (_updateTimer == null)
+ if (_updateTimer is null)
{
_updateTimer = new Timer(
UpdateTimerCallback,
@@ -75,11 +75,11 @@ namespace Emby.Server.Implementations.EntryPoints
var baseItem = e.Item;
// Go up one level for indicators
- if (baseItem != null)
+ if (baseItem is not null)
{
var parent = baseItem.GetOwner() ?? baseItem.GetParent();
- if (parent != null)
+ if (parent is not null)
{
keys.Add(parent);
}
@@ -97,7 +97,7 @@ namespace Emby.Server.Implementations.EntryPoints
SendNotifications(changes, CancellationToken.None).GetAwaiter().GetResult();
- if (_updateTimer != null)
+ if (_updateTimer is not null)
{
_updateTimer.Dispose();
_updateTimer = null;
@@ -145,7 +145,7 @@ namespace Emby.Server.Implementations.EntryPoints
public void Dispose()
{
- if (_updateTimer != null)
+ if (_updateTimer is not null)
{
_updateTimer.Dispose();
_updateTimer = null;
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
index d095248fa..b1a99853a 100644
--- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
+++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
@@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.HttpServer
ReadResult result = await reader.ReadAsync().ConfigureAwait(false);
ReadOnlySequence<byte> buffer = result.Buffer;
- if (OnReceive == null)
+ if (OnReceive is null)
{
// Tell the PipeReader how much of the buffer we have consumed
reader.AdvanceTo(buffer.End);
@@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.HttpServer
return;
}
- if (stub == null)
+ if (stub is null)
{
_logger.LogError("Error processing web socket message");
return;
diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs
index 6326208f7..ec8590929 100644
--- a/Emby.Server.Implementations/IO/FileRefresher.cs
+++ b/Emby.Server.Implementations/IO/FileRefresher.cs
@@ -40,10 +40,7 @@ namespace Emby.Server.Implementations.IO
private void AddAffectedPath(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
if (!_affectedPaths.Contains(path, StringComparer.Ordinal))
{
@@ -53,10 +50,7 @@ namespace Emby.Server.Implementations.IO
public void AddPath(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
lock (_timerLock)
{
@@ -80,7 +74,7 @@ namespace Emby.Server.Implementations.IO
return;
}
- if (_timer == null)
+ if (_timer is null)
{
_timer = new Timer(OnTimerCallback, null, TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryMonitorDelay), TimeSpan.FromMilliseconds(-1));
}
@@ -138,7 +132,7 @@ namespace Emby.Server.Implementations.IO
IEnumerable<BaseItem> itemsToRefresh = paths
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(GetAffectedBaseItem)
- .Where(item => item != null)
+ .Where(item => item is not null)
.GroupBy(x => x!.Id) // Removed null values in the previous .Where()
.Select(x => x.First())!;
@@ -178,21 +172,21 @@ namespace Emby.Server.Implementations.IO
{
BaseItem? item = null;
- while (item == null && !string.IsNullOrEmpty(path))
+ while (item is null && !string.IsNullOrEmpty(path))
{
item = _libraryManager.FindByPath(path, null);
path = System.IO.Path.GetDirectoryName(path) ?? string.Empty;
}
- if (item != null)
+ if (item is not null)
{
// If the item has been deleted find the first valid parent that still exists
while (!Directory.Exists(item.Path) && !File.Exists(item.Path))
{
item = item.GetOwner() ?? item.GetParent();
- if (item == null)
+ if (item is null)
{
break;
}
@@ -206,7 +200,7 @@ namespace Emby.Server.Implementations.IO
{
lock (_timerLock)
{
- if (_timer != null)
+ if (_timer is not null)
{
_timer.Dispose();
_timer = null;
diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs
index c1422c43d..4b999d40b 100644
--- a/Emby.Server.Implementations/IO/LibraryMonitor.cs
+++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs
@@ -71,20 +71,14 @@ namespace Emby.Server.Implementations.IO
public void ReportFileSystemChangeBeginning(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
TemporarilyIgnore(path);
}
public async void ReportFileSystemChangeComplete(string path, bool refreshPath)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
// This is an arbitrary amount of time, but delay it because file system writes often trigger events long after the file was actually written to.
// Seeing long delays in some situations, especially over the network, sometimes up to 45 seconds
@@ -115,7 +109,7 @@ namespace Emby.Server.Implementations.IO
var options = _libraryManager.GetLibraryOptions(item);
- if (options != null)
+ if (options is not null)
{
return options.EnableRealtimeMonitor;
}
@@ -197,10 +191,7 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c>.</exception>
private static bool ContainsParentFolder(IEnumerable<string> lst, string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
path = path.TrimEnd(Path.DirectorySeparatorChar);
@@ -356,10 +347,7 @@ namespace Emby.Server.Implementations.IO
public void ReportFileSystemChanged(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
var monitorPath = !IgnorePatterns.ShouldIgnore(path);
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
index 120b1812a..55f384ae8 100644
--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
@@ -48,10 +48,7 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException"><paramref name="filename"/> is <c>null</c>.</exception>
public virtual bool IsShortcut(string filename)
{
- if (string.IsNullOrEmpty(filename))
- {
- throw new ArgumentNullException(nameof(filename));
- }
+ ArgumentException.ThrowIfNullOrEmpty(filename);
var extension = Path.GetExtension(filename);
return _shortcutHandlers.Any(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
@@ -65,10 +62,7 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException"><paramref name="filename"/> is <c>null</c>.</exception>
public virtual string? ResolveShortcut(string filename)
{
- if (string.IsNullOrEmpty(filename))
- {
- throw new ArgumentNullException(nameof(filename));
- }
+ ArgumentException.ThrowIfNullOrEmpty(filename);
var extension = Path.GetExtension(filename);
var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
@@ -136,20 +130,13 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException">The shortcutPath or target is null.</exception>
public virtual void CreateShortcut(string shortcutPath, string target)
{
- if (string.IsNullOrEmpty(shortcutPath))
- {
- throw new ArgumentNullException(nameof(shortcutPath));
- }
-
- if (string.IsNullOrEmpty(target))
- {
- throw new ArgumentNullException(nameof(target));
- }
+ ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
+ ArgumentException.ThrowIfNullOrEmpty(target);
var extension = Path.GetExtension(shortcutPath);
var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
- if (handler != null)
+ if (handler is not null)
{
handler.Create(shortcutPath, target);
}
@@ -488,15 +475,8 @@ namespace Emby.Server.Implementations.IO
/// <param name="file2">The file2.</param>
public virtual void SwapFiles(string file1, string file2)
{
- if (string.IsNullOrEmpty(file1))
- {
- throw new ArgumentNullException(nameof(file1));
- }
-
- if (string.IsNullOrEmpty(file2))
- {
- throw new ArgumentNullException(nameof(file2));
- }
+ ArgumentException.ThrowIfNullOrEmpty(file1);
+ ArgumentException.ThrowIfNullOrEmpty(file2);
var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
@@ -514,15 +494,8 @@ namespace Emby.Server.Implementations.IO
/// <inheritdoc />
public virtual bool ContainsSubPath(string parentPath, string path)
{
- if (string.IsNullOrEmpty(parentPath))
- {
- throw new ArgumentNullException(nameof(parentPath));
- }
-
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(parentPath);
+ ArgumentException.ThrowIfNullOrEmpty(path);
return path.Contains(
Path.TrimEndingDirectorySeparator(parentPath) + Path.DirectorySeparatorChar,
@@ -532,10 +505,7 @@ namespace Emby.Server.Implementations.IO
/// <inheritdoc />
public virtual string NormalizePath(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
{
@@ -621,14 +591,14 @@ namespace Emby.Server.Implementations.IO
// On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
- if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Count == 1)
+ if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Count == 1)
{
return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], enumerationOptions));
}
var files = new DirectoryInfo(path).EnumerateFiles("*", enumerationOptions);
- if (extensions != null && extensions.Count > 0)
+ if (extensions is not null && extensions.Count > 0)
{
files = files.Where(i =>
{
@@ -678,14 +648,14 @@ namespace Emby.Server.Implementations.IO
// On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
- if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Length == 1)
+ if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Length == 1)
{
return Directory.EnumerateFiles(path, "*" + extensions[0], enumerationOptions);
}
var files = Directory.EnumerateFiles(path, "*", enumerationOptions);
- if (extensions != null && extensions.Length > 0)
+ if (extensions is not null && extensions.Length > 0)
{
files = files.Where(i =>
{
diff --git a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
index 76c58d5dc..c2aab3879 100644
--- a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
+++ b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
@@ -19,10 +19,7 @@ namespace Emby.Server.Implementations.IO
public string? Resolve(string shortcutPath)
{
- if (string.IsNullOrEmpty(shortcutPath))
- {
- throw new ArgumentException("Shortcut path is empty or null.", nameof(shortcutPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase))
{
@@ -36,15 +33,8 @@ namespace Emby.Server.Implementations.IO
public void Create(string shortcutPath, string targetPath)
{
- if (string.IsNullOrEmpty(shortcutPath))
- {
- throw new ArgumentNullException(nameof(shortcutPath));
- }
-
- if (string.IsNullOrEmpty(targetPath))
- {
- throw new ArgumentNullException(nameof(targetPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
+ ArgumentException.ThrowIfNullOrEmpty(targetPath);
File.WriteAllText(shortcutPath, targetPath);
}
diff --git a/Emby.Server.Implementations/IO/StreamHelper.cs b/Emby.Server.Implementations/IO/StreamHelper.cs
index f55c16d6d..6eaf22ce4 100644
--- a/Emby.Server.Implementations/IO/StreamHelper.cs
+++ b/Emby.Server.Implementations/IO/StreamHelper.cs
@@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.IO
await destination.WriteAsync(buffer.AsMemory(0, read), cancellationToken).ConfigureAwait(false);
- if (onStarted != null)
+ if (onStarted is not null)
{
onStarted();
onStarted = null;
diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
index 57c2f1a5e..0a3d740cc 100644
--- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
+++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Images
{
var image = item.GetImageInfo(imageType, 0);
- if (image != null)
+ if (image is not null)
{
if (!image.IsLocalFile)
{
@@ -143,20 +143,20 @@ namespace Emby.Server.Implementations.Images
if (useBackdrop)
{
var backdrop = i.GetImageInfo(ImageType.Backdrop, 0);
- if (backdrop != null && backdrop.IsLocalFile)
+ if (backdrop is not null && backdrop.IsLocalFile)
{
return backdrop.Path;
}
}
var image = i.GetImageInfo(ImageType.Primary, 0);
- if (image != null && image.IsLocalFile)
+ if (image is not null && image.IsLocalFile)
{
return image.Path;
}
image = i.GetImageInfo(ImageType.Thumb, 0);
- if (image != null && image.IsLocalFile)
+ if (image is not null && image.IsLocalFile)
{
return image.Path;
}
@@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Images
{
var image = item.GetImageInfo(type, 0);
- if (image != null)
+ if (image is not null)
{
if (!image.IsLocalFile)
{
diff --git a/Emby.Server.Implementations/Images/DynamicImageProvider.cs b/Emby.Server.Implementations/Images/DynamicImageProvider.cs
index 0faa0f8fa..82690f8a9 100644
--- a/Emby.Server.Implementations/Images/DynamicImageProvider.cs
+++ b/Emby.Server.Implementations/Images/DynamicImageProvider.cs
@@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Images
if (i is Episode episode)
{
var series = episode.Series;
- if (series != null)
+ if (series is not null)
{
return series;
}
@@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.Images
if (i is Season season)
{
var series = season.Series;
- if (series != null)
+ if (series is not null)
{
return series;
}
@@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Images
if (i is Audio audio)
{
var album = audio.AlbumEntity;
- if (album != null && album.HasImage(ImageType.Primary))
+ if (album is not null && album.HasImage(ImageType.Primary))
{
return album;
}
diff --git a/Emby.Server.Implementations/Images/PlaylistImageProvider.cs b/Emby.Server.Implementations/Images/PlaylistImageProvider.cs
index b8f0f0d65..580151287 100644
--- a/Emby.Server.Implementations/Images/PlaylistImageProvider.cs
+++ b/Emby.Server.Implementations/Images/PlaylistImageProvider.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Images
if (subItem is Episode episode)
{
var series = episode.Series;
- if (series != null && series.HasImage(ImageType.Primary))
+ if (series is not null && series.HasImage(ImageType.Primary))
{
return series;
}
@@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Images
var parent = subItem.GetOwner() ?? subItem.GetParent();
- if (parent != null && parent.HasImage(ImageType.Primary))
+ if (parent is not null && parent.HasImage(ImageType.Primary))
{
if (parent is MusicAlbum)
{
@@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Images
return null;
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.GroupBy(x => x.Id)
.Select(x => x.First())
.ToList();
diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
index e558fbe27..665d70a41 100644
--- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
+++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
@@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Library
if (fileInfo.IsDirectory)
{
- if (parent != null)
+ if (parent is not null)
{
// Ignore extras folders but allow it at the collection level
if (_namingOptions.AllExtrasTypesFolderNames.ContainsKey(filename)
@@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Library
}
else
{
- if (parent != null)
+ if (parent is not null)
{
// Don't resolve these into audio files
if (Path.GetFileNameWithoutExtension(filename.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringComparison.Ordinal)
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index b688af528..70439d258 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -176,7 +176,7 @@ namespace Emby.Server.Implementations.Library
{
get
{
- if (_rootFolder == null)
+ if (_rootFolder is null)
{
lock (_rootFolderSyncLock)
{
@@ -465,9 +465,9 @@ namespace Emby.Server.Implementations.Library
private BaseItem ResolveItem(ItemResolveArgs args, IItemResolver[] resolvers)
{
var item = (resolvers ?? EntityResolvers).Select(r => Resolve(args, r))
- .FirstOrDefault(i => i != null);
+ .FirstOrDefault(i => i is not null);
- if (item != null)
+ if (item is not null)
{
ResolverHelper.SetInitialItemValues(item, args, _fileSystem, this);
}
@@ -495,11 +495,7 @@ namespace Emby.Server.Implementations.Library
private Guid GetNewItemIdInternal(string key, Type type, bool forceCaseInsensitive)
{
- if (string.IsNullOrEmpty(key))
- {
- throw new ArgumentNullException(nameof(key));
- }
-
+ ArgumentException.ThrowIfNullOrEmpty(key);
ArgumentNullException.ThrowIfNull(type);
string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath;
@@ -536,7 +532,7 @@ namespace Emby.Server.Implementations.Library
var fullPath = fileInfo.FullName;
- if (string.IsNullOrEmpty(collectionType) && parent != null)
+ if (string.IsNullOrEmpty(collectionType) && parent is not null)
{
collectionType = GetContentTypeOverride(fullPath, true);
}
@@ -572,7 +568,7 @@ namespace Emby.Server.Implementations.Library
}
catch (Exception ex)
{
- if (parent != null && parent.IsPhysicalRoot)
+ if (parent is not null && parent.IsPhysicalRoot)
{
_logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf);
@@ -654,9 +650,9 @@ namespace Emby.Server.Implementations.Library
{
var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList();
- if (parent != null)
+ if (parent is not null)
{
- var multiItemResolvers = resolvers == null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
+ var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
foreach (var resolver in multiItemResolvers)
{
@@ -697,7 +693,7 @@ namespace Emby.Server.Implementations.Library
_logger.LogError(ex, "Error resolving path {Path}", file.FullName);
}
- if (result != null)
+ if (result is not null)
{
yield return result;
}
@@ -750,7 +746,7 @@ namespace Emby.Server.Implementations.Library
var dbItem = GetItemById(folder.Id) as BasePluginFolder;
- if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
+ if (dbItem is not null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
{
folder = dbItem;
}
@@ -770,11 +766,11 @@ namespace Emby.Server.Implementations.Library
public Folder GetUserRootFolder()
{
- if (_userRootFolder == null)
+ if (_userRootFolder is null)
{
lock (_userRootFolderSyncLock)
{
- if (_userRootFolder == null)
+ if (_userRootFolder is null)
{
var userRootPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
@@ -792,7 +788,7 @@ namespace Emby.Server.Implementations.Library
_logger.LogError(ex, "Error creating UserRootFolder {Path}", newItemId);
}
- if (tmpItem == null)
+ if (tmpItem is null)
{
_logger.LogDebug("Creating new userRootFolder with DeepCopy");
tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath))).DeepCopy<Folder, UserRootFolder>();
@@ -818,10 +814,7 @@ namespace Emby.Server.Implementations.Library
{
// If this returns multiple items it could be tricky figuring out which one is correct.
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
var query = new InternalItemsQuery
{
@@ -952,7 +945,7 @@ namespace Emby.Server.Implementations.Library
.Cast<T>()
.FirstOrDefault();
- if (existing != null)
+ if (existing is not null)
{
return existing;
}
@@ -961,7 +954,7 @@ namespace Emby.Server.Implementations.Library
var path = getPathFn(name);
var id = GetItemByNameId<T>(path);
var item = GetItemById(id) as T;
- if (item == null)
+ if (item is null)
{
item = new T
{
@@ -1181,7 +1174,7 @@ namespace Emby.Server.Implementations.Library
return null;
}
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.OrderBy(i => i)
.ToArray(),
@@ -1190,17 +1183,17 @@ namespace Emby.Server.Implementations.Library
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
- if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary))
+ if (libraryFolder is not null && libraryFolder.HasImage(ImageType.Primary))
{
info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
}
- if (libraryFolder != null)
+ if (libraryFolder is not null)
{
info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
info.LibraryOptions = GetLibraryOptions(libraryFolder);
- if (refreshQueue != null)
+ if (refreshQueue is not null)
{
info.RefreshProgress = libraryFolder.GetRefreshProgress();
@@ -1245,7 +1238,7 @@ namespace Emby.Server.Implementations.Library
item = RetrieveItem(id);
- if (item != null)
+ if (item is not null)
{
RegisterItem(item);
}
@@ -1258,13 +1251,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default))
{
var parent = GetItemById(query.ParentId);
- if (parent != null)
+ if (parent is not null)
{
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
}
}
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User, allowExternalContent);
}
@@ -1282,13 +1275,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default))
{
var parent = GetItemById(query.ParentId);
- if (parent != null)
+ if (parent is not null)
{
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
}
}
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1302,7 +1295,7 @@ namespace Emby.Server.Implementations.Library
if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1313,7 +1306,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1331,7 +1324,7 @@ namespace Emby.Server.Implementations.Library
public List<Guid> GetItemIds(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1341,7 +1334,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1352,7 +1345,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1363,7 +1356,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1374,7 +1367,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1385,7 +1378,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1426,7 +1419,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1440,13 +1433,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default))
{
var parent = GetItemById(query.ParentId);
- if (parent != null)
+ if (parent is not null)
{
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
}
}
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1524,7 +1517,7 @@ namespace Emby.Server.Implementations.Library
if (!view.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(view.DisplayParentId);
- if (displayParent != null)
+ if (displayParent is not null)
{
return GetTopParentIdsForQuery(displayParent, user);
}
@@ -1535,7 +1528,7 @@ namespace Emby.Server.Implementations.Library
if (!view.ParentId.Equals(default))
{
var displayParent = GetItemById(view.ParentId);
- if (displayParent != null)
+ if (displayParent is not null)
{
return GetTopParentIdsForQuery(displayParent, user);
}
@@ -1544,7 +1537,7 @@ namespace Emby.Server.Implementations.Library
}
// Handle grouping
- if (user != null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
+ if (user is not null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
&& user.GetPreference(PreferenceKind.GroupedFolders).Length > 0)
{
return GetUserRootFolder()
@@ -1564,7 +1557,7 @@ namespace Emby.Server.Implementations.Library
}
var topParent = item.GetTopParent();
- if (topParent != null)
+ if (topParent is not null)
{
return new[] { topParent.Id };
}
@@ -1589,7 +1582,7 @@ namespace Emby.Server.Implementations.Library
return items
.SelectMany(i => i.ToArray())
.Select(ResolveIntro)
- .Where(i => i != null);
+ .Where(i => i is not null);
}
/// <summary>
@@ -1627,7 +1620,7 @@ namespace Emby.Server.Implementations.Library
// Get an existing item by Id
video = GetItemById(info.ItemId.Value) as Video;
- if (video == null)
+ if (video is null)
{
_logger.LogError("Unable to locate item with Id {ID}.", info.ItemId.Value);
}
@@ -1639,7 +1632,7 @@ namespace Emby.Server.Implementations.Library
// Try to resolve the path into a video
video = ResolvePath(_fileSystem.GetFileSystemInfo(info.Path)) as Video;
- if (video == null)
+ if (video is null)
{
_logger.LogError("Intro resolver returned null for {Path}.", info.Path);
}
@@ -1648,7 +1641,7 @@ namespace Emby.Server.Implementations.Library
// Pull the saved db item that will include metadata
var dbItem = GetItemById(video.Id) as Video;
- if (dbItem != null)
+ if (dbItem is not null)
{
video = dbItem;
}
@@ -1685,7 +1678,7 @@ namespace Emby.Server.Implementations.Library
IOrderedEnumerable<BaseItem> orderedItems = null;
- foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c != null))
+ foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c is not null))
{
if (isFirst)
{
@@ -1711,7 +1704,7 @@ namespace Emby.Server.Implementations.Library
foreach (var (name, sortOrder) in orderBy)
{
var comparer = GetComparer(name, user);
- if (comparer == null)
+ if (comparer is null)
{
continue;
}
@@ -1781,7 +1774,7 @@ namespace Emby.Server.Implementations.Library
RegisterItem(item);
}
- if (ItemAdded != null)
+ if (ItemAdded is not null)
{
foreach (var item in items)
{
@@ -1811,7 +1804,7 @@ namespace Emby.Server.Implementations.Library
private bool ImageNeedsRefresh(ItemImageInfo image)
{
- if (image.Path != null && image.IsLocalFile)
+ if (image.Path is not null && image.IsLocalFile)
{
if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash))
{
@@ -1829,7 +1822,7 @@ namespace Emby.Server.Implementations.Library
}
}
- return image.Path != null && !image.IsLocalFile;
+ return image.Path is not null && !image.IsLocalFile;
}
/// <inheritdoc />
@@ -1838,7 +1831,7 @@ namespace Emby.Server.Implementations.Library
ArgumentNullException.ThrowIfNull(item);
var outdated = forceUpdate
- ? item.ImageInfos.Where(i => i.Path != null).ToArray()
+ ? item.ImageInfos.Where(i => i.Path is not null).ToArray()
: item.ImageInfos.Where(ImageNeedsRefresh).ToArray();
// Skip image processing if current or live tv source
if (outdated.Length == 0 || item.SourceType != SourceType.Library)
@@ -1923,7 +1916,7 @@ namespace Emby.Server.Implementations.Library
_itemRepository.SaveItems(items, cancellationToken);
- if (ItemUpdated != null)
+ if (ItemUpdated is not null)
{
foreach (var item in items)
{
@@ -1975,7 +1968,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="parent">The parent item.</param>
public void ReportItemRemoved(BaseItem item, BaseItem parent)
{
- if (ItemRemoved != null)
+ if (ItemRemoved is not null)
{
try
{
@@ -2006,11 +1999,11 @@ namespace Emby.Server.Implementations.Library
public List<Folder> GetCollectionFolders(BaseItem item)
{
- while (item != null)
+ while (item is not null)
{
var parent = item.GetParent();
- if (parent == null || parent is AggregateFolder)
+ if (parent is null || parent is AggregateFolder)
{
break;
}
@@ -2018,7 +2011,7 @@ namespace Emby.Server.Implementations.Library
item = parent;
}
- if (item == null)
+ if (item is null)
{
return new List<Folder>();
}
@@ -2028,11 +2021,11 @@ namespace Emby.Server.Implementations.Library
public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
{
- while (item != null)
+ while (item is not null)
{
var parent = item.GetParent();
- if (parent == null || parent is AggregateFolder)
+ if (parent is null || parent is AggregateFolder)
{
break;
}
@@ -2040,7 +2033,7 @@ namespace Emby.Server.Implementations.Library
item = parent;
}
- if (item == null)
+ if (item is null)
{
return new List<Folder>();
}
@@ -2064,7 +2057,7 @@ namespace Emby.Server.Implementations.Library
.Find(folder => folder is CollectionFolder) as CollectionFolder;
}
- return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
+ return collectionFolder is null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
}
public string GetContentType(BaseItem item)
@@ -2129,7 +2122,7 @@ namespace Emby.Server.Implementations.Library
private string GetTopFolderContentType(BaseItem item)
{
- if (item == null)
+ if (item is null)
{
return null;
}
@@ -2137,7 +2130,7 @@ namespace Emby.Server.Implementations.Library
while (!item.ParentId.Equals(default))
{
var parent = item.GetParent();
- if (parent == null || parent is AggregateFolder)
+ if (parent is null || parent is AggregateFolder)
{
break;
}
@@ -2177,7 +2170,7 @@ namespace Emby.Server.Implementations.Library
var refresh = false;
- if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
+ if (item is null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
{
Directory.CreateDirectory(path);
@@ -2225,7 +2218,7 @@ namespace Emby.Server.Implementations.Library
var isNew = false;
- if (item == null)
+ if (item is null)
{
Directory.CreateDirectory(path);
@@ -2251,7 +2244,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(item.DisplayParentId);
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
}
if (refresh)
@@ -2289,7 +2282,7 @@ namespace Emby.Server.Implementations.Library
var isNew = false;
- if (item == null)
+ if (item is null)
{
Directory.CreateDirectory(path);
@@ -2315,7 +2308,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(item.DisplayParentId);
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
}
if (refresh)
@@ -2340,10 +2333,7 @@ namespace Emby.Server.Implementations.Library
string sortName,
string uniqueId)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
var parentIdString = parentId.Equals(default)
? null
@@ -2362,7 +2352,7 @@ namespace Emby.Server.Implementations.Library
var isNew = false;
- if (item == null)
+ if (item is null)
{
Directory.CreateDirectory(path);
@@ -2394,7 +2384,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(item.DisplayParentId);
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
}
if (refresh)
@@ -2441,7 +2431,7 @@ namespace Emby.Server.Implementations.Library
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
{
var series = episode.Series;
- bool? isAbsoluteNaming = series != null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
+ bool? isAbsoluteNaming = series is not null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
if (!isAbsoluteNaming.Value)
{
// In other words, no filter applied
@@ -2459,10 +2449,10 @@ namespace Emby.Server.Implementations.Library
episodeInfo = resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming);
// Resolve from parent folder if it's not the Season folder
var parent = episode.GetParent();
- if (episodeInfo == null && parent.GetType() == typeof(Folder))
+ if (episodeInfo is null && parent.GetType() == typeof(Folder))
{
episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming);
- if (episodeInfo != null)
+ if (episodeInfo is not null)
{
// add the container
episodeInfo.Container = Path.GetExtension(episode.Path)?.TrimStart('.');
@@ -2582,7 +2572,7 @@ namespace Emby.Server.Implementations.Library
{
var season = episode.Season;
- if (season != null)
+ if (season is not null)
{
episode.ParentIndexNumber = season.IndexNumber;
}
@@ -2620,7 +2610,7 @@ namespace Emby.Server.Implementations.Library
public IEnumerable<BaseItem> FindExtras(BaseItem owner, IReadOnlyList<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService)
{
var ownerVideoInfo = VideoResolver.Resolve(owner.Path, owner.IsFolder, _namingOptions);
- if (ownerVideoInfo == null)
+ if (ownerVideoInfo is null)
{
yield break;
}
@@ -2640,7 +2630,7 @@ namespace Emby.Server.Implementations.Library
}
var extra = GetExtra(file, extraType.Value);
- if (extra != null)
+ if (extra is not null)
{
yield return extra;
}
@@ -2649,7 +2639,7 @@ namespace Emby.Server.Implementations.Library
else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType))
{
var extra = GetExtra(current, extraType.Value);
- if (extra != null)
+ if (extra is not null)
{
yield return extra;
}
@@ -2666,7 +2656,7 @@ namespace Emby.Server.Implementations.Library
// Try to retrieve it from the db. If we don't find it, use the resolved version
var itemById = GetItemById(extra.Id);
- if (itemById != null)
+ if (itemById is not null)
{
extra = itemById;
}
@@ -2681,10 +2671,10 @@ namespace Emby.Server.Implementations.Library
public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem)
{
string newPath;
- if (ownerItem != null)
+ if (ownerItem is not null)
{
var libraryOptions = GetLibraryOptions(ownerItem);
- if (libraryOptions != null)
+ if (libraryOptions is not null)
{
foreach (var pathInfo in libraryOptions.PathInfos)
{
@@ -2753,8 +2743,8 @@ namespace Emby.Server.Implementations.Library
return null;
}
})
- .Where(i => i != null)
- .Where(i => query.User == null ?
+ .Where(i => i is not null)
+ .Where(i => query.User is null ?
true :
i.IsVisible(query.User))
.ToList();
@@ -2838,10 +2828,10 @@ namespace Emby.Server.Implementations.Library
}
var mediaPathInfos = options.PathInfos;
- if (mediaPathInfos != null)
+ if (mediaPathInfos is not null)
{
var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path));
- if (invalidpath != null)
+ if (invalidpath is not null)
{
throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + ".");
}
@@ -2853,7 +2843,7 @@ namespace Emby.Server.Implementations.Library
{
Directory.CreateDirectory(virtualFolderPath);
- if (collectionType != null)
+ if (collectionType is not null)
{
var path = Path.Combine(virtualFolderPath, collectionType.ToString().ToLowerInvariant() + ".collection");
@@ -2862,7 +2852,7 @@ namespace Emby.Server.Implementations.Library
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
- if (mediaPathInfos != null)
+ if (mediaPathInfos is not null)
{
foreach (var path in mediaPathInfos)
{
@@ -3125,10 +3115,7 @@ namespace Emby.Server.Implementations.Library
public void RemoveMediaPath(string virtualFolderName, string mediaPath)
{
- if (string.IsNullOrEmpty(mediaPath))
- {
- throw new ArgumentNullException(nameof(mediaPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(mediaPath);
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs
index 20624cc7a..936a08da8 100644
--- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs
+++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs
@@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Library
}
}
- if (mediaInfo == null)
+ if (mediaInfo is null)
{
if (addProbeDelay)
{
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Library
},
cancellationToken).ConfigureAwait(false);
- if (cacheFilePath != null)
+ if (cacheFilePath is not null)
{
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
await using FileStream createStream = AsyncFile.OpenWrite(cacheFilePath);
@@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.Library
var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audioStream == null || audioStream.Index == -1)
+ if (audioStream is null || audioStream.Index == -1)
{
mediaSource.DefaultAudioStreamIndex = null;
}
@@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Library
}
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- if (videoStream != null)
+ if (videoStream is not null)
{
if (!videoStream.BitRate.HasValue)
{
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index bfccc7db7..eadfa5dfe 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -182,7 +182,7 @@ namespace Emby.Server.Implementations.Library
source.SupportsDirectStream = SupportsDirectStream(source.Path, source.Protocol);
}
- if (user != null)
+ if (user is not null)
{
SetDefaultAudioAndSubtitleStreamIndexes(item, source, user);
@@ -248,7 +248,7 @@ namespace Emby.Server.Implementations.Library
if (protocol == MediaProtocol.Http)
{
- if (path != null)
+ if (path is not null)
{
if (path.Contains(".m3u", StringComparison.OrdinalIgnoreCase))
{
@@ -328,7 +328,7 @@ namespace Emby.Server.Implementations.Library
var sources = hasMediaSources.GetMediaSources(enablePathSubstitution);
- if (user != null)
+ if (user is not null)
{
foreach (var source in sources)
{
@@ -357,7 +357,7 @@ namespace Emby.Server.Implementations.Library
}
var culture = _localizationManager.FindLanguageInfo(language);
- if (culture != null)
+ if (culture is not null)
{
return culture.ThreeLetterISOLanguageNames;
}
@@ -383,7 +383,7 @@ namespace Emby.Server.Implementations.Library
var preferredSubs = NormalizeLanguage(user.SubtitleLanguagePreference);
var defaultAudioIndex = source.DefaultAudioStreamIndex;
- var audioLangage = defaultAudioIndex == null
+ var audioLangage = defaultAudioIndex is null
? null
: source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault();
@@ -417,13 +417,13 @@ namespace Emby.Server.Implementations.Library
public void SetDefaultAudioAndSubtitleStreamIndexes(BaseItem item, MediaSourceInfo source, User user)
{
// Item would only be null if the app didn't supply ItemId as part of the live stream open request
- var mediaType = item == null ? MediaType.Video : item.MediaType;
+ var mediaType = item is null ? MediaType.Video : item.MediaType;
if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
{
- var userData = item == null ? new UserItemData() : _userDataManager.GetUserData(user, item);
+ var userData = item is null ? new UserItemData() : _userDataManager.GetUserData(user, item);
- var allowRememberingSelection = item == null || item.EnableRememberingTrackSelections;
+ var allowRememberingSelection = item is null || item.EnableRememberingTrackSelections;
SetDefaultAudioStreamIndex(source, userData, user, allowRememberingSelection);
SetDefaultSubtitleStreamIndex(source, userData, user, allowRememberingSelection);
@@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.Library
{
var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audio != null)
+ if (audio is not null)
{
source.DefaultAudioStreamIndex = audio.Index;
}
@@ -543,7 +543,7 @@ namespace Emby.Server.Implementations.Library
var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audioStream == null || audioStream.Index == -1)
+ if (audioStream is null || audioStream.Index == -1)
{
mediaSource.DefaultAudioStreamIndex = null;
}
@@ -553,7 +553,7 @@ namespace Emby.Server.Implementations.Library
}
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- if (videoStream != null)
+ if (videoStream is not null)
{
if (!videoStream.BitRate.HasValue)
{
@@ -638,7 +638,7 @@ namespace Emby.Server.Implementations.Library
}
}
- if (mediaInfo == null)
+ if (mediaInfo is null)
{
if (addProbeDelay)
{
@@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.Library
},
cancellationToken).ConfigureAwait(false);
- if (cacheFilePath != null)
+ if (cacheFilePath is not null)
{
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
await using FileStream createStream = File.Create(cacheFilePath);
@@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.Library
var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audioStream == null || audioStream.Index == -1)
+ if (audioStream is null || audioStream.Index == -1)
{
mediaSource.DefaultAudioStreamIndex = null;
}
@@ -723,7 +723,7 @@ namespace Emby.Server.Implementations.Library
}
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- if (videoStream != null)
+ if (videoStream is not null)
{
if (!videoStream.BitRate.HasValue)
{
@@ -762,10 +762,7 @@ namespace Emby.Server.Implementations.Library
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStreamWithDirectStreamProvider(string id, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
// TODO probably shouldn't throw here but it is kept for "backwards compatibility"
var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
@@ -774,10 +771,7 @@ namespace Emby.Server.Implementations.Library
public ILiveStream GetLiveStreamInfo(string id)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
if (_openStreams.TryGetValue(id, out ILiveStream info))
{
@@ -801,10 +795,7 @@ namespace Emby.Server.Implementations.Library
public async Task CloseLiveStream(string id)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false);
@@ -835,10 +826,7 @@ namespace Emby.Server.Implementations.Library
private (IMediaSourceProvider MediaSourceProvider, string KeyId) GetProvider(string key)
{
- if (string.IsNullOrEmpty(key))
- {
- throw new ArgumentException("Key can't be empty.", nameof(key));
- }
+ ArgumentException.ThrowIfNullOrEmpty(key);
var keys = key.Split(LiveStreamIdDelimeter, 2);
diff --git a/Emby.Server.Implementations/Library/MediaStreamSelector.cs b/Emby.Server.Implementations/Library/MediaStreamSelector.cs
index 609b95772..74c53b2da 100644
--- a/Emby.Server.Implementations/Library/MediaStreamSelector.cs
+++ b/Emby.Server.Implementations/Library/MediaStreamSelector.cs
@@ -19,7 +19,7 @@ namespace Emby.Server.Implementations.Library
{
var defaultStream = sortedStreams.FirstOrDefault(i => i.IsDefault);
- if (defaultStream != null)
+ if (defaultStream is not null)
{
return defaultStream.Index;
}
diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs
index 4100a74a5..7a61e2607 100644
--- a/Emby.Server.Implementations/Library/ResolverHelper.cs
+++ b/Emby.Server.Implementations/Library/ResolverHelper.cs
@@ -25,13 +25,10 @@ namespace Emby.Server.Implementations.Library
public static bool SetInitialItemValues(BaseItem item, Folder? parent, ILibraryManager libraryManager, IDirectoryService directoryService)
{
// This version of the below method has no ItemResolveArgs, so we have to require the path already being set
- if (string.IsNullOrEmpty(item.Path))
- {
- throw new ArgumentException("Item must have a Path");
- }
+ ArgumentException.ThrowIfNullOrEmpty(item.Path);
// If the resolver didn't specify this
- if (parent != null)
+ if (parent is not null)
{
item.SetParent(parent);
}
@@ -43,7 +40,7 @@ namespace Emby.Server.Implementations.Library
// Make sure DateCreated and DateModified have values
var fileInfo = directoryService.GetFile(item.Path);
- if (fileInfo == null)
+ if (fileInfo is null)
{
return false;
}
@@ -71,7 +68,7 @@ namespace Emby.Server.Implementations.Library
}
// If the resolver didn't specify this
- if (args.Parent != null)
+ if (args.Parent is not null)
{
item.SetParent(args.Parent);
}
@@ -113,7 +110,7 @@ namespace Emby.Server.Implementations.Library
{
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
- if (childData != null)
+ if (childData is not null)
{
SetDateCreated(item, childData);
}
@@ -140,7 +137,7 @@ namespace Emby.Server.Implementations.Library
if (config.UseFileCreationTimeForDateAdded)
{
// directoryService.getFile may return null
- if (info != null)
+ if (info is not null)
{
var dateCreated = info.CreationTimeUtc;
diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
index 7a6aea9c1..06621700a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
@@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{
var result = ResolveMultipleInternal(parent, files, collectionType);
- if (result != null)
+ if (result is not null)
{
foreach (var item in result.Items)
{
@@ -116,7 +116,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
// Use regular audio type for mixed libraries, owned items and music
if (isMixedCollectionType ||
- args.Parent == null ||
+ args.Parent is null ||
isMusicCollectionType)
{
item = new MediaBrowser.Controller.Entities.Audio.Audio();
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
item = new AudioBook();
}
- if (item != null)
+ if (item is not null)
{
item.IsShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase);
@@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
// TODO: Allow GetMultiDiscMovie in here
var result = ResolveMultipleAudio(args.Parent, args.GetActualFileSystemChildren(), parseName);
- if (result == null || result.Items.Count != 1 || result.Items[0] is not AudioBook item)
+ if (result is null || result.Items.Count != 1 || result.Items[0] is not AudioBook item)
{
return null;
}
@@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
Items = items
};
- var isInMixedFolder = resolverResult.Count > 1 || (parent != null && parent.IsTopParent);
+ var isInMixedFolder = resolverResult.Count > 1 || (parent is not null && parent.IsTopParent);
foreach (var resolvedItem in resolverResult)
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
index b2a7abb1b..cb377136a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
@@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
videoType = VideoType.Dvd;
}
- if (videoType == null)
+ if (videoType is null)
{
continue;
}
@@ -93,7 +93,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
videoInfo = VideoResolver.Resolve(args.Path, false, NamingOptions, parseName);
}
- if (videoInfo == null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions)))
+ if (videoInfo is null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions)))
{
return null;
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
index 6fc200e3b..042422c6f 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
var extension = Path.GetExtension(args.Path);
- if (extension != null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
+ if (extension is not null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
{
// It's a book
return new Book
diff --git a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
index 408e640f9..30c52e19d 100644
--- a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType)
{
var extraResult = GetExtraInfo(path, _namingOptions);
- if (extraResult.ExtraType == null)
+ if (extraResult.ExtraType is null)
{
extraType = null;
return false;
diff --git a/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs
index 079962282..1c2de912a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs
@@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
{
base.SetInitialItemValues(item, args);
- item.IsRoot = args.Parent == null;
+ item.IsRoot = args.Parent is null;
}
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 84d4688af..5f1a3ec6d 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{
var result = ResolveMultipleInternal(parent, files, collectionType);
- if (result != null)
+ if (result is not null)
{
foreach (var item in result.Items)
{
@@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.IsNullOrEmpty(collectionType))
{
// Owned items will be caught by the video extra resolver
- if (args.Parent == null)
+ if (args.Parent is null)
{
return null;
}
@@ -127,10 +127,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
// ignore extras
- return movie?.ExtraType == null ? movie : null;
+ return movie?.ExtraType is null ? movie : null;
}
- if (args.Parent == null)
+ if (args.Parent is null)
{
return base.Resolve(args);
}
@@ -168,12 +168,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
// Ignore extras
- if (item?.ExtraType != null)
+ if (item?.ExtraType is not null)
{
return null;
}
- if (item != null)
+ if (item is not null)
{
item.IsInMixedFolder = true;
}
@@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.IsNullOrEmpty(collectionType))
{
// Owned items should just use the plain video type
- if (parent == null)
+ if (parent is null)
{
return ResolveVideos<Video>(parent, files, false, collectionType, false);
}
@@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
var videoInfos = files
.Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName))
- .Where(f => f != null)
+ .Where(f => f is not null)
.ToList();
var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName);
@@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{
var firstVideo = video.Files[0];
var path = firstVideo.Path;
- if (video.ExtraType != null)
+ if (video.ExtraType is not null)
{
result.ExtraFiles.Add(files.Find(f => string.Equals(f.FullName, path, StringComparison.OrdinalIgnoreCase)));
continue;
@@ -568,7 +568,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
private bool IsInvalid(Folder parent, ReadOnlySpan<char> collectionType)
{
- if (parent != null)
+ if (parent is not null)
{
if (parent.IsRoot)
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
index 9ba079edf..0fcc5070b 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{
var parent = args.Parent;
- if (parent == null)
+ if (parent is null)
{
return null;
}
@@ -46,34 +46,34 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
// If the parent is a Season or Series and the parent is not an extras folder, then this is an Episode if the VideoResolver returns something
// Also handle flat tv folders
- if (season != null ||
+ if (season is not null ||
string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ||
args.HasParent<Series>())
{
var episode = ResolveVideo<Episode>(args, false);
// Ignore extras
- if (episode == null || episode.ExtraType != null)
+ if (episode is null || episode.ExtraType is not null)
{
return null;
}
var series = parent as Series ?? parent.GetParents().OfType<Series>().FirstOrDefault();
- if (series != null)
+ if (series is not null)
{
episode.SeriesId = series.Id;
episode.SeriesName = series.Name;
}
- if (season != null)
+ if (season is not null)
{
episode.SeasonId = season.Id;
episode.SeasonName = season.Name;
}
// Assume season 1 if there's no season folder and a season number could not be determined
- if (season == null && !episode.ParentIndexNumber.HasValue && (episode.IndexNumber.HasValue || episode.PremiereDate.HasValue))
+ if (season is null && !episode.ParentIndexNumber.HasValue && (episode.IndexNumber.HasValue || episode.PremiereDate.HasValue))
{
episode.ParentIndexNumber = 1;
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index ea4851458..62a524d2e 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var episodeInfo = resolver.Resolve(testPath, true);
- if (episodeInfo?.EpisodeNumber != null && episodeInfo.SeasonNumber.HasValue)
+ if (episodeInfo?.EpisodeNumber is not null && episodeInfo.SeasonNumber.HasValue)
{
_logger.LogDebug(
"Found folder underneath series with episode number: {0}. Season {1}. Episode {2}",
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
index f5ac3c665..8f69175d0 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
@@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{
if (args.ContainsFileSystemEntryByName("tvshow.nfo"))
{
- if (args.Parent != null && args.Parent.IsRoot)
+ if (args.Parent is not null && args.Parent.IsRoot)
{
// For now, return null, but if we want to allow this in the future then add some additional checks to guard against a misplaced tvshow.nfo
return null;
@@ -89,7 +89,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
};
}
- if (args.Parent != null && args.Parent.IsRoot)
+ if (args.Parent is not null && args.Parent.IsRoot)
{
return null;
}
@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions);
var episodeInfo = episodeResolver.Resolve(fullName, false, true, false, fillExtendedInfo: false);
- if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)
+ if (episodeInfo is not null && episodeInfo.EpisodeNumber.HasValue)
{
return true;
}
diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs
index 60778a443..b916b9170 100644
--- a/Emby.Server.Implementations/Library/SearchEngine.cs
+++ b/Emby.Server.Implementations/Library/SearchEngine.cs
@@ -73,10 +73,7 @@ namespace Emby.Server.Implementations.Library
{
var searchTerm = query.SearchTerm;
- if (string.IsNullOrEmpty(searchTerm))
- {
- throw new ArgumentException("SearchTerm can't be empty.", nameof(query));
- }
+ ArgumentException.ThrowIfNullOrEmpty(searchTerm);
searchTerm = searchTerm.Trim().RemoveDiacritics();
diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs
index aecab7d9c..a0a90b129 100644
--- a/Emby.Server.Implementations/Library/UserDataManager.cs
+++ b/Emby.Server.Implementations/Library/UserDataManager.cs
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library
{
var userData = _repository.GetUserData(internalUserId, keys);
- if (userData != null)
+ if (userData is not null)
{
return userData;
}
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs
index ec411aa3b..1137625f4 100644
--- a/Emby.Server.Implementations/Library/UserViewManager.cs
+++ b/Emby.Server.Implementations/Library/UserViewManager.cs
@@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library
{
var user = _userManager.GetUserById(query.UserId);
- if (user == null)
+ if (user is null)
{
throw new ArgumentException("User Id specified in the query does not exist.", nameof(query));
}
@@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.Library
continue;
}
- if (collectionFolder != null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id))
+ if (collectionFolder is not null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id))
{
groupedFolders.Add(collectionFolder);
continue;
@@ -208,15 +208,15 @@ namespace Emby.Server.Implementations.Library
// Only grab the index container for media
var container = item.IsFolder || !request.GroupItems ? null : item.LatestItemsIndexContainer;
- if (container == null)
+ if (container is null)
{
list.Add(new Tuple<BaseItem, List<BaseItem>>(null, new List<BaseItem> { item }));
}
else
{
- var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id.Equals(container.Id));
+ var current = list.FirstOrDefault(i => i.Item1 is not null && i.Item1.Id.Equals(container.Id));
- if (current != null)
+ if (current is not null)
{
current.Item2.Add(item);
}
diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
index 88b93a211..df45793c3 100644
--- a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
+++ b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
@@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.Library.Validators
try
{
var boxSet = boxSets.FirstOrDefault(b => b?.Name == collectionName) as BoxSet;
- if (boxSet == null)
+ if (boxSet is null)
{
// won't automatically create collection if only one movie in it
if (movieIds.Count >= 2)
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
index b2d25fdae..49833de73 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public Task Record(IDirectStreamProvider? directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
- if (directStreamProvider != null)
+ if (directStreamProvider is not null)
{
return RecordFromDirectStreamProvider(directStreamProvider, targetFile, duration, onStarted, cancellationToken);
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index cf9be5a54..8f5fa8694 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -295,7 +295,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var program = GetProgramInfoFromCache(timer);
- if (program == null)
+ if (program is null)
{
OnTimerOutOfDate(timer);
continue;
@@ -367,7 +367,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var epgChannel = GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels);
- if (epgChannel != null)
+ if (epgChannel is not null)
{
if (!string.IsNullOrWhiteSpace(epgChannel.Name))
{
@@ -450,7 +450,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelById(mappedTunerChannelId);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -473,7 +473,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelById(mappedTunerChannelId);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -490,7 +490,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelByNumber(tunerChannelNumber);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -502,7 +502,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelByName(normalizedName);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -552,7 +552,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var remove = _seriesTimerProvider.GetAll().FirstOrDefault(r => string.Equals(r.Id, timerId, StringComparison.OrdinalIgnoreCase));
- if (remove != null)
+ if (remove is not null)
{
_seriesTimerProvider.Delete(remove);
}
@@ -563,7 +563,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private void CancelTimerInternal(string timerId, bool isSeriesCancelled, bool isManualCancellation)
{
var timer = _timerProvider.GetTimer(timerId);
- if (timer != null)
+ if (timer is not null)
{
var statusChanging = timer.Status != RecordingStatus.Cancelled;
timer.Status = RecordingStatus.Cancelled;
@@ -582,7 +582,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_timerProvider.AddOrUpdate(timer, false);
}
- if (statusChanging && TimerCancelled != null)
+ if (statusChanging && TimerCancelled is not null)
{
TimerCancelled(this, new GenericEventArgs<string>(timerId));
}
@@ -617,7 +617,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
null :
_timerProvider.GetTimerByProgramId(info.ProgramId);
- if (existingTimer != null)
+ if (existingTimer is not null)
{
if (existingTimer.Status == RecordingStatus.Cancelled
|| existingTimer.Status == RecordingStatus.Completed)
@@ -642,13 +642,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
programInfo = GetProgramInfoFromCache(info);
}
- if (programInfo == null)
+ if (programInfo is null)
{
_logger.LogInformation("Unable to find program with Id {0}. Will search using start date", info.ProgramId);
programInfo = GetProgramInfoFromCache(info.ChannelId, info.StartDate);
}
- if (programInfo != null)
+ if (programInfo is not null)
{
CopyProgramInfoToTimerInfo(programInfo, info);
}
@@ -668,7 +668,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// populate info.seriesID
var program = GetProgramInfoFromCache(info.ProgramId);
- if (program != null)
+ if (program is not null)
{
info.SeriesId = program.ExternalSeriesId;
}
@@ -714,7 +714,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var instance = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
- if (instance != null)
+ if (instance is not null)
{
instance.ChannelId = info.ChannelId;
instance.Days = info.Days;
@@ -744,7 +744,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var existingTimer = _timerProvider.GetTimer(updatedTimer.Id);
- if (existingTimer == null)
+ if (existingTimer is null)
{
throw new ResourceNotFoundException();
}
@@ -861,7 +861,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
};
- if (program != null)
+ if (program is not null)
{
defaults.SeriesId = program.SeriesId;
defaults.ProgramId = program.Id;
@@ -912,7 +912,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var epgChannel = await GetEpgChannelFromTunerChannel(provider.Item1, provider.Item2, channel, cancellationToken).ConfigureAwait(false);
- if (epgChannel == null)
+ if (epgChannel is null)
{
_logger.LogDebug("EPG channel not found for tuner channel {0}-{1} from {2}-{3}", channel.Number, channel.Name, provider.Item1.Name, provider.Item2.ListingsId ?? string.Empty);
continue;
@@ -945,9 +945,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var provider = _liveTvManager.ListingProviders.FirstOrDefault(l => string.Equals(l.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- return provider == null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i);
+ return provider is null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i);
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList();
}
@@ -964,7 +964,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
null :
currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase));
- if (result != null && result.EnableStreamSharing)
+ if (result is not null && result.EnableStreamSharing)
{
result.ConsumerCount++;
@@ -1134,7 +1134,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// trim trailing period from the folder name
var folderName = _fileSystem.GetValidFilename(timer.Name).Trim().TrimEnd('.').Trim();
- if (metadata != null && metadata.ProductionYear.HasValue)
+ if (metadata is not null && metadata.ProductionYear.HasValue)
{
folderName += " (" + metadata.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
}
@@ -1232,13 +1232,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
programInfo = GetProgramInfoFromCache(timer);
}
- if (programInfo == null)
+ if (programInfo is null)
{
_logger.LogInformation("Unable to find program with Id {0}. Will search using start date", timer.ProgramId);
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
}
- if (programInfo != null)
+ if (programInfo is not null)
{
CopyProgramInfoToTimerInfo(programInfo, timer);
}
@@ -1412,7 +1412,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var item = GetAffectedBaseItem(Path.GetDirectoryName(path));
- if (item != null)
+ if (item is not null)
{
_logger.LogInformation("Refreshing recording parent {Path}", item.Path);
@@ -1437,19 +1437,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var parentPath = Path.GetDirectoryName(path);
- while (item == null && !string.IsNullOrEmpty(path))
+ while (item is null && !string.IsNullOrEmpty(path))
{
item = _libraryManager.FindByPath(path, null);
path = Path.GetDirectoryName(path);
}
- if (item != null)
+ if (item is not null)
{
if (item.GetType() == typeof(Folder) && string.Equals(item.Path, parentPath, StringComparison.OrdinalIgnoreCase))
{
var parentItem = item.GetParent();
- if (parentItem != null && parentItem is not AggregateFolder)
+ if (parentItem is not null && parentItem is not AggregateFolder)
{
item = parentItem;
}
@@ -1474,7 +1474,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var seriesTimerId = timer.SeriesTimerId;
var seriesTimer = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, seriesTimerId, StringComparison.OrdinalIgnoreCase));
- if (seriesTimer == null || seriesTimer.KeepUpTo <= 0)
+ if (seriesTimer is null || seriesTimer.KeepUpTo <= 0)
{
return;
}
@@ -1569,7 +1569,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var libraryItem = _libraryManager.FindByPath(timer.RecordingPath, false);
- if (libraryItem != null)
+ if (libraryItem is not null)
{
_libraryManager.DeleteItem(
libraryItem,
@@ -1695,7 +1695,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_ => null
};
- if (imageSaveFilenameWithoutExtension == null)
+ if (imageSaveFilenameWithoutExtension is null)
{
return;
}
@@ -1714,7 +1714,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
(program.GetImageInfo(ImageType.Thumb, 0) ?? program.GetImageInfo(ImageType.Primary, 0)) :
(program.GetImageInfo(ImageType.Primary, 0) ?? program.GetImageInfo(ImageType.Thumb, 0));
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1729,7 +1729,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (!program.IsSeries)
{
image = program.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1742,7 +1742,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
image = program.GetImageInfo(ImageType.Thumb, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1755,7 +1755,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
image = program.GetImageInfo(ImageType.Logo, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1782,7 +1782,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}).FirstOrDefault() as LiveTvProgram;
// dummy this up
- if (program == null)
+ if (program is null)
{
program = new LiveTvProgram
{
@@ -2240,7 +2240,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
? null
: _timerProvider.GetTimerByProgramId(timer.ProgramId));
- if (existingTimer == null)
+ if (existingTimer is null)
{
if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer))
{
@@ -2367,13 +2367,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions()
}).FirstOrDefault() as LiveTvChannel;
- if (channel != null && !string.IsNullOrWhiteSpace(channel.ExternalId))
+ if (channel is not null && !string.IsNullOrWhiteSpace(channel.ExternalId))
{
tempChannelCache[parent.ChannelId] = channel;
}
}
- if (channel != null || tempChannelCache.TryGetValue(parent.ChannelId, out channel))
+ if (channel is not null || tempChannelCache.TryGetValue(parent.ChannelId, out channel))
{
channelId = channel.ExternalId;
}
@@ -2426,13 +2426,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions()
}).FirstOrDefault() as LiveTvChannel;
- if (channel != null && !string.IsNullOrWhiteSpace(channel.ExternalId))
+ if (channel is not null && !string.IsNullOrWhiteSpace(channel.ExternalId))
{
tempChannelCache[programInfo.ChannelId] = channel;
}
}
- if (channel != null || tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
+ if (channel is not null || tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
{
channelId = channel.ExternalId;
}
@@ -2626,7 +2626,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase));
- if (configuredDevice != null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
+ if (configuredDevice is not null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
{
_logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url);
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 08534de59..5369c9b3d 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -208,7 +208,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// var audioChannels = 2;
// var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- // if (audioStream != null)
+ // if (audioStream is not null)
// {
// audioChannels = audioStream.Channels ?? audioChannels;
// }
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
index 58b798ce6..d5a6feb47 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
@@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
[MemberNotNull(nameof(_items))]
private void EnsureLoaded()
{
- if (_items != null)
+ if (_items is not null)
{
return;
}
@@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var bytes = File.ReadAllBytes(_dataPath);
_items = JsonSerializer.Deserialize<T[]>(bytes, _jsonOptions);
- if (_items == null)
+ if (_items is null)
{
Logger.LogError("Error deserializing {Path}, data was null", _dataPath);
_items = Array.Empty<T>();
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
index 40dcca94f..7bbeae866 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
@@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
}
- else if (info.IsMovie && info.ProductionYear != null)
+ else if (info.IsMovie && info.ProductionYear is not null)
{
name += " (" + info.ProductionYear + ")";
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
index b1259de23..bf28f3b67 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
@@ -16,10 +16,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
/// <inheritdoc />
public override void Add(SeriesTimerInfo item)
{
- if (string.IsNullOrEmpty(item.Id))
- {
- throw new ArgumentException("SeriesTimerInfo.Id cannot be null or empty.");
- }
+ ArgumentException.ThrowIfNullOrEmpty(item.Id);
base.Add(item);
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
index f612565d1..9f8441fa4 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
@@ -74,10 +74,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public override void Add(TimerInfo item)
{
- if (string.IsNullOrEmpty(item.Id))
- {
- throw new ArgumentException("TimerInfo.Id cannot be null or empty.");
- }
+ ArgumentException.ThrowIfNullOrEmpty(item.Id);
base.Add(item);
AddOrUpdateSystemTimer(item);
@@ -165,7 +162,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var timerId = (string?)state ?? throw new ArgumentNullException(nameof(state));
var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));
- if (timer != null)
+ if (timer is not null)
{
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(timer));
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index b981ad81a..3f7914d3b 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -74,10 +74,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
// Normalize incoming input
channelId = channelId.Replace(".json.schedulesdirect.org", string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart('I');
@@ -111,7 +108,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var dailySchedules = await JsonSerializer.DeserializeAsync<IReadOnlyList<DayDto>>(responseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (dailySchedules == null)
+ if (dailySchedules is null)
{
return Array.Empty<ProgramInfo>();
}
@@ -127,7 +124,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var programDetails = await JsonSerializer.DeserializeAsync<IReadOnlyList<ProgramDetailsDto>>(innerResponseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (programDetails == null)
+ if (programDetails is null)
{
return Array.Empty<ProgramInfo>();
}
@@ -153,7 +150,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
continue;
}
- if (images != null)
+ if (images is not null)
{
var imageIndex = images.FindIndex(i => i.ProgramId == schedule.ProgramId[..10]);
if (imageIndex > -1)
@@ -228,7 +225,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private ProgramInfo GetProgram(string channelId, ProgramDto programInfo, ProgramDetailsDto details)
{
- if (programInfo.AirDateTime == null)
+ if (programInfo.AirDateTime is null)
{
return null;
}
@@ -266,7 +263,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
string episodeTitle = null;
- if (details.EpisodeTitle150 != null)
+ if (details.EpisodeTitle150 is not null)
{
episodeTitle = details.EpisodeTitle150;
}
@@ -283,7 +280,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
EpisodeTitle = episodeTitle,
Audio = audioType,
// IsNew = programInfo.@new ?? false,
- IsRepeat = programInfo.New == null,
+ IsRepeat = programInfo.New is null,
IsSeries = string.Equals(details.EntityType, "episode", StringComparison.OrdinalIgnoreCase),
ImageUrl = details.PrimaryImage,
ThumbImageUrl = details.ThumbImage,
@@ -315,13 +312,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
info.ShowId = showId;
- if (programInfo.VideoProperties != null)
+ if (programInfo.VideoProperties is not null)
{
info.IsHD = programInfo.VideoProperties.Contains("hdtv", StringComparison.OrdinalIgnoreCase);
info.Is3D = programInfo.VideoProperties.Contains("3d", StringComparison.OrdinalIgnoreCase);
}
- if (details.ContentRating != null && details.ContentRating.Count > 0)
+ if (details.ContentRating is not null && details.ContentRating.Count > 0)
{
info.OfficialRating = details.ContentRating[0].Code.Replace("TV", "TV-", StringComparison.Ordinal)
.Replace("--", "-", StringComparison.Ordinal);
@@ -333,13 +330,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- if (details.Descriptions != null)
+ if (details.Descriptions is not null)
{
- if (details.Descriptions.Description1000 != null && details.Descriptions.Description1000.Count > 0)
+ if (details.Descriptions.Description1000 is not null && details.Descriptions.Description1000.Count > 0)
{
info.Overview = details.Descriptions.Description1000[0].Description;
}
- else if (details.Descriptions.Description100 != null && details.Descriptions.Description100.Count > 0)
+ else if (details.Descriptions.Description100 is not null && details.Descriptions.Description100.Count > 0)
{
info.Overview = details.Descriptions.Description100[0].Description;
}
@@ -351,12 +348,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
info.SeriesProviderIds[MetadataProvider.Zap2It.ToString()] = info.SeriesId;
- if (details.Metadata != null)
+ if (details.Metadata is not null)
{
foreach (var metadataProgram in details.Metadata)
{
var gracenote = metadataProgram.Gracenote;
- if (gracenote != null)
+ if (gracenote is not null)
{
info.SeasonNumber = gracenote.Season;
@@ -371,13 +368,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- if (details.OriginalAirDate != null)
+ if (details.OriginalAirDate is not null)
{
info.OriginalAirDate = details.OriginalAirDate;
info.ProductionYear = info.OriginalAirDate.Value.Year;
}
- if (details.Movie != null)
+ if (details.Movie is not null)
{
if (!string.IsNullOrEmpty(details.Movie.Year)
&& int.TryParse(details.Movie.Year, out int year))
@@ -386,7 +383,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- if (details.Genres != null)
+ if (details.Genres is not null)
{
info.Genres = details.Genres.Where(g => !string.IsNullOrWhiteSpace(g)).ToList();
info.IsNews = details.Genres.Contains("news", StringComparison.OrdinalIgnoreCase);
@@ -407,7 +404,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
.ThenByDescending(i => GetSizeOrder(i))
.FirstOrDefault();
- if (match == null)
+ if (match is null)
{
return null;
}
@@ -518,7 +515,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var root = await JsonSerializer.DeserializeAsync<IReadOnlyList<HeadendsDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (root != null)
+ if (root is not null)
{
foreach (HeadendsDto headend in root)
{
@@ -670,15 +667,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
- if (string.IsNullOrEmpty(token))
- {
- throw new ArgumentException("Authentication required.");
- }
-
- if (string.IsNullOrEmpty(info.ListingsId))
- {
- throw new ArgumentException("Listings Id required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(token);
+ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
_logger.LogInformation("Adding new LineUp ");
@@ -689,17 +679,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(info.ListingsId))
- {
- throw new ArgumentException("Listings Id required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
- if (string.IsNullOrEmpty(token))
- {
- throw new ArgumentException("token required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(token);
_logger.LogInformation("Headends on account ");
@@ -732,23 +716,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
if (validateLogin)
{
- if (string.IsNullOrEmpty(info.Username))
- {
- throw new ArgumentException("Username is required");
- }
-
- if (string.IsNullOrEmpty(info.Password))
- {
- throw new ArgumentException("Password is required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(info.Username);
+ ArgumentException.ThrowIfNullOrEmpty(info.Password);
}
if (validateListings)
{
- if (string.IsNullOrEmpty(info.ListingsId))
- {
- throw new ArgumentException("Listings Id required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false);
@@ -767,17 +741,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public async Task<List<ChannelInfo>> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
{
var listingsId = info.ListingsId;
- if (string.IsNullOrEmpty(listingsId))
- {
- throw new ArgumentException("ListingsId required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(listingsId);
var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
- if (string.IsNullOrEmpty(token))
- {
- throw new ArgumentException("token required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(token);
using var options = new HttpRequestMessage(HttpMethod.Get, ApiUrl + "/lineups/" + listingsId);
options.Headers.TryAddWithoutValidation("token", token);
@@ -785,7 +753,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var root = await JsonSerializer.DeserializeAsync<ChannelDto>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (root == null)
+ if (root is null)
{
return new List<ChannelInfo>();
}
@@ -814,7 +782,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
Name = string.IsNullOrWhiteSpace(station.Name) ? channelNumber : station.Name
};
- if (station.Logo != null)
+ if (station.Logo is not null)
{
channelInfo.ImageUrl = station.Logo.Url;
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 82f0baf32..e874990da 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -151,9 +151,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings
Overview = program.Description,
ProductionYear = program.CopyrightDate?.Year,
SeasonNumber = program.Episode?.Series,
- IsSeries = program.Episode != null,
+ IsSeries = program.Episode is not null,
IsRepeat = program.IsPreviouslyShown && !program.IsNew,
- IsPremiere = program.Premiere != null,
+ IsPremiere = program.Premiere is not null,
IsKids = program.Categories.Any(c => info.KidsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
@@ -162,7 +162,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
HasImage = !string.IsNullOrEmpty(program.Icon?.Source),
OfficialRating = string.IsNullOrEmpty(program.Rating?.Value) ? null : program.Rating.Value,
CommunityRating = program.StarRating,
- SeriesId = program.Episode == null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture)
+ SeriesId = program.Episode is null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture)
};
if (string.IsNullOrWhiteSpace(program.ProgramId))
@@ -243,7 +243,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
Id = c.Id,
Name = c.DisplayName,
- ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
+ ImageUrl = string.IsNullOrEmpty(c.Icon.Source) ? null : c.Icon.Source,
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
}).ToList();
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
index c09f9cf8d..9326fbd5c 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture);
}
- if (program != null)
+ if (program is not null)
{
dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions());
@@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- if (channel != null)
+ if (channel is not null)
{
dto.ChannelName = channel.Name;
@@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture);
}
- dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days.ToArray());
+ dto.DayPattern = info.Days is null ? null : GetDayPattern(info.Days.ToArray());
FillImages(dto, info.Name, info.SeriesId);
@@ -168,10 +168,10 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false)
}).FirstOrDefault();
- if (librarySeries != null)
+ if (librarySeries is not null)
{
var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.LiveTv
}
image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -212,10 +212,10 @@ namespace Emby.Server.Implementations.LiveTv
Name = string.IsNullOrEmpty(programSeriesId) ? seriesName : null
}).FirstOrDefault();
- if (program != null)
+ if (program is not null)
{
var image = program.GetImageInfo(ImageType.Primary, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -228,10 +228,10 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0)
+ if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0)
{
image = program.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -262,10 +262,10 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false)
}).FirstOrDefault();
- if (librarySeries != null)
+ if (librarySeries is not null)
{
var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -279,7 +279,7 @@ namespace Emby.Server.Implementations.LiveTv
}
image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -305,7 +305,7 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false)
}).FirstOrDefault();
- if (program == null)
+ if (program is null)
{
program = _libraryManager.GetItemList(new InternalItemsQuery
{
@@ -318,10 +318,10 @@ namespace Emby.Server.Implementations.LiveTv
}).FirstOrDefault();
}
- if (program != null)
+ if (program is not null)
{
var image = program.GetImageInfo(ImageType.Primary, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -334,10 +334,10 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0)
+ if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0)
{
image = program.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -460,7 +460,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var channel = _libraryManager.GetItemById(dto.ChannelId);
- if (channel != null)
+ if (channel is not null)
{
info.ChannelId = channel.ExternalId;
}
@@ -470,7 +470,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var program = _libraryManager.GetItemById(dto.ProgramId);
- if (program != null)
+ if (program is not null)
{
info.ProgramId = program.ExternalId;
}
@@ -480,7 +480,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var timer = await liveTv.GetSeriesTimer(dto.SeriesTimerId, cancellationToken).ConfigureAwait(false);
- if (timer != null)
+ if (timer is not null)
{
info.SeriesTimerId = timer.ExternalId;
}
@@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var channel = _libraryManager.GetItemById(dto.ChannelId);
- if (channel != null)
+ if (channel is not null)
{
info.ChannelId = channel.ExternalId;
}
@@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var program = _libraryManager.GetItemById(dto.ProgramId);
- if (program != null)
+ if (program is not null)
{
info.ProgramId = program.ExternalId;
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 97c2e6e30..7afc7959c 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -434,7 +434,7 @@ namespace Emby.Server.Implementations.LiveTv
var item = _libraryManager.GetItemById(id) as LiveTvChannel;
- if (item == null)
+ if (item is null)
{
item = new LiveTvChannel
{
@@ -446,7 +446,7 @@ namespace Emby.Server.Implementations.LiveTv
isNew = true;
}
- if (channelInfo.Tags != null)
+ if (channelInfo.Tags is not null)
{
if (!channelInfo.Tags.SequenceEqual(item.Tags, StringComparer.OrdinalIgnoreCase))
{
@@ -836,7 +836,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false);
var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.Id).ToString("N", CultureInfo.InvariantCulture), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
- if (seriesTimer != null)
+ if (seriesTimer is not null)
{
internalQuery.ExternalSeriesId = seriesTimer.SeriesId;
@@ -948,7 +948,7 @@ namespace Emby.Server.Implementations.LiveTv
var channel = _libraryManager.GetItemById(program.ChannelId);
- if (channel == null)
+ if (channel is null)
{
return score;
}
@@ -989,7 +989,7 @@ namespace Emby.Server.Implementations.LiveTv
var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, externalProgramId, StringComparison.OrdinalIgnoreCase));
var foundSeriesTimer = false;
- if (timer != null)
+ if (timer is not null)
{
if (timer.Status != RecordingStatus.Cancelled && timer.Status != RecordingStatus.Error)
{
@@ -1016,7 +1016,7 @@ namespace Emby.Server.Implementations.LiveTv
var seriesTimer = seriesTimerList.FirstOrDefault(i => string.Equals(i.SeriesId, externalSeriesId, StringComparison.OrdinalIgnoreCase));
- if (seriesTimer != null)
+ if (seriesTimer is not null)
{
program.SeriesTimerId = _tvDtoService.GetInternalSeriesTimerId(seriesTimer.Id)
.ToString("N", CultureInfo.InvariantCulture);
@@ -1086,7 +1086,7 @@ namespace Emby.Server.Implementations.LiveTv
var coreService = _services.OfType<EmbyTV.EmbyTV>().FirstOrDefault();
- if (coreService != null)
+ if (coreService is not null)
{
await coreService.RefreshSeriesTimers(cancellationToken).ConfigureAwait(false);
await coreService.RefreshTimers(cancellationToken).ConfigureAwait(false);
@@ -1280,7 +1280,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var item = _libraryManager.GetItemById(itemId);
- if (item != null)
+ if (item is not null)
{
_libraryManager.DeleteItem(
item,
@@ -1314,7 +1314,7 @@ namespace Emby.Server.Implementations.LiveTv
private QueryResult<BaseItem> GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, User user)
{
- if (user == null)
+ if (user is null)
{
return new QueryResult<BaseItem>();
}
@@ -1377,7 +1377,7 @@ namespace Emby.Server.Implementations.LiveTv
limit = null;
// var allActivePaths = EmbyTV.EmbyTV.Current.GetAllActiveRecordings().Select(i => i.Path).ToArray();
- // var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i != null).ToArray();
+ // var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i is not null).ToArray();
// return new QueryResult<BaseItem>
// {
@@ -1517,7 +1517,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.CompletionPercentage = pct;
}
- if (channel != null)
+ if (channel is not null)
{
dto.ChannelName = channel.Name;
@@ -1702,7 +1702,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var timer = await GetTimer(id, CancellationToken.None).ConfigureAwait(false);
- if (timer == null)
+ if (timer is null)
{
throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "Timer with Id {0} not found", id));
}
@@ -1721,7 +1721,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var timer = await GetSeriesTimer(id, CancellationToken.None).ConfigureAwait(false);
- if (timer == null)
+ if (timer is null)
{
throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "SeriesTimer with Id {0} not found", id));
}
@@ -1834,7 +1834,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var internalChannelId = _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId);
var channel = _libraryManager.GetItemById(internalChannelId);
- channelName = channel == null ? null : channel.Name;
+ channelName = channel is null ? null : channel.Name;
}
return _tvDtoService.GetSeriesTimerInfoDto(i.Item1, i.Item2, channelName);
@@ -1887,7 +1887,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var currentProgram = programs.FirstOrDefault(i => channel.Id.Equals(i.ChannelId));
- if (currentProgram != null)
+ if (currentProgram is not null)
{
currentProgramsList.Add(currentProgram);
}
@@ -1913,7 +1913,7 @@ namespace Emby.Server.Implementations.LiveTv
ILiveTvService service = null;
ProgramInfo programInfo = null;
- if (program != null)
+ if (program is not null)
{
service = GetService(program);
@@ -2147,7 +2147,7 @@ namespace Emby.Server.Implementations.LiveTv
var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), parts[0], StringComparison.OrdinalIgnoreCase));
- if (service == null)
+ if (service is null)
{
throw new ArgumentException("Service not found.");
}
@@ -2178,7 +2178,7 @@ namespace Emby.Server.Implementations.LiveTv
var provider = _tunerHosts.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException();
}
@@ -2222,7 +2222,7 @@ namespace Emby.Server.Implementations.LiveTv
var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException(
string.Format(
@@ -2317,7 +2317,7 @@ namespace Emby.Server.Implementations.LiveTv
var providerChannel = EmbyTV.EmbyTV.Current.GetEpgChannelFromTunerChannel(mappings, tunerChannel, providerChannels);
- if (providerChannel != null)
+ if (providerChannel is not null)
{
result.ProviderChannelName = providerChannel.Name;
result.ProviderChannelId = providerChannel.Id;
@@ -2334,7 +2334,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var provider = _listingProviders.FirstOrDefault(i => string.Equals(providerType, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException();
}
@@ -2347,7 +2347,7 @@ namespace Emby.Server.Implementations.LiveTv
var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException();
}
@@ -2390,7 +2390,7 @@ namespace Emby.Server.Implementations.LiveTv
.SelectMany(i => i.Locations)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i => _libraryManager.FindByPath(i, true))
- .Where(i => i != null && i.IsVisibleStandalone(user))
+ .Where(i => i is not null && i.IsVisibleStandalone(user))
.SelectMany(i => _libraryManager.GetCollectionFolders(i))
.GroupBy(x => x.Id)
.Select(x => x.First())
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
index 4b7584af3..6a92fc599 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var activeRecordingInfo = _liveTvManager.GetActiveRecordingInfo(item.Path);
- if (string.IsNullOrEmpty(item.Path) || activeRecordingInfo != null)
+ if (string.IsNullOrEmpty(item.Path) || activeRecordingInfo is not null)
{
return GetMediaSourcesInternal(item, activeRecordingInfo, cancellationToken);
}
@@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.LiveTv
try
{
- if (activeRecordingInfo != null)
+ if (activeRecordingInfo is not null)
{
sources = await EmbyTV.EmbyTV.Current.GetRecordingStreamMediaSources(activeRecordingInfo, cancellationToken)
.ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
index 2b82f2462..7b6c8b80a 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
@@ -131,10 +131,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
if (IsValidChannelId(channelId))
{
@@ -147,7 +144,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false);
var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase));
- if (channelInfo != null)
+ if (channelInfo is not null)
{
return await GetChannelStreamMediaSources(host, channelInfo, cancellationToken).ConfigureAwait(false);
}
@@ -166,10 +163,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<ILiveStream> GetChannelStream(string channelId, string streamId, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
if (!IsValidChannelId(channelId))
{
@@ -187,7 +181,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false);
var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase));
- if (channelInfo != null)
+ if (channelInfo is not null)
{
hostsWithChannel.Add(new Tuple<TunerHostInfo, ChannelInfo>(host, channelInfo));
}
@@ -223,10 +217,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
protected virtual bool IsValidChannelId(string channelId)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
index e0eaa8e58..5327b3d74 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
@@ -302,7 +302,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var hdHomerunChannelInfo = channels.FirstOrDefault() as HdHomerunChannelInfo;
- if (hdHomerunChannelInfo == null || hdHomerunChannelInfo.IsLegacyTuner)
+ if (hdHomerunChannelInfo is null || hdHomerunChannelInfo.IsLegacyTuner)
{
return await GetTunerInfosUdp(info, cancellationToken).ConfigureAwait(false);
}
@@ -503,7 +503,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var modelInfo = await GetModelInfo(tuner, false, cancellationToken).ConfigureAwait(false);
- if (modelInfo != null && modelInfo.SupportsTranscoding)
+ if (modelInfo is not null && modelInfo.SupportsTranscoding)
{
if (tuner.AllowHWTranscoding)
{
@@ -560,7 +560,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var mediaSource = GetMediaSource(tunerHost, hdhrId, channel, profile);
- if (hdhomerunChannel != null && hdhomerunChannel.IsLegacyTuner)
+ if (hdhomerunChannel is not null && hdhomerunChannel.IsLegacyTuner)
{
return new HdHomerunUdpStream(
mediaSource,
@@ -674,7 +674,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var info = await TryGetTunerHostInfo(deviceAddress, cancellationToken).ConfigureAwait(false);
- if (info != null)
+ if (info is not null)
{
list.Add(info);
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
index e67b5846a..81eb083f6 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
@@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
using (var socket = _tcpClient)
{
- if (socket != null)
+ if (socket is not null)
{
_tcpClient = null;
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
index 2748794b3..3ae9e256b 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
@@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
EnableStreamSharing = true;
UniqueId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
- if (tuner != null)
+ if (tuner is not null)
{
TunerHostId = tuner.Id;
}
diff --git a/Emby.Server.Implementations/Localization/Core/da.json b/Emby.Server.Implementations/Localization/Core/da.json
index 34655ace6..0d0d0c813 100644
--- a/Emby.Server.Implementations/Localization/Core/da.json
+++ b/Emby.Server.Implementations/Localization/Core/da.json
@@ -15,8 +15,8 @@
"Favorites": "Favoritter",
"Folders": "Mapper",
"Genres": "Genrer",
- "HeaderAlbumArtists": "Kunstnerens album",
- "HeaderContinueWatching": "Fortsæt Afspilning",
+ "HeaderAlbumArtists": "Albumkunstner",
+ "HeaderContinueWatching": "Fortsæt afspilning",
"HeaderFavoriteAlbums": "Favoritalbummer",
"HeaderFavoriteArtists": "Favoritkunstnere",
"HeaderFavoriteEpisodes": "Favoritepisoder",
@@ -42,7 +42,7 @@
"MusicVideos": "Musik videoer",
"NameInstallFailed": "{0} installationen mislykkedes",
"NameSeasonNumber": "Sæson {0}",
- "NameSeasonUnknown": "Ukendt Sæson",
+ "NameSeasonUnknown": "Ukendt sæson",
"NewVersionIsAvailable": "En ny version af Jellyfin Server er tilgængelig til download.",
"NotificationOptionApplicationUpdateAvailable": "Opdatering til applikation tilgængelig",
"NotificationOptionApplicationUpdateInstalled": "Opdatering til applikation installeret",
@@ -77,7 +77,7 @@
"SubtitleDownloadFailureFromForItem": "Undertekster kunne ikke downloades fra {0} til {1}",
"Sync": "Synk",
"System": "System",
- "TvShows": "TV serier",
+ "TvShows": "Tv-serier",
"User": "Bruger",
"UserCreatedWithName": "Bruger {0} er blevet oprettet",
"UserDeletedWithName": "Brugeren {0} er blevet slettet",
diff --git a/Emby.Server.Implementations/Localization/Core/ka.json b/Emby.Server.Implementations/Localization/Core/ka.json
index 78cfda3bd..3a8b89f44 100644
--- a/Emby.Server.Implementations/Localization/Core/ka.json
+++ b/Emby.Server.Implementations/Localization/Core/ka.json
@@ -27,5 +27,86 @@
"TasksLibraryCategory": "ბიბლიოთეკა",
"ChapterNameValue": "თავი {0}",
"HeaderContinueWatching": "ყურების გაგრძელება",
- "HeaderFavoriteArtists": "რჩეული შემსრულებლები"
+ "HeaderFavoriteArtists": "რჩეული შემსრულებლები",
+ "DeviceOfflineWithName": "{0} გაითიშა",
+ "External": "გარე",
+ "HeaderFavoriteEpisodes": "რჩეული ეპიზოდები",
+ "HeaderFavoriteSongs": "რჩეული სიმღერები",
+ "HeaderRecordingGroups": "ჩამწერი ჯგუფები",
+ "HearingImpaired": "სმენადაქვეითებული",
+ "LabelRunningTimeValue": "გაშვებულობის დრო: {0}",
+ "MessageApplicationUpdatedTo": "Jellyfin-ის სერვერი განახლდა {0}-ზე",
+ "MessageNamedServerConfigurationUpdatedWithValue": "სერვერის კონფიგურაციის სექცია {0} განახლდა",
+ "MixedContent": "შერეული შემცველობა",
+ "MusicVideos": "მუსიკის ვიდეოები",
+ "NotificationOptionInstallationFailed": "დაყენების შეცდომა",
+ "NotificationOptionApplicationUpdateInstalled": "აპლიკაციის განახლება დაყენებულია",
+ "NotificationOptionAudioPlayback": "აუდიოს დაკვრა დაწყებულია",
+ "NotificationOptionCameraImageUploaded": "კამერის გამოსახულება ატვირთულია",
+ "NotificationOptionVideoPlaybackStopped": "ვიდეოს დაკვრა გაჩერებულია",
+ "PluginUninstalledWithName": "{0} წაიშალა",
+ "ScheduledTaskStartedWithName": "{0} გაეშვა",
+ "VersionNumber": "ვერსია {0}",
+ "TasksChannelsCategory": "ინტერნეტ-არხები",
+ "ValueSpecialEpisodeName": "სპეციალური - {0}",
+ "TaskRefreshChannelsDescription": "ინტერნეტ-არხის ინფორმაციის განახლება.",
+ "Channels": "არხები",
+ "Collections": "კოლექციები",
+ "Default": "ნაგულისხმები",
+ "Favorites": "რჩეულები",
+ "Folders": "საქაღალდეები",
+ "HeaderFavoriteShows": "რჩეული სერიალები",
+ "HeaderLiveTV": "ცოცხალი TV",
+ "HeaderNextUp": "შემდეგი ზემოთ",
+ "HomeVideos": "სახლის ვიდეოები",
+ "NameSeasonNumber": "სეზონი {0}",
+ "NameSeasonUnknown": "სეზონი უცნობია",
+ "NotificationOptionPluginError": "დამატების შეცდომა",
+ "NotificationOptionPluginInstalled": "დამატება დაყენებულია",
+ "NotificationOptionPluginUninstalled": "დამატება წაიშალა",
+ "ProviderValue": "მომწოდებელი: {0}",
+ "ScheduledTaskFailedWithName": "{0} ავარიულია",
+ "TvShows": "TV სერიალები",
+ "TaskRefreshPeople": "ხალხის განახლება",
+ "TaskUpdatePlugins": "დამატებების განახლება",
+ "TaskRefreshChannels": "არხების განახლება",
+ "TaskOptimizeDatabase": "ბაზების ოპტიმიზაცია",
+ "TaskKeyframeExtractor": "საკვანძო კადრის გამომღები",
+ "DeviceOnlineWithName": "{0} შეერთებულია",
+ "LabelIpAddressValue": "IP მისამართი: {0}",
+ "NameInstallFailed": "{0}-ის დაყენების შეცდომა",
+ "NotificationOptionApplicationUpdateAvailable": "ხელმისაწვდომია აპლიკაციის განახლება",
+ "NotificationOptionAudioPlaybackStopped": "აუდიოს დაკვრა გაჩერებულია",
+ "NotificationOptionNewLibraryContent": "ახალი შემცველობა დამატებულია",
+ "NotificationOptionPluginUpdateInstalled": "დამატების განახლება დაყენებულია",
+ "NotificationOptionServerRestartRequired": "სერვერის გადატვირთვა აუცილებელია",
+ "NotificationOptionTaskFailed": "დაგეგმილი ამოცანის შეცდომა",
+ "NotificationOptionUserLockedOut": "მომხმარებელი დაიბლოკა",
+ "NotificationOptionVideoPlayback": "ვიდეოს დაკვრა დაწყებულია",
+ "PluginInstalledWithName": "{0} დაყენებულია",
+ "PluginUpdatedWithName": "{0} განახლდა",
+ "TaskCleanActivityLog": "აქტივობების ჟურნალის გასუფთავება",
+ "TaskCleanCache": "ქეშის საქაღალდის გასუფთავება",
+ "TaskRefreshChapterImages": "თავის სურათების გაშლა",
+ "TaskRefreshLibrary": "მედიის ბიბლიოთეკის სკანირება",
+ "TaskCleanLogs": "ჟურნალის საქაღალდის გასუფთავება",
+ "TaskCleanTranscode": "ტრანსკოდირების საქაღალდის გასუფთავება",
+ "TaskDownloadMissingSubtitles": "ნაკლული სუბტიტრების გადმოწერა",
+ "UserDownloadingItemWithValues": "{0} -ი {0}-ს იწერს",
+ "FailedLoginAttemptWithUserName": "{0}-დან შემოსვლის შეცდომა",
+ "MessageApplicationUpdated": "Jellyfin-ის სერვერი განახლდა",
+ "MessageServerConfigurationUpdated": "სერვერის კონფიგურაცია განახლდა",
+ "ServerNameNeedsToBeRestarted": "საჭიროა {0}-ის გადატვირთვა",
+ "UserCreatedWithName": "მომხმარებელი {0} შეიქმნა",
+ "UserDeletedWithName": "მომხმარებელი {0} წაშლილია",
+ "UserOnlineFromDevice": "{0}-ი ხაზზეა {1}-დან",
+ "UserOfflineFromDevice": "{0}-ი {1}-დან გაითიშა",
+ "ItemAddedWithName": "{0} ჩამატებულია ბიბლიოთეკაში",
+ "ItemRemovedWithName": "{0} წაშლილია ბიბლიოთეკიდან",
+ "UserLockedOutWithName": "მომხმარებელი {0} დაბლოკილია",
+ "UserStartedPlayingItemWithValues": "{0} თამაშობს {1}-ს {2}-ზე",
+ "UserPasswordChangedWithName": "მომხმარებლისთვის {0} პაროლი შეცვლილია",
+ "UserPolicyUpdatedWithName": "{0}-ის მომხმარებლის პოლიტიკა განახლდა",
+ "UserStoppedPlayingItemWithValues": "{0}-მა დაამთავრა {1}-ის დაკვრა {2}-ზე",
+ "TaskRefreshChapterImagesDescription": "თავების მქონე ვიდეოებისთვის მინიატურების შექმნა."
}
diff --git a/Emby.Server.Implementations/Localization/Core/sv.json b/Emby.Server.Implementations/Localization/Core/sv.json
index af5db1976..318a0f3cf 100644
--- a/Emby.Server.Implementations/Localization/Core/sv.json
+++ b/Emby.Server.Implementations/Localization/Core/sv.json
@@ -123,5 +123,6 @@
"TaskOptimizeDatabaseDescription": "Komprimerar databasen och trunkerar ledigt utrymme. Prestandan kan förbättras genom att köra denna aktivitet efter att du har skannat biblioteket eller gjort andra förändringar som indikerar att databasen har modifierats.",
"TaskKeyframeExtractorDescription": "Exporterar nyckelbildrutor från videofiler för att skapa mer exakta HLS-spellistor. Denna rutin kan ta lång tid.",
"TaskKeyframeExtractor": "Extraktor för nyckelbildrutor",
- "External": "Extern"
+ "External": "Extern",
+ "HearingImpaired": "Hörselskadad"
}
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index b77168126..b418c7877 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -219,10 +219,7 @@ namespace Emby.Server.Implementations.Localization
/// <inheritdoc />
public int? GetRatingLevel(string rating)
{
- if (string.IsNullOrEmpty(rating))
- {
- throw new ArgumentNullException(nameof(rating));
- }
+ ArgumentException.ThrowIfNullOrEmpty(rating);
if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
@@ -295,10 +292,7 @@ namespace Emby.Server.Implementations.Localization
private Dictionary<string, string> GetLocalizationDictionary(string culture)
{
- if (string.IsNullOrEmpty(culture))
- {
- throw new ArgumentNullException(nameof(culture));
- }
+ ArgumentException.ThrowIfNullOrEmpty(culture);
const string Prefix = "Core";
@@ -310,10 +304,7 @@ namespace Emby.Server.Implementations.Localization
private async Task<Dictionary<string, string>> GetDictionary(string prefix, string culture, string baseFilename)
{
- if (string.IsNullOrEmpty(culture))
- {
- throw new ArgumentNullException(nameof(culture));
- }
+ ArgumentException.ThrowIfNullOrEmpty(culture);
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@@ -329,14 +320,14 @@ namespace Emby.Server.Implementations.Localization
{
await using var stream = _assembly.GetManifestResourceStream(resourcePath);
// If a Culture doesn't have a translation the stream will be null and it defaults to en-us further up the chain
- if (stream == null)
+ if (stream is null)
{
_logger.LogError("Missing translation/culture resource: {ResourcePath}", resourcePath);
return;
}
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(stream, _jsonOptions).ConfigureAwait(false);
- if (dict == null)
+ if (dict is null)
{
throw new InvalidOperationException($"Resource contains invalid data: '{stream}'");
}
diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
index 6e1dc725d..9fe51f083 100644
--- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
+++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.MediaEncoder
}
var libraryOptions = _libraryManager.GetLibraryOptions(video);
- if (libraryOptions != null)
+ if (libraryOptions is not null)
{
if (!libraryOptions.EnableChapterImageExtraction)
{
diff --git a/Emby.Server.Implementations/Net/UdpSocket.cs b/Emby.Server.Implementations/Net/UdpSocket.cs
index c3994fc04..577b79283 100644
--- a/Emby.Server.Implementations/Net/UdpSocket.cs
+++ b/Emby.Server.Implementations/Net/UdpSocket.cs
@@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Net
private void OnReceiveSocketAsyncEventArgsCompleted(object sender, SocketAsyncEventArgs e)
{
var tcs = _currentReceiveTaskCompletionSource;
- if (tcs != null)
+ if (tcs is not null)
{
_currentReceiveTaskCompletionSource = null;
@@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.Net
private void OnSendSocketAsyncEventArgsCompleted(object sender, SocketAsyncEventArgs e)
{
var tcs = _currentSendTaskCompletionSource;
- if (tcs != null)
+ if (tcs is not null)
{
_currentSendTaskCompletionSource = null;
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
index 9e7035cb3..2717c392b 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Playlists
var folderName = _fileSystem.GetValidFilename(name);
var parentFolder = GetPlaylistsFolder(Guid.Empty);
- if (parentFolder == null)
+ if (parentFolder is null)
{
throw new ArgumentException(nameof(parentFolder));
}
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Playlists
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
throw new ArgumentException("No item exists with the supplied Id");
}
@@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Playlists
private List<BaseItem> GetPlaylistItems(IEnumerable<Guid> itemIds, string playlistMediaType, User user, DtoOptions options)
{
- var items = itemIds.Select(i => _libraryManager.GetItemById(i)).Where(i => i != null);
+ var items = itemIds.Select(i => _libraryManager.GetItemById(i)).Where(i => i is not null);
return Playlist.GetPlaylistItems(playlistMediaType, items, user, options);
}
@@ -502,15 +502,8 @@ namespace Emby.Server.Implementations.Playlists
private static string MakeRelativePath(string folderPath, string fileAbsolutePath)
{
- if (string.IsNullOrEmpty(folderPath))
- {
- throw new ArgumentException("Folder path was null or empty.", nameof(folderPath));
- }
-
- if (string.IsNullOrEmpty(fileAbsolutePath))
- {
- throw new ArgumentException("File absolute path was null or empty.", nameof(fileAbsolutePath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(folderPath);
+ ArgumentException.ThrowIfNullOrEmpty(fileAbsolutePath);
if (!folderPath.EndsWith(Path.DirectorySeparatorChar))
{
diff --git a/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs b/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs
index 8ec9f6161..e2f2e436f 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs
@@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Playlists
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
{
- if (query.User == null)
+ if (query.User is null)
{
query.Recursive = false;
return base.GetItemsInternal(query);
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index 3f7d46822..14e7c2269 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Plugins
foreach (var pluginServiceRegistrator in _appHost.GetExportTypes<IPluginServiceRegistrator>())
{
var plugin = GetPluginByAssembly(pluginServiceRegistrator.Assembly);
- if (plugin == null)
+ if (plugin is null)
{
_logger.LogError("Unable to find plugin in assembly {Assembly}", pluginServiceRegistrator.Assembly.FullName);
continue;
@@ -210,10 +210,7 @@ namespace Emby.Server.Implementations.Plugins
/// <param name="folder">Folder of the plugin.</param>
public void ImportPluginFrom(string folder)
{
- if (string.IsNullOrEmpty(folder))
- {
- throw new ArgumentNullException(nameof(folder));
- }
+ ArgumentException.ThrowIfNullOrEmpty(folder);
// Load the plugin.
var plugin = LoadManifest(folder);
@@ -263,12 +260,12 @@ namespace Emby.Server.Implementations.Plugins
{
LocalPlugin? plugin;
- if (version == null)
+ if (version is null)
{
// If no version is given, return the current instance.
var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
- plugin = plugins.FirstOrDefault(p => p.Instance != null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
+ plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
}
else
{
@@ -320,7 +317,7 @@ namespace Emby.Server.Implementations.Plugins
ArgumentNullException.ThrowIfNull(assembly);
var plugin = _plugins.FirstOrDefault(p => p.DllFiles.Contains(assembly.Location));
- if (plugin == null)
+ if (plugin is null)
{
// A plugin's assembly didn't cause this issue, so ignore it.
return;
@@ -442,7 +439,7 @@ namespace Emby.Server.Implementations.Plugins
_logger.LogDebug("Creating instance of {Type}", type);
// _appHost.ServiceProvider is already assigned when we create the plugins
var instance = (IPlugin)ActivatorUtilities.CreateInstance(_appHost.ServiceProvider!, type);
- if (plugin == null)
+ if (plugin is null)
{
// Create a dummy record for the providers.
// TODO: remove this code once all provided have been released as separate plugins.
@@ -500,7 +497,7 @@ namespace Emby.Server.Implementations.Plugins
#pragma warning restore CA1031 // Do not catch general exception types
{
_logger.LogError(ex, "Error creating {Type}", type.FullName);
- if (plugin != null)
+ if (plugin is not null)
{
if (ChangePluginState(plugin, PluginStatus.Malfunctioned))
{
@@ -523,7 +520,7 @@ namespace Emby.Server.Implementations.Plugins
var predecessor = _plugins.OrderByDescending(p => p.Version)
.FirstOrDefault(p => p.Id.Equals(plugin.Id) && p.IsEnabledAndSupported && p.Version != plugin.Version);
- if (predecessor != null)
+ if (predecessor is not null)
{
return;
}
@@ -577,7 +574,7 @@ namespace Emby.Server.Implementations.Plugins
_logger.LogError(ex, "Error deserializing {Json}.", Encoding.UTF8.GetString(data!));
}
- if (manifest != null)
+ if (manifest is not null)
{
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
{
@@ -711,7 +708,7 @@ namespace Emby.Server.Implementations.Plugins
&& p.IsEnabledAndSupported
&& p.Version != plugin.Version);
- if (previousVersion == null)
+ if (previousVersion is null)
{
// This value is memory only - so that the web will show restart required.
plugin.Manifest.Status = PluginStatus.Restart;
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index 532c8d1e3..c4bda9637 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -71,25 +71,10 @@ namespace Emby.Server.Implementations.QuickConnect
/// <inheritdoc/>
public QuickConnectResult TryConnect(AuthorizationInfo authorizationInfo)
{
- if (string.IsNullOrEmpty(authorizationInfo.DeviceId))
- {
- throw new ArgumentException(nameof(authorizationInfo.DeviceId) + " is required");
- }
-
- if (string.IsNullOrEmpty(authorizationInfo.Device))
- {
- throw new ArgumentException(nameof(authorizationInfo.Device) + " is required");
- }
-
- if (string.IsNullOrEmpty(authorizationInfo.Client))
- {
- throw new ArgumentException(nameof(authorizationInfo.Client) + " is required");
- }
-
- if (string.IsNullOrEmpty(authorizationInfo.Version))
- {
- throw new ArgumentException(nameof(authorizationInfo.Version) + "is required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.DeviceId);
+ ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.Device);
+ ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.Client);
+ ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.Version);
AssertActive();
ExpireRequests();
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index b370e06ef..ee9aa8569 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
lock (_lastExecutionResultSyncLock)
{
- if (_lastExecutionResult == null && !_readFromFile)
+ if (_lastExecutionResult is null && !_readFromFile)
{
if (File.Exists(path))
{
@@ -211,7 +211,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
get
{
- if (CurrentCancellationTokenSource != null)
+ if (CurrentCancellationTokenSource is not null)
{
return CurrentCancellationTokenSource.IsCancellationRequested
? TaskState.Cancelling
@@ -240,7 +240,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
ArgumentNullException.ThrowIfNull(value);
// Cleanup current triggers
- if (_triggers != null)
+ if (_triggers is not null)
{
DisposeTriggers();
}
@@ -269,7 +269,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
ArgumentNullException.ThrowIfNull(value);
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
- var triggerList = value.Where(i => i != null).ToArray();
+ var triggerList = value.Where(i => i is not null).ToArray();
SaveTriggers(triggerList);
@@ -369,7 +369,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
private async Task ExecuteInternal(TaskOptions options)
{
// Cancel the current execution, if any
- if (CurrentCancellationTokenSource != null)
+ if (CurrentCancellationTokenSource is not null)
{
throw new InvalidOperationException("Cannot execute a Task that is already running");
}
@@ -391,7 +391,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
try
{
- if (options != null && options.MaxRuntimeTicks.HasValue)
+ if (options is not null && options.MaxRuntimeTicks.HasValue)
{
CurrentCancellationTokenSource.CancelAfter(TimeSpan.FromTicks(options.MaxRuntimeTicks.Value));
}
@@ -507,7 +507,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
private Tuple<TaskTriggerInfo, ITaskTrigger>[] LoadTriggers()
{
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
- var settings = LoadTriggerSettings().Where(i => i != null).ToArray();
+ var settings = LoadTriggerSettings().Where(i => i is not null).ToArray();
return settings.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
}
@@ -583,7 +583,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
result.Key = ScheduledTask.Key;
- if (ex != null)
+ if (ex is not null)
{
result.ErrorMessage = ex.Message;
result.LongErrorMessage = ex.StackTrace;
@@ -617,7 +617,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
var startTime = CurrentExecutionStartTime;
var token = CurrentCancellationTokenSource;
- if (token != null)
+ if (token is not null)
{
try
{
@@ -631,7 +631,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
}
var task = _currentTask;
- if (task != null)
+ if (task is not null)
{
try
{
@@ -653,7 +653,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
}
}
- if (token != null)
+ if (token is not null)
{
try
{
diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
index 0431858fc..63f0beb10 100644
--- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
@@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T));
- if (scheduledTask == null)
+ if (scheduledTask is null)
{
_logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", typeof(T).Name);
}
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T));
- if (scheduledTask == null)
+ if (scheduledTask is null)
{
_logger.LogError("Unable to find scheduled task of type {0} in Execute.", typeof(T).Name);
}
@@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType());
- if (scheduledTask == null)
+ if (scheduledTask is null)
{
_logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", task.GetType().Name);
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
index da7c8732a..abc203618 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
@@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
previouslyFailedImages.Add(key);
var parentPath = Path.GetDirectoryName(failHistoryPath);
- if (parentPath != null)
+ if (parentPath is not null)
{
Directory.CreateDirectory(parentPath);
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs
index 3eb800199..d65ac2e5e 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs
@@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
DateTime triggerDate;
- if (lastResult == null)
+ if (lastResult is null)
{
// Task has never been completed before
triggerDate = DateTime.UtcNow.AddHours(1);
@@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
{
DisposeTimer();
- if (Triggered != null)
+ if (Triggered is not null)
{
_lastStartDate = DateTime.UtcNow;
Triggered(this, EventArgs.Empty);
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 0d1029882..2f60d01a9 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -200,7 +200,7 @@ namespace Emby.Server.Implementations.Session
{
var capabilities = _deviceManager.GetCapabilities(info.DeviceId);
- if (capabilities != null)
+ if (capabilities is not null)
{
ReportCapabilities(info, capabilities, false);
}
@@ -238,7 +238,7 @@ namespace Emby.Server.Implementations.Session
public void UpdateDeviceName(string sessionId, string reportedDeviceName)
{
var session = GetSession(sessionId);
- if (session != null)
+ if (session is not null)
{
session.DeviceName = reportedDeviceName;
}
@@ -264,27 +264,16 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (string.IsNullOrEmpty(appName))
- {
- throw new ArgumentNullException(nameof(appName));
- }
-
- if (string.IsNullOrEmpty(appVersion))
- {
- throw new ArgumentNullException(nameof(appVersion));
- }
-
- if (string.IsNullOrEmpty(deviceId))
- {
- throw new ArgumentNullException(nameof(deviceId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(appName);
+ ArgumentException.ThrowIfNullOrEmpty(appVersion);
+ ArgumentException.ThrowIfNullOrEmpty(deviceId);
var activityDate = DateTime.UtcNow;
var session = await GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false);
var lastActivityDate = session.LastActivityDate;
session.LastActivityDate = activityDate;
- if (user != null)
+ if (user is not null)
{
var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
@@ -351,7 +340,7 @@ namespace Emby.Server.Implementations.Session
CheckDisposed();
var session = GetSession(sessionId, false);
- if (session != null)
+ if (session is not null)
{
var key = GetSessionKey(session.Client, session.DeviceId);
@@ -377,11 +366,11 @@ namespace Emby.Server.Implementations.Session
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
}
- if (!info.ItemId.Equals(default) && info.Item == null && libraryItem != null)
+ if (!info.ItemId.Equals(default) && info.Item is null && libraryItem is not null)
{
var current = session.NowPlayingItem;
- if (current == null || !info.ItemId.Equals(current.Id))
+ if (current is null || !info.ItemId.Equals(current.Id))
{
var runtimeTicks = libraryItem.RunTimeTicks;
@@ -390,7 +379,7 @@ namespace Emby.Server.Implementations.Session
{
mediaSource = await GetMediaSource(libraryItem, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false);
- if (mediaSource != null)
+ if (mediaSource is not null)
{
runtimeTicks = mediaSource.RunTimeTicks;
}
@@ -478,10 +467,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (string.IsNullOrEmpty(deviceId))
- {
- throw new ArgumentNullException(nameof(deviceId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(deviceId);
var key = GetSessionKey(appName, deviceId);
@@ -495,7 +481,7 @@ namespace Emby.Server.Implementations.Session
sessionInfo.UserId = user?.Id ?? Guid.Empty;
sessionInfo.UserName = user?.Username;
- sessionInfo.UserPrimaryImageTag = user?.ProfileImage == null ? null : GetImageCacheTag(user);
+ sessionInfo.UserPrimaryImageTag = user?.ProfileImage is null ? null : GetImageCacheTag(user);
sessionInfo.RemoteEndPoint = remoteEndPoint;
sessionInfo.Client = appName;
@@ -506,7 +492,7 @@ namespace Emby.Server.Implementations.Session
sessionInfo.ApplicationVersion = appVersion;
- if (user == null)
+ if (user is null)
{
sessionInfo.AdditionalUsers = Array.Empty<SessionUserInfo>();
}
@@ -536,7 +522,7 @@ namespace Emby.Server.Implementations.Session
sessionInfo.UserId = user?.Id ?? Guid.Empty;
sessionInfo.UserName = username;
- sessionInfo.UserPrimaryImageTag = user?.ProfileImage == null ? null : GetImageCacheTag(user);
+ sessionInfo.UserPrimaryImageTag = user?.ProfileImage is null ? null : GetImageCacheTag(user);
sessionInfo.RemoteEndPoint = remoteEndPoint;
if (string.IsNullOrEmpty(deviceName))
@@ -570,7 +556,7 @@ namespace Emby.Server.Implementations.Session
var user = _userManager.GetUserById(session.UserId);
- if (user == null)
+ if (user is null)
{
throw new InvalidOperationException("User not found");
}
@@ -579,7 +565,7 @@ namespace Emby.Server.Implementations.Session
users.AddRange(session.AdditionalUsers
.Select(i => _userManager.GetUserById(i.UserId))
- .Where(i => i != null));
+ .Where(i => i is not null));
return users;
}
@@ -591,7 +577,7 @@ namespace Emby.Server.Implementations.Session
private void StopIdleCheckTimer()
{
- if (_idleTimer != null)
+ if (_idleTimer is not null)
{
_idleTimer.Dispose();
_idleTimer = null;
@@ -600,7 +586,7 @@ namespace Emby.Server.Implementations.Session
private async void CheckForIdlePlayback(object state)
{
- var playingSessions = Sessions.Where(i => i.NowPlayingItem != null)
+ var playingSessions = Sessions.Where(i => i.NowPlayingItem is not null)
.ToList();
if (playingSessions.Count > 0)
@@ -618,7 +604,7 @@ namespace Emby.Server.Implementations.Session
await OnPlaybackStopped(new PlaybackStopInfo
{
Item = session.NowPlayingItem,
- ItemId = session.NowPlayingItem == null ? Guid.Empty : session.NowPlayingItem.Id,
+ ItemId = session.NowPlayingItem is null ? Guid.Empty : session.NowPlayingItem.Id,
SessionId = session.Id,
MediaSourceId = session.PlayState?.MediaSourceId,
PositionTicks = session.PlayState?.PositionTicks
@@ -630,7 +616,7 @@ namespace Emby.Server.Implementations.Session
}
}
- playingSessions = Sessions.Where(i => i.NowPlayingItem != null)
+ playingSessions = Sessions.Where(i => i.NowPlayingItem is not null)
.ToList();
}
@@ -643,7 +629,7 @@ namespace Emby.Server.Implementations.Session
private BaseItem GetNowPlayingItem(SessionInfo session, Guid itemId)
{
var item = session.FullNowPlayingItem;
- if (item != null && item.Id.Equals(itemId))
+ if (item is not null && item.Id.Equals(itemId))
{
return item;
}
@@ -684,7 +670,7 @@ namespace Emby.Server.Implementations.Session
var users = GetUsers(session);
- if (libraryItem != null)
+ if (libraryItem is not null)
{
foreach (var user in users)
{
@@ -777,7 +763,7 @@ namespace Emby.Server.Implementations.Session
var users = GetUsers(session);
// only update saved user data on actual check-ins, not automated ones
- if (libraryItem != null && !isAutomated)
+ if (libraryItem is not null && !isAutomated)
{
foreach (var user in users)
{
@@ -912,11 +898,11 @@ namespace Emby.Server.Implementations.Session
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
}
- if (!info.ItemId.Equals(default) && info.Item == null && libraryItem != null)
+ if (!info.ItemId.Equals(default) && info.Item is null && libraryItem is not null)
{
var current = session.NowPlayingItem;
- if (current == null || !info.ItemId.Equals(current.Id))
+ if (current is null || !info.ItemId.Equals(current.Id))
{
MediaSourceInfo mediaSource = null;
@@ -933,7 +919,7 @@ namespace Emby.Server.Implementations.Session
}
}
- if (info.Item != null)
+ if (info.Item is not null)
{
var msString = info.PositionTicks.HasValue ? (info.PositionTicks.Value / 10000).ToString(CultureInfo.InvariantCulture) : "unknown";
@@ -945,7 +931,7 @@ namespace Emby.Server.Implementations.Session
msString);
}
- if (info.NowPlayingQueue != null)
+ if (info.NowPlayingQueue is not null)
{
session.NowPlayingQueue = info.NowPlayingQueue;
}
@@ -957,7 +943,7 @@ namespace Emby.Server.Implementations.Session
var users = GetUsers(session);
var playedToCompletion = false;
- if (libraryItem != null)
+ if (libraryItem is not null)
{
foreach (var user in users)
{
@@ -1037,7 +1023,7 @@ namespace Emby.Server.Implementations.Session
private SessionInfo GetSession(string sessionId, bool throwOnMissing = true)
{
var session = Sessions.FirstOrDefault(i => string.Equals(i.Id, sessionId, StringComparison.Ordinal));
- if (session == null && throwOnMissing)
+ if (session is null && throwOnMissing)
{
throw new ResourceNotFoundException(
string.Format(CultureInfo.InvariantCulture, "Session {0} not found.", sessionId));
@@ -1051,7 +1037,7 @@ namespace Emby.Server.Implementations.Session
// Accept either device id or session id
var session = Sessions.FirstOrDefault(i => string.Equals(i.Id, sessionId, StringComparison.Ordinal));
- if (session == null)
+ if (session is null)
{
throw new ResourceNotFoundException(
string.Format(CultureInfo.InvariantCulture, "Session {0} not found.", sessionId));
@@ -1164,7 +1150,7 @@ namespace Emby.Server.Implementations.Session
command.ItemIds = items.Select(i => i.Id).ToArray();
- if (user != null)
+ if (user is not null)
{
if (items.Any(i => i.GetPlayAccess(user) != PlayAccess.Full))
{
@@ -1173,13 +1159,13 @@ namespace Emby.Server.Implementations.Session
}
}
- if (user != null
+ if (user is not null
&& command.ItemIds.Length == 1
&& user.EnableNextEpisodeAutoPlay
&& _libraryManager.GetItemById(command.ItemIds[0]) is Episode episode)
{
var series = episode.Series;
- if (series != null)
+ if (series is not null)
{
var episodes = series.GetEpisodes(
user,
@@ -1231,7 +1217,7 @@ namespace Emby.Server.Implementations.Session
{
var item = _libraryManager.GetItemById(id);
- if (item == null)
+ if (item is null)
{
_logger.LogError("A non-existent item Id {0} was passed into TranslateItemForPlayback", id);
return Array.Empty<BaseItem>();
@@ -1284,7 +1270,7 @@ namespace Emby.Server.Implementations.Session
{
var item = _libraryManager.GetItemById(id);
- if (item == null)
+ if (item is null)
{
_logger.LogError("A non-existent item Id {0} was passed into TranslateItemForInstantMix", id);
return new List<BaseItem>();
@@ -1429,7 +1415,7 @@ namespace Emby.Server.Implementations.Session
var user = session.AdditionalUsers.FirstOrDefault(i => i.UserId.Equals(userId));
- if (user != null)
+ if (user is not null)
{
var list = session.AdditionalUsers.ToList();
list.Remove(user);
@@ -1480,7 +1466,7 @@ namespace Emby.Server.Implementations.Session
true).ConfigureAwait(false);
}
- if (user == null)
+ if (user is null)
{
AuthenticationFailed?.Invoke(this, new GenericEventArgs<AuthenticationRequest>(request));
throw new AuthenticationException("Invalid username or password entered.");
@@ -1541,7 +1527,7 @@ namespace Emby.Server.Implementations.Session
foreach (var auth in allExistingForDevice)
{
- if (existing == null || !string.Equals(auth.AccessToken, existing.AccessToken, StringComparison.Ordinal))
+ if (existing is null || !string.Equals(auth.AccessToken, existing.AccessToken, StringComparison.Ordinal))
{
try
{
@@ -1554,7 +1540,7 @@ namespace Emby.Server.Implementations.Session
}
}
- if (existing != null)
+ if (existing is not null)
{
_logger.LogInformation("Reissuing access token: {Token}", existing.AccessToken);
return existing.AccessToken;
@@ -1571,10 +1557,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (string.IsNullOrEmpty(accessToken))
- {
- throw new ArgumentNullException(nameof(accessToken));
- }
+ ArgumentException.ThrowIfNullOrEmpty(accessToken);
var existing = (await _deviceManager.GetDevices(
new DeviceQuery
@@ -1677,7 +1660,7 @@ namespace Emby.Server.Implementations.Session
var dtoOptions = _itemInfoDtoOptions;
- if (_itemInfoDtoOptions == null)
+ if (_itemInfoDtoOptions is null)
{
dtoOptions = new DtoOptions
{
@@ -1720,7 +1703,7 @@ namespace Emby.Server.Implementations.Session
var info = _dtoService.GetBaseItemDto(item, dtoOptions);
- if (mediaSource != null)
+ if (mediaSource is not null)
{
info.MediaStreams = mediaSource.MediaStreams.ToArray();
}
@@ -1744,10 +1727,7 @@ namespace Emby.Server.Implementations.Session
/// <inheritdoc />
public void ReportNowViewingItem(string sessionId, string itemId)
{
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException(nameof(itemId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(itemId);
var item = _libraryManager.GetItemById(new Guid(itemId));
var session = GetSession(sessionId);
@@ -1761,7 +1741,7 @@ namespace Emby.Server.Implementations.Session
var session = Sessions.FirstOrDefault(i =>
string.Equals(i.DeviceId, deviceId, StringComparison.OrdinalIgnoreCase));
- if (session != null)
+ if (session is not null)
{
session.TranscodingInfo = info;
}
diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
index c654828b1..aebb55907 100644
--- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.Session
public async Task ProcessWebSocketConnectedAsync(IWebSocketConnection connection, HttpContext httpContext)
{
var session = await GetSession(httpContext, connection.RemoteEndPoint?.ToString()).ConfigureAwait(false);
- if (session != null)
+ if (session is not null)
{
EnsureController(session, connection);
await KeepAliveWebSocket(connection).ConfigureAwait(false);
@@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.Session
{
lock (_keepAliveLock)
{
- if (_keepAliveCancellationToken == null)
+ if (_keepAliveCancellationToken is null)
{
_keepAliveCancellationToken = new CancellationTokenSource();
// Start KeepAlive watcher
@@ -221,7 +221,7 @@ namespace Emby.Server.Implementations.Session
{
lock (_keepAliveLock)
{
- if (_keepAliveCancellationToken != null)
+ if (_keepAliveCancellationToken is not null)
{
_keepAliveCancellationToken.Cancel();
_keepAliveCancellationToken.Dispose();
diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs
index 1f3248f07..051fa5b3c 100644
--- a/Emby.Server.Implementations/Session/WebSocketController.cs
+++ b/Emby.Server.Implementations/Session/WebSocketController.cs
@@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.Session
.OrderByDescending(i => i.LastActivityDate)
.FirstOrDefault();
- if (socket == null)
+ if (socket is null)
{
return Task.CompletedTask;
}
diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
index 2d21bd9c2..964004ecc 100644
--- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
@@ -31,9 +31,9 @@ namespace Emby.Server.Implementations.Sorting
var episode1 = x as Episode;
var episode2 = y as Episode;
- if (episode1 == null)
+ if (episode1 is null)
{
- if (episode2 == null)
+ if (episode2 is null)
{
return 0;
}
@@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Sorting
return 1;
}
- if (episode2 == null)
+ if (episode2 is null)
{
return -1;
}
diff --git a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
index ec818253b..453d817c7 100644
--- a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
@@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.Sorting
{
var userdata = UserDataRepository.GetUserData(User, x);
- if (userdata != null && userdata.LastPlayedDate.HasValue)
+ if (userdata is not null && userdata.LastPlayedDate.HasValue)
{
return userdata.LastPlayedDate.Value;
}
diff --git a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
index 45c9044c5..16f1b79b3 100644
--- a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
@@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Sorting
{
var userdata = UserDataRepository.GetUserData(User, x);
- return userdata == null ? 0 : userdata.PlayCount;
+ return userdata is null ? 0 : userdata.PlayCount;
}
}
}
diff --git a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
index b217556ef..db86b8002 100644
--- a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>DateTime.</returns>
private static DateTime GetDate(BaseItem? x)
{
- if (x == null)
+ if (x is null)
{
return DateTime.MinValue;
}
diff --git a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
index d2022df7a..7fd1e024d 100644
--- a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
@@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>DateTime.</returns>
private static int GetValue(BaseItem? x)
{
- if (x == null)
+ if (x is null)
{
return 0;
}
diff --git a/Emby.Server.Implementations/SyncPlay/Group.cs b/Emby.Server.Implementations/SyncPlay/Group.cs
index 52becfec6..7d7ea5810 100644
--- a/Emby.Server.Implementations/SyncPlay/Group.cs
+++ b/Emby.Server.Implementations/SyncPlay/Group.cs
@@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.SyncPlay
private bool HasAccessToQueue(User user, IReadOnlyList<Guid> queue)
{
// Check if queue is empty.
- if (queue == null || queue.Count == 0)
+ if (queue is null || queue.Count == 0)
{
return true;
}
@@ -217,7 +217,7 @@ namespace Emby.Server.Implementations.SyncPlay
private bool AllUsersHaveAccessToQueue(IReadOnlyList<Guid> queue)
{
// Check if queue is empty.
- if (queue == null || queue.Count == 0)
+ if (queue is null || queue.Count == 0)
{
return true;
}
@@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.SyncPlay
GroupName = request.GroupName;
AddSession(session);
- var sessionIsPlayingAnItem = session.FullNowPlayingItem != null;
+ var sessionIsPlayingAnItem = session.FullNowPlayingItem is not null;
RestartCurrentItem();
diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
index 53e3b3577..63c4a1556 100644
--- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
+++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
@@ -102,12 +102,12 @@ namespace Emby.Server.Implementations.SyncPlay
/// <inheritdoc />
public void NewGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken)
{
- if (session == null)
+ if (session is null)
{
throw new InvalidOperationException("Session is null!");
}
- if (request == null)
+ if (request is null)
{
throw new InvalidOperationException("Request is null!");
}
@@ -138,12 +138,12 @@ namespace Emby.Server.Implementations.SyncPlay
/// <inheritdoc />
public void JoinGroup(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken)
{
- if (session == null)
+ if (session is null)
{
throw new InvalidOperationException("Session is null!");
}
- if (request == null)
+ if (request is null)
{
throw new InvalidOperationException("Request is null!");
}
@@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.SyncPlay
{
_groups.TryGetValue(request.GroupId, out Group group);
- if (group == null)
+ if (group is null)
{
_logger.LogWarning("Session {SessionId} tried to join group {GroupId} that does not exist.", session.Id, request.GroupId);
@@ -204,12 +204,12 @@ namespace Emby.Server.Implementations.SyncPlay
/// <inheritdoc />
public void LeaveGroup(SessionInfo session, LeaveGroupRequest request, CancellationToken cancellationToken)
{
- if (session == null)
+ if (session is null)
{
throw new InvalidOperationException("Session is null!");
}
- if (request == null)
+ if (request is null)
{
throw new InvalidOperationException("Request is null!");
}
@@ -257,12 +257,12 @@ namespace Emby.Server.Implementations.SyncPlay
/// <inheritdoc />
public List<GroupInfoDto> ListGroups(SessionInfo session, ListGroupsRequest request)
{
- if (session == null)
+ if (session is null)
{
throw new InvalidOperationException("Session is null!");
}
- if (request == null)
+ if (request is null)
{
throw new InvalidOperationException("Request is null!");
}
@@ -291,12 +291,12 @@ namespace Emby.Server.Implementations.SyncPlay
/// <inheritdoc />
public void HandleRequest(SessionInfo session, IGroupPlaybackRequest request, CancellationToken cancellationToken)
{
- if (session == null)
+ if (session is null)
{
throw new InvalidOperationException("Session is null!");
}
- if (request == null)
+ if (request is null)
{
throw new InvalidOperationException("Request is null!");
}
diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs
index 5c9b9df15..967f90b55 100644
--- a/Emby.Server.Implementations/TV/TVSeriesManager.cs
+++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs
@@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.TV
{
var user = _userManager.GetUserById(query.UserId);
- if (user == null)
+ if (user is null)
{
throw new ArgumentException("User not found");
}
@@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.TV
{
var parent = _libraryManager.GetItemById(query.ParentId.Value);
- if (parent != null)
+ if (parent is not null)
{
parents = new[] { parent };
}
@@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.TV
{
var user = _userManager.GetUserById(request.UserId);
- if (user == null)
+ if (user is null)
{
throw new ArgumentException("User not found");
}
@@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.TV
return !anyFound && i.LastWatchedDate == DateTime.MinValue;
})
.Select(i => i.GetEpisodeFunction())
- .Where(i => i != null);
+ .Where(i => i is not null);
}
private static string GetUniqueSeriesKey(Episode episode)
@@ -247,23 +247,23 @@ namespace Emby.Server.Implementations.TV
DtoOptions = dtoOptions
})
.Cast<Episode>()
- .Where(episode => episode.AirsBeforeSeasonNumber != null || episode.AirsAfterSeasonNumber != null)
+ .Where(episode => episode.AirsBeforeSeasonNumber is not null || episode.AirsAfterSeasonNumber is not null)
.ToList();
- if (lastWatchedEpisode != null)
+ if (lastWatchedEpisode is not null)
{
// Last watched episode is added, because there could be specials that aired before the last watched episode
consideredEpisodes.Add(lastWatchedEpisode);
}
- if (nextEpisode != null)
+ if (nextEpisode is not null)
{
consideredEpisodes.Add(nextEpisode);
}
var sortedConsideredEpisodes = _libraryManager.Sort(consideredEpisodes, user, new[] { (ItemSortBy.AiredEpisodeOrder, SortOrder.Ascending) })
.Cast<Episode>();
- if (lastWatchedEpisode != null)
+ if (lastWatchedEpisode is not null)
{
sortedConsideredEpisodes = sortedConsideredEpisodes.SkipWhile(episode => !episode.Id.Equals(lastWatchedEpisode.Id)).Skip(1);
}
@@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.TV
nextEpisode = sortedConsideredEpisodes.FirstOrDefault();
}
- if (nextEpisode != null)
+ if (nextEpisode is not null)
{
var userData = _userDataManager.GetUserData(user, nextEpisode);
@@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.TV
return nextEpisode;
}
- if (lastWatchedEpisode != null)
+ if (lastWatchedEpisode is not null)
{
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 550f0e075..5e897833e 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Updates
PackageInfo[]? packages = await _httpClientFactory.CreateClient(NamedClient.Default)
.GetFromJsonAsync<PackageInfo[]>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
- if (packages == null)
+ if (packages is null)
{
return Array.Empty<PackageInfo>();
}
@@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.Updates
var result = new List<PackageInfo>();
foreach (RepositoryInfo repository in _config.Configuration.PluginRepositories)
{
- if (repository.Enabled && repository.Url != null)
+ if (repository.Enabled && repository.Url is not null)
{
// Where repositories have the same content, the details from the first is taken.
foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true))
@@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Updates
var version = package.Versions[i];
var plugin = _pluginManager.GetPlugin(package.Id, version.VersionNumber);
- if (plugin != null)
+ if (plugin is not null)
{
await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);
}
@@ -199,7 +199,7 @@ namespace Emby.Server.Implementations.Updates
continue;
}
- if (existing != null)
+ if (existing is not null)
{
// Assumption is both lists are ordered, so slot these into the correct place.
MergeSortedList(existing.Versions, package.Versions);
@@ -222,7 +222,7 @@ namespace Emby.Server.Implementations.Updates
Guid id = default,
Version? specificVersion = null)
{
- if (name != null)
+ if (name is not null)
{
availablePackages = availablePackages.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
}
@@ -232,7 +232,7 @@ namespace Emby.Server.Implementations.Updates
availablePackages = availablePackages.Where(x => x.Id.Equals(id));
}
- if (specificVersion != null)
+ if (specificVersion is not null)
{
availablePackages = availablePackages.Where(x => x.Versions.Any(y => y.VersionNumber.Equals(specificVersion)));
}
@@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Updates
var package = FilterPackages(availablePackages, name, id, specificVersion).FirstOrDefault();
// Package not found in repository
- if (package == null)
+ if (package is null)
{
yield break;
}
@@ -260,11 +260,11 @@ namespace Emby.Server.Implementations.Updates
var availableVersions = package.Versions
.Where(x => string.IsNullOrEmpty(x.TargetAbi) || Version.Parse(x.TargetAbi) <= appVer);
- if (specificVersion != null)
+ if (specificVersion is not null)
{
availableVersions = availableVersions.Where(x => x.VersionNumber.Equals(specificVersion));
}
- else if (minVersion != null)
+ else if (minVersion is not null)
{
availableVersions = availableVersions.Where(x => x.VersionNumber >= minVersion);
}
@@ -370,7 +370,7 @@ namespace Emby.Server.Implementations.Updates
/// <param name="plugin">The <see cref="LocalPlugin"/> to uninstall.</param>
public void UninstallPlugin(LocalPlugin plugin)
{
- if (plugin == null)
+ if (plugin is null)
{
return;
}
@@ -495,7 +495,7 @@ namespace Emby.Server.Implementations.Updates
var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version);
var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version);
- if (version != null && CompletedInstallations.All(x => !x.Id.Equals(version.Id)))
+ if (version is not null && CompletedInstallations.All(x => !x.Id.Equals(version.Id)))
{
yield return version;
}
@@ -565,9 +565,9 @@ namespace Emby.Server.Implementations.Updates
?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version));
await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false);
- _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin == null ? "installed" : "updated", package.Name, package.Version);
+ _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin is null ? "installed" : "updated", package.Name, package.Version);
- return plugin != null;
+ return plugin is not null;
}
}
}
diff --git a/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs b/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs
index 88af08dd3..d4b1ffb06 100644
--- a/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs
+++ b/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs
@@ -32,7 +32,7 @@ namespace Jellyfin.Api.Auth.AnonymousLanAccessPolicy
var ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress;
// Loopback will be on LAN, so we can accept null.
- if (ip == null || _networkManager.IsInLocalNetwork(ip))
+ if (ip is null || _networkManager.IsInLocalNetwork(ip))
{
context.Succeed(requirement);
}
diff --git a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
index 92ee1dd59..8e5e66d64 100644
--- a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
+++ b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
@@ -67,7 +67,7 @@ namespace Jellyfin.Api.Auth
// Ensure userId links to a valid user.
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return false;
}
@@ -78,7 +78,7 @@ namespace Jellyfin.Api.Auth
return false;
}
- var isInLocalNetwork = _httpContextAccessor.HttpContext != null
+ var isInLocalNetwork = _httpContextAccessor.HttpContext is not null
&& _networkManager.IsInLocalNetwork(_httpContextAccessor.HttpContext.GetNormalizedRemoteIp());
// User cannot access remotely and user is remote
diff --git a/Jellyfin.Api/Controllers/ArtistsController.cs b/Jellyfin.Api/Controllers/ArtistsController.cs
index c059cb198..c8ac2ed52 100644
--- a/Jellyfin.Api/Controllers/ArtistsController.cs
+++ b/Jellyfin.Api/Controllers/ArtistsController.cs
@@ -183,7 +183,7 @@ namespace Jellyfin.Api.Controllers
{
return null;
}
- }).Where(i => i != null).Select(i => i!.Id).ToArray();
+ }).Where(i => i is not null).Select(i => i!.Id).ToArray();
}
foreach (var filter in filters)
@@ -386,7 +386,7 @@ namespace Jellyfin.Api.Controllers
{
return null;
}
- }).Where(i => i != null).Select(i => i!.Id).ToArray();
+ }).Where(i => i is not null).Select(i => i!.Id).ToArray();
}
foreach (var filter in filters)
diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs
index bbe163312..a00ac1b0a 100644
--- a/Jellyfin.Api/Controllers/ConfigurationController.cs
+++ b/Jellyfin.Api/Controllers/ConfigurationController.cs
@@ -96,7 +96,7 @@ namespace Jellyfin.Api.Controllers
var configurationType = _configurationManager.GetConfigurationType(key);
var deserializedConfiguration = configuration.Deserialize(configurationType, _serializerOptions);
- if (deserializedConfiguration == null)
+ if (deserializedConfiguration is null)
{
throw new ArgumentException("Body doesn't contain a valid configuration");
}
diff --git a/Jellyfin.Api/Controllers/DashboardController.cs b/Jellyfin.Api/Controllers/DashboardController.cs
index c8411f44b..3894e6c5f 100644
--- a/Jellyfin.Api/Controllers/DashboardController.cs
+++ b/Jellyfin.Api/Controllers/DashboardController.cs
@@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetDashboardConfigurationPage([FromQuery] string? name)
{
var altPage = GetPluginPages().FirstOrDefault(p => string.Equals(p.Item1.Name, name, StringComparison.OrdinalIgnoreCase));
- if (altPage == null)
+ if (altPage is null)
{
return NotFound();
}
@@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers
IPlugin plugin = altPage.Item2;
string resourcePath = altPage.Item1.EmbeddedResourcePath;
Stream? stream = plugin.GetType().Assembly.GetManifestResourceStream(resourcePath);
- if (stream == null)
+ if (stream is null)
{
_logger.LogError("Failed to get resource {Resource} from plugin {Plugin}", resourcePath, plugin.Name);
return NotFound();
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs
index 8292cf83b..aad60cf5c 100644
--- a/Jellyfin.Api/Controllers/DevicesController.cs
+++ b/Jellyfin.Api/Controllers/DevicesController.cs
@@ -64,7 +64,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<DeviceInfo>> GetDeviceInfo([FromQuery, Required] string id)
{
var deviceInfo = await _deviceManager.GetDevice(id).ConfigureAwait(false);
- if (deviceInfo == null)
+ if (deviceInfo is null)
{
return NotFound();
}
@@ -85,7 +85,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<DeviceOptions>> GetDeviceOptions([FromQuery, Required] string id)
{
var deviceInfo = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false);
- if (deviceInfo == null)
+ if (deviceInfo is null)
{
return NotFound();
}
@@ -123,7 +123,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult> DeleteDevice([FromQuery, Required] string id)
{
var existingDevice = await _deviceManager.GetDevice(id).ConfigureAwait(false);
- if (existingDevice == null)
+ if (existingDevice is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
index 14fd7eb3c..67cceb4a8 100644
--- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
+++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
@@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers
foreach (var key in displayPreferences.CustomPrefs.Keys.Where(key => key.StartsWith("homesection", StringComparison.OrdinalIgnoreCase)))
{
- var order = int.Parse(key.AsSpan().Slice("homesection".Length), NumberStyles.Any, CultureInfo.InvariantCulture);
+ var order = int.Parse(key.AsSpan().Slice("homesection".Length), CultureInfo.InvariantCulture);
if (!Enum.TryParse<HomeSectionType>(displayPreferences.CustomPrefs[key], true, out var type))
{
type = order < 8 ? defaults[order] : HomeSectionType.None;
diff --git a/Jellyfin.Api/Controllers/DlnaController.cs b/Jellyfin.Api/Controllers/DlnaController.cs
index 35c3a3d92..07e0590a1 100644
--- a/Jellyfin.Api/Controllers/DlnaController.cs
+++ b/Jellyfin.Api/Controllers/DlnaController.cs
@@ -63,7 +63,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<DeviceProfile> GetProfile([FromRoute, Required] string profileId)
{
var profile = _dlnaManager.GetProfile(profileId);
- if (profile == null)
+ if (profile is null)
{
return NotFound();
}
@@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult DeleteProfile([FromRoute, Required] string profileId)
{
var existingDeviceProfile = _dlnaManager.GetProfile(profileId);
- if (existingDeviceProfile == null)
+ if (existingDeviceProfile is null)
{
return NotFound();
}
@@ -121,7 +121,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult UpdateProfile([FromRoute, Required] string profileId, [FromBody] DeviceProfile deviceProfile)
{
var existingDeviceProfile = _dlnaManager.GetProfile(profileId);
- if (existingDeviceProfile == null)
+ if (existingDeviceProfile is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs
index 8859d6020..96c492b3e 100644
--- a/Jellyfin.Api/Controllers/DlnaServerController.cs
+++ b/Jellyfin.Api/Controllers/DlnaServerController.cs
@@ -274,7 +274,7 @@ namespace Jellyfin.Api.Controllers
private ActionResult GetIconInternal(string fileName)
{
var icon = _dlnaManager.GetIcon(fileName);
- if (icon == null)
+ if (icon is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs
index 0f4d3c1eb..af43bb578 100644
--- a/Jellyfin.Api/Controllers/DynamicHlsController.cs
+++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs
@@ -341,7 +341,7 @@ namespace Jellyfin.Api.Controllers
job ??= _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- if (job != null)
+ if (job is not null)
{
_transcodingJobHelper.OnTranscodeEndRequest(job);
}
@@ -1482,7 +1482,7 @@ namespace Jellyfin.Api.Controllers
startTranscoding = true;
segmentId = 0;
}
- else if (currentTranscodingIndex == null)
+ else if (currentTranscodingIndex is null)
{
_logger.LogDebug("Starting transcoding because currentTranscodingIndex=null");
startTranscoding = true;
@@ -1533,7 +1533,7 @@ namespace Jellyfin.Api.Controllers
else
{
job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- if (job?.TranscodingThrottler != null)
+ if (job?.TranscodingThrottler is not null)
{
await job.TranscodingThrottler.UnpauseTranscoding().ConfigureAwait(false);
}
@@ -1665,7 +1665,7 @@ namespace Jellyfin.Api.Controllers
/// <returns>The command line arguments for audio transcoding.</returns>
private string GetAudioArguments(StreamState state)
{
- if (state.AudioStream == null)
+ if (state.AudioStream is null)
{
return string.Empty;
}
@@ -1762,7 +1762,7 @@ namespace Jellyfin.Api.Controllers
/// <returns>The command line arguments for video transcoding.</returns>
private string GetVideoArguments(StreamState state, int startNumber, bool isEventPlaylist)
{
- if (state.VideoStream == null)
+ if (state.VideoStream is null)
{
return string.Empty;
}
@@ -1806,7 +1806,7 @@ namespace Jellyfin.Api.Controllers
if (EncodingHelper.IsCopyCodec(codec))
{
// If h264_mp4toannexb is ever added, do not use it for live tv.
- if (state.VideoStream != null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
+ if (state.VideoStream is not null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{
string bitStreamArgs = EncodingHelper.GetBitStreamArgs(state.VideoStream);
if (!string.IsNullOrEmpty(bitStreamArgs))
@@ -1837,7 +1837,7 @@ namespace Jellyfin.Api.Controllers
// -start_at_zero is necessary to use with -ss when seeking,
// otherwise the target position cannot be determined.
- if (state.SubtitleStream != null)
+ if (state.SubtitleStream is not null)
{
// Disable start_at_zero for external graphical subs
if (!(state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream))
@@ -1883,7 +1883,7 @@ namespace Jellyfin.Api.Controllers
var segmentExists = System.IO.File.Exists(segmentPath);
if (segmentExists)
{
- if (transcodingJob != null && transcodingJob.HasExited)
+ if (transcodingJob is not null && transcodingJob.HasExited)
{
// Transcoding job is over, so assume all existing files are ready
_logger.LogDebug("serving up {0} as transcode is over", segmentPath);
@@ -1901,7 +1901,7 @@ namespace Jellyfin.Api.Controllers
}
var nextSegmentPath = GetSegmentPath(state, playlistPath, segmentIndex + 1);
- if (transcodingJob != null)
+ if (transcodingJob is not null)
{
while (!cancellationToken.IsCancellationRequested && !transcodingJob.HasExited)
{
@@ -1953,7 +1953,7 @@ namespace Jellyfin.Api.Controllers
Response.OnCompleted(() =>
{
_logger.LogDebug("Finished serving {SegmentPath}", segmentPath);
- if (transcodingJob != null)
+ if (transcodingJob is not null)
{
transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks);
_transcodingJobHelper.OnTranscodeEndRequest(transcodingJob);
@@ -1969,14 +1969,14 @@ namespace Jellyfin.Api.Controllers
{
var job = _transcodingJobHelper.GetTranscodingJob(playlist, TranscodingJobType);
- if (job == null || job.HasExited)
+ if (job is null || job.HasExited)
{
return null;
}
var file = GetLastTranscodingFile(playlist, segmentExtension, _fileSystem);
- if (file == null)
+ if (file is null)
{
return null;
}
@@ -2011,7 +2011,7 @@ namespace Jellyfin.Api.Controllers
{
var file = GetLastTranscodingFile(playlistPath, segmentExtension, _fileSystem);
- if (file != null)
+ if (file is not null)
{
DeleteFile(file.FullName, retryCount);
}
diff --git a/Jellyfin.Api/Controllers/EnvironmentController.cs b/Jellyfin.Api/Controllers/EnvironmentController.cs
index b0b4b5af5..6c78a7987 100644
--- a/Jellyfin.Api/Controllers/EnvironmentController.cs
+++ b/Jellyfin.Api/Controllers/EnvironmentController.cs
@@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers
if (validatePathDto.ValidateWritable)
{
- if (validatePathDto.Path == null)
+ if (validatePathDto.Path is null)
{
throw new ResourceNotFoundException(nameof(validatePathDto.Path));
}
diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs
index 11808b1b8..b6780ee20 100644
--- a/Jellyfin.Api/Controllers/FilterController.cs
+++ b/Jellyfin.Api/Controllers/FilterController.cs
@@ -182,7 +182,7 @@ namespace Jellyfin.Api.Controllers
if ((recursive ?? true) || parentItem is UserView || parentItem is ICollectionFolder)
{
- genreQuery.AncestorIds = parentItem == null ? Array.Empty<Guid>() : new[] { parentItem.Id };
+ genreQuery.AncestorIds = parentItem is null ? Array.Empty<Guid>() : new[] { parentItem.Id };
}
else
{
diff --git a/Jellyfin.Api/Controllers/HlsSegmentController.cs b/Jellyfin.Api/Controllers/HlsSegmentController.cs
index 78634f0bf..50fee233a 100644
--- a/Jellyfin.Api/Controllers/HlsSegmentController.cs
+++ b/Jellyfin.Api/Controllers/HlsSegmentController.cs
@@ -167,7 +167,7 @@ namespace Jellyfin.Api.Controllers
}
}
- return playlistPath == null
+ return playlistPath is null
? NotFound("Hls segment not found.")
: GetFileResult(file, playlistPath);
}
@@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers
Response.OnCompleted(() =>
{
- if (transcodingJob != null)
+ if (transcodingJob is not null)
{
_transcodingJobHelper.OnTranscodeEndRequest(transcodingJob);
}
diff --git a/Jellyfin.Api/Controllers/ImageByNameController.cs b/Jellyfin.Api/Controllers/ImageByNameController.cs
index 89bbf22c9..c54851b96 100644
--- a/Jellyfin.Api/Controllers/ImageByNameController.cs
+++ b/Jellyfin.Api/Controllers/ImageByNameController.cs
@@ -77,7 +77,7 @@ namespace Jellyfin.Api.Controllers
.Select(i => Path.GetFullPath(Path.Combine(_applicationPaths.GeneralPath, name, filename + i)))
.FirstOrDefault(System.IO.File.Exists);
- if (path == null)
+ if (path is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs
index f092bd882..49342ad5c 100644
--- a/Jellyfin.Api/Controllers/ImageController.cs
+++ b/Jellyfin.Api/Controllers/ImageController.cs
@@ -28,6 +28,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Jellyfin.Api.Controllers
@@ -110,7 +111,7 @@ namespace Jellyfin.Api.Controllers
// Handle image/png; charset=utf-8
var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
- if (user.ProfileImage != null)
+ if (user.ProfileImage is not null)
{
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
}
@@ -157,7 +158,7 @@ namespace Jellyfin.Api.Controllers
// Handle image/png; charset=utf-8
var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
- if (user.ProfileImage != null)
+ if (user.ProfileImage is not null)
{
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
}
@@ -198,7 +199,7 @@ namespace Jellyfin.Api.Controllers
}
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NoContent();
}
@@ -242,7 +243,7 @@ namespace Jellyfin.Api.Controllers
}
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NoContent();
}
@@ -279,7 +280,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -307,7 +308,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute] int imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -335,7 +336,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] ImageType imageType)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -371,7 +372,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute] int imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -407,7 +408,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery, Required] int newIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -430,7 +431,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<IEnumerable<ImageInfo>>> GetItemImageInfos([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -452,7 +453,7 @@ namespace Jellyfin.Api.Controllers
{
var info = GetImageInfo(item, image, null);
- if (info != null)
+ if (info is not null)
{
list.Add(info);
}
@@ -470,7 +471,7 @@ namespace Jellyfin.Api.Controllers
{
var info = GetImageInfo(item, image, index);
- if (info != null)
+ if (info is not null)
{
list.Add(info);
}
@@ -537,7 +538,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -620,7 +621,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -703,7 +704,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] int imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -786,7 +787,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] int imageIndex)
{
var item = _libraryManager.GetArtist(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -869,7 +870,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -952,7 +953,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1035,7 +1036,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetMusicGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1118,7 +1119,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetMusicGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1201,7 +1202,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetPerson(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1284,7 +1285,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetPerson(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1367,7 +1368,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetStudio(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1450,7 +1451,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetStudio(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1533,7 +1534,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NotFound();
}
@@ -1634,7 +1635,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NotFound();
}
@@ -1944,10 +1945,10 @@ namespace Jellyfin.Api.Controllers
unplayedCount = null;
}
- if (imageInfo == null)
+ if (imageInfo is null)
{
imageInfo = item?.GetImageInfo(imageType, imageIndex ?? 0);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return NotFound(string.Format(NumberFormatInfo.InvariantInfo, "{0} does not have an image of type {1}", item?.Name, imageType));
}
@@ -1968,7 +1969,7 @@ namespace Jellyfin.Api.Controllers
{ "realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*" }
};
- if (!imageInfo.IsLocalFile && item != null)
+ if (!imageInfo.IsLocalFile && item is not null)
{
imageInfo = await _libraryManager.ConvertImageToLocal(item, imageInfo, imageIndex ?? 0).ConfigureAwait(false);
}
@@ -2026,8 +2027,13 @@ namespace Jellyfin.Api.Controllers
}
var acceptParam = Request.Query[HeaderNames.Accept];
+ if (StringValues.IsNullOrEmpty(acceptParam))
+ {
+ return Array.Empty<ImageFormat>();
+ }
- var supportsWebP = SupportsFormat(supportedFormats, acceptParam, ImageFormat.Webp, false);
+ // Can't be null, checked above
+ var supportsWebP = SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Webp, false);
if (!supportsWebP)
{
@@ -2049,7 +2055,8 @@ namespace Jellyfin.Api.Controllers
formats.Add(ImageFormat.Jpg);
formats.Add(ImageFormat.Png);
- if (SupportsFormat(supportedFormats, acceptParam, ImageFormat.Gif, true))
+ // Can't be null, checked above
+ if (SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Gif, true))
{
formats.Add(ImageFormat.Gif);
}
diff --git a/Jellyfin.Api/Controllers/ItemLookupController.cs b/Jellyfin.Api/Controllers/ItemLookupController.cs
index c49f85616..34893d682 100644
--- a/Jellyfin.Api/Controllers/ItemLookupController.cs
+++ b/Jellyfin.Api/Controllers/ItemLookupController.cs
@@ -65,7 +65,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<IEnumerable<ExternalIdInfo>> GetExternalIdInfos([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ItemRefreshController.cs b/Jellyfin.Api/Controllers/ItemRefreshController.cs
index 9340737b5..0dc3fbd05 100644
--- a/Jellyfin.Api/Controllers/ItemRefreshController.cs
+++ b/Jellyfin.Api/Controllers/ItemRefreshController.cs
@@ -61,7 +61,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] bool replaceAllImages = false)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ItemUpdateController.cs b/Jellyfin.Api/Controllers/ItemUpdateController.cs
index fd137f98f..af3d779f5 100644
--- a/Jellyfin.Api/Controllers/ItemUpdateController.cs
+++ b/Jellyfin.Api/Controllers/ItemUpdateController.cs
@@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult> UpdateItem([FromRoute, Required] Guid itemId, [FromBody, Required] BaseItemDto request)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -80,13 +80,13 @@ namespace Jellyfin.Api.Controllers
var isLockedChanged = item.IsLocked != newLockData;
var series = item as Series;
- var displayOrderChanged = series != null && !string.Equals(
+ var displayOrderChanged = series is not null && !string.Equals(
series.DisplayOrder ?? string.Empty,
request.DisplayOrder ?? string.Empty,
StringComparison.OrdinalIgnoreCase);
// Do this first so that metadata savers can pull the updates from the database.
- if (request.People != null)
+ if (request.People is not null)
{
_libraryManager.UpdatePeople(
item,
@@ -198,7 +198,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult UpdateItemContentType([FromRoute, Required] Guid itemId, [FromQuery] string? contentType)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -248,12 +248,12 @@ namespace Jellyfin.Api.Controllers
item.Tags = request.Tags;
- if (request.Taglines != null)
+ if (request.Taglines is not null)
{
item.Tagline = request.Taglines.FirstOrDefault();
}
- if (request.Studios != null)
+ if (request.Studios is not null)
{
item.Studios = request.Studios.Select(x => x.Name).ToArray();
}
@@ -269,7 +269,7 @@ namespace Jellyfin.Api.Controllers
item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating;
item.CustomRating = request.CustomRating;
- if (request.ProductionLocations != null)
+ if (request.ProductionLocations is not null)
{
item.ProductionLocations = request.ProductionLocations;
}
@@ -289,7 +289,7 @@ namespace Jellyfin.Api.Controllers
item.IsLocked = request.LockData ?? false;
- if (request.LockedFields != null)
+ if (request.LockedFields is not null)
{
item.LockedFields = request.LockedFields;
}
@@ -315,7 +315,7 @@ namespace Jellyfin.Api.Controllers
video.Video3DFormat = request.Video3DFormat;
}
- if (request.AlbumArtists != null)
+ if (request.AlbumArtists is not null)
{
if (item is IHasAlbumArtist hasAlbumArtists)
{
@@ -326,7 +326,7 @@ namespace Jellyfin.Api.Controllers
}
}
- if (request.ArtistItems != null)
+ if (request.ArtistItems is not null)
{
if (item is IHasArtist hasArtists)
{
@@ -349,7 +349,7 @@ namespace Jellyfin.Api.Controllers
{
series.Status = GetSeriesStatus(request);
- if (request.AirDays != null)
+ if (request.AirDays is not null)
{
series.AirDays = request.AirDays;
series.AirTime = request.AirTime;
diff --git a/Jellyfin.Api/Controllers/ItemsController.cs b/Jellyfin.Api/Controllers/ItemsController.cs
index 3ee5b8d73..717ddc32b 100644
--- a/Jellyfin.Api/Controllers/ItemsController.cs
+++ b/Jellyfin.Api/Controllers/ItemsController.cs
@@ -447,7 +447,7 @@ namespace Jellyfin.Api.Controllers
{
return null;
}
- }).Where(i => i != null).Select(i => i!.Id).ToArray();
+ }).Where(i => i is not null).Select(i => i!.Id).ToArray();
}
// ExcludeArtistIds
@@ -483,7 +483,7 @@ namespace Jellyfin.Api.Controllers
{
return null;
}
- }).Where(i => i != null).Select(i => i!.Id).ToArray();
+ }).Where(i => i is not null).Select(i => i!.Id).ToArray();
}
// Apply default sorting if none requested
@@ -837,7 +837,7 @@ namespace Jellyfin.Api.Controllers
if (excludeActiveSessions)
{
excludeItemIds = _sessionManager.Sessions
- .Where(s => s.UserId.Equals(userId) && s.NowPlayingItem != null)
+ .Where(s => s.UserId.Equals(userId) && s.NowPlayingItem is not null)
.Select(s => s.NowPlayingItem.Id)
.ToArray();
}
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs
index 7a57bf1a2..ab2020830 100644
--- a/Jellyfin.Api/Controllers/LibraryController.cs
+++ b/Jellyfin.Api/Controllers/LibraryController.cs
@@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetFile([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers
: _libraryManager.GetUserRootFolder())
: _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound("Item not found.");
}
@@ -171,7 +171,7 @@ namespace Jellyfin.Api.Controllers
}
var parent = item.GetParent();
- if (parent == null)
+ if (parent is null)
{
break;
}
@@ -220,7 +220,7 @@ namespace Jellyfin.Api.Controllers
: _libraryManager.GetUserRootFolder())
: _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound("Item not found.");
}
@@ -237,7 +237,7 @@ namespace Jellyfin.Api.Controllers
}
var parent = item.GetParent();
- if (parent == null)
+ if (parent is null)
{
break;
}
@@ -435,7 +435,7 @@ namespace Jellyfin.Api.Controllers
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound("Item not found");
}
@@ -449,9 +449,9 @@ namespace Jellyfin.Api.Controllers
var dtoOptions = new DtoOptions().AddClientFields(User);
BaseItem? parent = item.GetParent();
- while (parent != null)
+ while (parent is not null)
{
- if (user != null)
+ if (user is not null)
{
parent = TranslateParentItem(parent, user);
}
@@ -610,14 +610,14 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult> GetDownload([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
var user = _userManager.GetUserById(User.GetUserId());
- if (user != null)
+ if (user is not null)
{
if (!item.CanDownload(user))
{
@@ -632,27 +632,15 @@ namespace Jellyfin.Api.Controllers
}
}
- if (user != null)
+ if (user is not null)
{
await LogDownloadAsync(item, user).ConfigureAwait(false);
}
- var path = item.Path;
+ // Quotes are valid in linux. They'll possibly cause issues here.
+ var filename = Path.GetFileName(item.Path)?.Replace("\"", string.Empty, StringComparison.Ordinal);
- // Quotes are valid in linux. They'll possibly cause issues here
- var filename = (Path.GetFileName(path) ?? string.Empty).Replace("\"", string.Empty, StringComparison.Ordinal);
- if (!string.IsNullOrWhiteSpace(filename))
- {
- // Kestrel doesn't support non-ASCII characters in headers
- if (Regex.IsMatch(filename, @"[^\p{IsBasicLatin}]"))
- {
- // Manually encoding non-ASCII characters, following https://tools.ietf.org/html/rfc5987#section-3.2.2
- filename = WebUtility.UrlEncode(filename);
- }
- }
-
- // TODO determine non-ASCII validity.
- return PhysicalFile(path, MimeTypes.GetMimeType(path), filename, true);
+ return PhysicalFile(item.Path, MimeTypes.GetMimeType(item.Path), filename, true);
}
/// <summary>
@@ -698,8 +686,8 @@ namespace Jellyfin.Api.Controllers
.AddClientFields(User);
var program = item as IHasProgramAttributes;
- bool? isMovie = item is Movie || (program != null && program.IsMovie) || item is Trailer;
- bool? isSeries = item is Series || (program != null && program.IsSeries);
+ bool? isMovie = item is Movie || (program is not null && program.IsMovie) || item is Trailer;
+ bool? isSeries = item is Series || (program is not null && program.IsSeries);
var includeItemTypes = new List<BaseItemKind>();
if (isMovie.Value)
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index ec1170411..1c2394055 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -82,7 +82,7 @@ namespace Jellyfin.Api.Controllers
{
var libraryOptions = libraryOptionsDto?.LibraryOptions ?? new LibraryOptions();
- if (paths != null && paths.Length > 0)
+ if (paths is not null && paths.Length > 0)
{
libraryOptions.PathInfos = paths.Select(i => new MediaPathInfo(i)).ToArray();
}
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs
index 394df0f58..94710d78f 100644
--- a/Jellyfin.Api/Controllers/LiveTvController.cs
+++ b/Jellyfin.Api/Controllers/LiveTvController.cs
@@ -763,7 +763,7 @@ namespace Jellyfin.Api.Controllers
await AssertUserCanManageLiveTv().ConfigureAwait(false);
var item = _libraryManager.GetItemById(recordingId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -840,7 +840,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<SeriesTimerInfoDto>> GetSeriesTimer([FromRoute, Required] string timerId)
{
var timer = await _liveTvManager.GetSeriesTimer(timerId, CancellationToken.None).ConfigureAwait(false);
- if (timer == null)
+ if (timer is null)
{
return NotFound();
}
@@ -1201,7 +1201,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetLiveStreamFile([FromRoute, Required] string streamId, [FromRoute, Required] string container)
{
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfoByUniqueId(streamId);
- if (liveStreamInfo == null)
+ if (liveStreamInfo is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/MediaInfoController.cs b/Jellyfin.Api/Controllers/MediaInfoController.cs
index c111e9218..8115c3585 100644
--- a/Jellyfin.Api/Controllers/MediaInfoController.cs
+++ b/Jellyfin.Api/Controllers/MediaInfoController.cs
@@ -121,10 +121,10 @@ namespace Jellyfin.Api.Controllers
var profile = playbackInfoDto?.DeviceProfile;
_logger.LogDebug("GetPostedPlaybackInfo profile: {@Profile}", profile);
- if (profile == null)
+ if (profile is null)
{
var caps = _deviceManager.GetCapabilities(User.GetDeviceId());
- if (caps != null)
+ if (caps is not null)
{
profile = caps.DeviceProfile;
}
@@ -154,12 +154,12 @@ namespace Jellyfin.Api.Controllers
liveStreamId)
.ConfigureAwait(false);
- if (info.ErrorCode != null)
+ if (info.ErrorCode is not null)
{
return info;
}
- if (profile != null)
+ if (profile is not null)
{
// set device specific data
var item = _libraryManager.GetItemById(itemId);
@@ -194,7 +194,7 @@ namespace Jellyfin.Api.Controllers
{
var mediaSource = string.IsNullOrWhiteSpace(mediaSourceId) ? info.MediaSources[0] : info.MediaSources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.Ordinal));
- if (mediaSource != null && mediaSource.RequiresOpening && string.IsNullOrWhiteSpace(mediaSource.LiveStreamId))
+ if (mediaSource is not null && mediaSource.RequiresOpening && string.IsNullOrWhiteSpace(mediaSource.LiveStreamId))
{
var openStreamResult = await _mediaInfoHelper.OpenMediaSource(
HttpContext,
diff --git a/Jellyfin.Api/Controllers/PackageController.cs b/Jellyfin.Api/Controllers/PackageController.cs
index 9690aead0..0aa7c2ac9 100644
--- a/Jellyfin.Api/Controllers/PackageController.cs
+++ b/Jellyfin.Api/Controllers/PackageController.cs
@@ -54,7 +54,7 @@ namespace Jellyfin.Api.Controllers
assemblyGuid ?? default)
.FirstOrDefault();
- if (result == null)
+ if (result is null)
{
return NotFound();
}
@@ -110,7 +110,7 @@ namespace Jellyfin.Api.Controllers
specificVersion: string.IsNullOrEmpty(version) ? null : Version.Parse(version))
.FirstOrDefault();
- if (package == null)
+ if (package is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs
index 42be969b2..09f7281ec 100644
--- a/Jellyfin.Api/Controllers/PersonsController.cs
+++ b/Jellyfin.Api/Controllers/PersonsController.cs
@@ -122,7 +122,7 @@ namespace Jellyfin.Api.Controllers
.AddClientFields(User);
var item = _libraryManager.GetPerson(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/PlaylistsController.cs b/Jellyfin.Api/Controllers/PlaylistsController.cs
index fb045f891..e0c565da1 100644
--- a/Jellyfin.Api/Controllers/PlaylistsController.cs
+++ b/Jellyfin.Api/Controllers/PlaylistsController.cs
@@ -176,7 +176,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
{
var playlist = (Playlist)_libraryManager.GetItemById(playlistId);
- if (playlist == null)
+ if (playlist is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/PlaystateController.cs b/Jellyfin.Api/Controllers/PlaystateController.cs
index 3a2ba033e..58f9b7d35 100644
--- a/Jellyfin.Api/Controllers/PlaystateController.cs
+++ b/Jellyfin.Api/Controllers/PlaystateController.cs
@@ -353,7 +353,7 @@ namespace Jellyfin.Api.Controllers
if (method == PlayMethod.Transcode)
{
var job = string.IsNullOrWhiteSpace(playSessionId) ? null : _transcodingJobHelper.GetTranscodingJob(playSessionId);
- if (job == null)
+ if (job is null)
{
return PlayMethod.DirectPlay;
}
diff --git a/Jellyfin.Api/Controllers/PluginsController.cs b/Jellyfin.Api/Controllers/PluginsController.cs
index b227dba2d..6a729b237 100644
--- a/Jellyfin.Api/Controllers/PluginsController.cs
+++ b/Jellyfin.Api/Controllers/PluginsController.cs
@@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult EnablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
@@ -95,7 +95,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult DisablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
@@ -119,7 +119,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult UninstallPluginByVersion([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
@@ -146,9 +146,9 @@ namespace Jellyfin.Api.Controllers
var plugins = _pluginManager.Plugins.Where(p => p.Id.Equals(pluginId));
// Select the un-instanced one first.
- var plugin = plugins.FirstOrDefault(p => p.Instance == null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault();
+ var plugin = plugins.FirstOrDefault(p => p.Instance is null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault();
- if (plugin != null)
+ if (plugin is not null)
{
_installationManager.UninstallPlugin(plugin);
return NoContent();
@@ -202,7 +202,7 @@ namespace Jellyfin.Api.Controllers
var configuration = (BasePluginConfiguration?)await JsonSerializer.DeserializeAsync(Request.Body, configPlugin.ConfigurationType, _serializerOptions)
.ConfigureAwait(false);
- if (configuration != null)
+ if (configuration is not null)
{
configPlugin.UpdateConfiguration(configuration);
}
@@ -225,13 +225,13 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetPluginImage([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
var imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath ?? string.Empty);
- if (plugin.Manifest.ImagePath == null || !System.IO.File.Exists(imagePath))
+ if (plugin.Manifest.ImagePath is null || !System.IO.File.Exists(imagePath))
{
return NotFound();
}
@@ -254,7 +254,7 @@ namespace Jellyfin.Api.Controllers
{
var plugin = _pluginManager.GetPlugin(pluginId);
- if (plugin != null)
+ if (plugin is not null)
{
return plugin.Manifest;
}
diff --git a/Jellyfin.Api/Controllers/RemoteImageController.cs b/Jellyfin.Api/Controllers/RemoteImageController.cs
index dbee56e14..da9e8cf90 100644
--- a/Jellyfin.Api/Controllers/RemoteImageController.cs
+++ b/Jellyfin.Api/Controllers/RemoteImageController.cs
@@ -68,7 +68,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] bool includeAllLanguages = false)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -127,7 +127,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<IEnumerable<ImageProviderInfo>> GetRemoteImageProviders([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? imageUrl)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ScheduledTasksController.cs b/Jellyfin.Api/Controllers/ScheduledTasksController.cs
index 68e4f0586..832e14505 100644
--- a/Jellyfin.Api/Controllers/ScheduledTasksController.cs
+++ b/Jellyfin.Api/Controllers/ScheduledTasksController.cs
@@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers
var task = _taskManager.ScheduledTasks.FirstOrDefault(i =>
string.Equals(i.Id, taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
@@ -99,7 +99,7 @@ namespace Jellyfin.Api.Controllers
var task = _taskManager.ScheduledTasks.FirstOrDefault(o =>
o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
@@ -123,7 +123,7 @@ namespace Jellyfin.Api.Controllers
var task = _taskManager.ScheduledTasks.FirstOrDefault(o =>
o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
@@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers
{
var task = _taskManager.ScheduledTasks.FirstOrDefault(o =>
o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs
index aeed0c0d6..3b7719f37 100644
--- a/Jellyfin.Api/Controllers/SearchController.cs
+++ b/Jellyfin.Api/Controllers/SearchController.cs
@@ -161,7 +161,7 @@ namespace Jellyfin.Api.Controllers
var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary);
- if (primaryImageTag != null)
+ if (primaryImageTag is not null)
{
result.PrimaryImageTag = primaryImageTag;
result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item);
@@ -195,7 +195,7 @@ namespace Jellyfin.Api.Controllers
MusicAlbum musicAlbum = song.AlbumEntity;
- if (musicAlbum != null)
+ if (musicAlbum is not null)
{
result.Album = musicAlbum.Name;
result.AlbumId = musicAlbum.Id;
@@ -221,18 +221,18 @@ namespace Jellyfin.Api.Controllers
{
var itemWithImage = item.HasImage(ImageType.Thumb) ? item : null;
- if (itemWithImage == null && item is Episode)
+ if (itemWithImage is null && item is Episode)
{
itemWithImage = GetParentWithImage<Series>(item, ImageType.Thumb);
}
itemWithImage ??= GetParentWithImage<BaseItem>(item, ImageType.Thumb);
- if (itemWithImage != null)
+ if (itemWithImage is not null)
{
var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Thumb);
- if (tag != null)
+ if (tag is not null)
{
hint.ThumbImageTag = tag;
hint.ThumbImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture);
@@ -245,11 +245,11 @@ namespace Jellyfin.Api.Controllers
var itemWithImage = (item.HasImage(ImageType.Backdrop) ? item : null)
?? GetParentWithImage<BaseItem>(item, ImageType.Backdrop);
- if (itemWithImage != null)
+ if (itemWithImage is not null)
{
var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Backdrop);
- if (tag != null)
+ if (tag is not null)
{
hint.BackdropImageTag = tag;
hint.BackdropImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture);
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs
index 31b95162d..25f930135 100644
--- a/Jellyfin.Api/Controllers/SessionController.cs
+++ b/Jellyfin.Api/Controllers/SessionController.cs
@@ -294,10 +294,7 @@ namespace Jellyfin.Api.Controllers
{
var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
- if (command == null)
- {
- throw new ArgumentException("Request body may not be null");
- }
+ ArgumentNullException.ThrowIfNull(command);
command.ControllingUserId = currentSession.UserId;
diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs
index c49bde93f..eec5779e6 100644
--- a/Jellyfin.Api/Controllers/StartupController.cs
+++ b/Jellyfin.Api/Controllers/StartupController.cs
@@ -132,7 +132,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.Users.First();
- if (startupUserDto.Name != null)
+ if (startupUserDto.Name is not null)
{
user.Username = startupUserDto.Name;
}
diff --git a/Jellyfin.Api/Controllers/SubtitleController.cs b/Jellyfin.Api/Controllers/SubtitleController.cs
index 1258a9876..ff9bd095b 100644
--- a/Jellyfin.Api/Controllers/SubtitleController.cs
+++ b/Jellyfin.Api/Controllers/SubtitleController.cs
@@ -96,7 +96,7 @@ namespace Jellyfin.Api.Controllers
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -522,7 +522,7 @@ namespace Jellyfin.Api.Controllers
.First(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
var fileSize = fontFile?.Length;
- if (fontFile != null && fileSize != null && fileSize > 0)
+ if (fontFile is not null && fileSize is not null && fileSize > 0)
{
_logger.LogDebug("Fallback font size is {FileSize} Bytes", fileSize);
return PhysicalFile(fontFile.FullName, MimeTypes.GetMimeType(fontFile.FullName));
diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs
index ea13ceb91..7f4f4d077 100644
--- a/Jellyfin.Api/Controllers/TvShowsController.cs
+++ b/Jellyfin.Api/Controllers/TvShowsController.cs
@@ -247,7 +247,7 @@ namespace Jellyfin.Api.Controllers
.GetSeasons(user, dtoOptions)
.FirstOrDefault(i => i.IndexNumber == season.Value);
- episodes = seasonItem == null ?
+ episodes = seasonItem is null ?
new List<BaseItem>()
: ((Season)seasonItem).GetEpisodes(user, dtoOptions);
}
diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs
index ff653fe6b..002327d74 100644
--- a/Jellyfin.Api/Controllers/UserController.cs
+++ b/Jellyfin.Api/Controllers/UserController.cs
@@ -124,7 +124,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -173,7 +173,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -272,7 +272,7 @@ namespace Jellyfin.Api.Controllers
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -292,7 +292,7 @@ namespace Jellyfin.Api.Controllers
HttpContext.GetNormalizedRemoteIp().ToString(),
false).ConfigureAwait(false);
- if (success == null)
+ if (success is null)
{
return StatusCode(StatusCodes.Status403Forbidden, "Invalid user or password entered.");
}
@@ -333,7 +333,7 @@ namespace Jellyfin.Api.Controllers
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -477,7 +477,7 @@ namespace Jellyfin.Api.Controllers
var newUser = await _userManager.CreateUserAsync(request.Name).ConfigureAwait(false);
// no need to authenticate password for new user
- if (request.Password != null)
+ if (request.Password is not null)
{
await _userManager.ChangePassword(newUser, request.Password).ConfigureAwait(false);
}
@@ -544,7 +544,7 @@ namespace Jellyfin.Api.Controllers
}
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return BadRequest();
}
diff --git a/Jellyfin.Api/Controllers/UserLibraryController.cs b/Jellyfin.Api/Controllers/UserLibraryController.cs
index 8a2d5a27d..c18fa29af 100644
--- a/Jellyfin.Api/Controllers/UserLibraryController.cs
+++ b/Jellyfin.Api/Controllers/UserLibraryController.cs
@@ -306,7 +306,7 @@ namespace Jellyfin.Api.Controllers
var item = i.Item2[0];
var childCount = 0;
- if (i.Item1 != null && (i.Item2.Count > 1 || i.Item1 is MusicAlbum))
+ if (i.Item1 is not null && (i.Item2.Count > 1 || i.Item1 is MusicAlbum))
{
item = i.Item1;
childCount = i.Item2.Count;
@@ -402,7 +402,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound();
}
@@ -411,7 +411,7 @@ namespace Jellyfin.Api.Controllers
? _libraryManager.GetUserRootFolder()
: _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/UserViewsController.cs b/Jellyfin.Api/Controllers/UserViewsController.cs
index 85d154cac..3aeb444df 100644
--- a/Jellyfin.Api/Controllers/UserViewsController.cs
+++ b/Jellyfin.Api/Controllers/UserViewsController.cs
@@ -117,7 +117,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<IEnumerable<SpecialViewOptionDto>> GetGroupingOptions([FromRoute, Required] Guid userId)
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/VideoAttachmentsController.cs b/Jellyfin.Api/Controllers/VideoAttachmentsController.cs
index c2bb0dfff..bb3162614 100644
--- a/Jellyfin.Api/Controllers/VideoAttachmentsController.cs
+++ b/Jellyfin.Api/Controllers/VideoAttachmentsController.cs
@@ -55,7 +55,7 @@ namespace Jellyfin.Api.Controllers
try
{
var item = _libraryManager.GetItemById(videoId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/VideosController.cs b/Jellyfin.Api/Controllers/VideosController.cs
index bf08ad376..64d8fb498 100644
--- a/Jellyfin.Api/Controllers/VideosController.cs
+++ b/Jellyfin.Api/Controllers/VideosController.cs
@@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers
{
var video = (Video)_libraryManager.GetItemById(itemId);
- if (video == null)
+ if (video is null)
{
return NotFound("The video either does not exist or the id does not belong to a video.");
}
@@ -199,7 +199,7 @@ namespace Jellyfin.Api.Controllers
}
var primaryVersion = items.FirstOrDefault(i => i.MediaSourceCount > 1 && string.IsNullOrEmpty(i.PrimaryVersionId));
- if (primaryVersion == null)
+ if (primaryVersion is null)
{
primaryVersion = items
.OrderBy(i =>
@@ -439,12 +439,12 @@ namespace Jellyfin.Api.Controllers
cancellationTokenSource.Token)
.ConfigureAwait(false);
- if (@static.HasValue && @static.Value && state.DirectStreamProvider != null)
+ if (@static.HasValue && @static.Value && state.DirectStreamProvider is not null)
{
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, state.Request.StartTimeTicks, Request, _dlnaManager);
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
- if (liveStreamInfo == null)
+ if (liveStreamInfo is null)
{
return NotFound();
}
@@ -472,7 +472,7 @@ namespace Jellyfin.Api.Controllers
var outputPathExists = System.IO.File.Exists(outputPath);
var transcodingJob = _transcodingJobHelper.GetTranscodingJob(outputPath, TranscodingJobType.Progressive);
- var isTranscodeCached = outputPathExists && transcodingJob != null;
+ var isTranscodeCached = outputPathExists && transcodingJob is not null;
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, (@static.HasValue && @static.Value) || isTranscodeCached, state.Request.StartTimeTicks, Request, _dlnaManager);
diff --git a/Jellyfin.Api/Controllers/YearsController.cs b/Jellyfin.Api/Controllers/YearsController.cs
index b732bdff3..cd85ba221 100644
--- a/Jellyfin.Api/Controllers/YearsController.cs
+++ b/Jellyfin.Api/Controllers/YearsController.cs
@@ -152,7 +152,7 @@ namespace Jellyfin.Api.Controllers
var result = new QueryResult<BaseItemDto>(
startIndex,
ibnItemsArray.Count,
- dtos.Where(i => i != null).ToArray());
+ dtos.Where(i => i is not null).ToArray());
return result;
}
@@ -173,7 +173,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<BaseItemDto> GetYear([FromRoute, Required] int year, [FromQuery] Guid? userId)
{
var item = _libraryManager.GetYear(year);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Helpers/AudioHelper.cs b/Jellyfin.Api/Helpers/AudioHelper.cs
index bc83ff48a..be410ebcd 100644
--- a/Jellyfin.Api/Helpers/AudioHelper.cs
+++ b/Jellyfin.Api/Helpers/AudioHelper.cs
@@ -85,7 +85,7 @@ namespace Jellyfin.Api.Helpers
TranscodingJobType transcodingJobType,
StreamingRequestDto streamingRequest)
{
- if (_httpContextAccessor.HttpContext == null)
+ if (_httpContextAccessor.HttpContext is null)
{
throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext));
}
@@ -111,12 +111,12 @@ namespace Jellyfin.Api.Helpers
cancellationTokenSource.Token)
.ConfigureAwait(false);
- if (streamingRequest.Static && state.DirectStreamProvider != null)
+ if (streamingRequest.Static && state.DirectStreamProvider is not null)
{
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
- if (liveStreamInfo == null)
+ if (liveStreamInfo is null)
{
throw new FileNotFoundException();
}
@@ -144,7 +144,7 @@ namespace Jellyfin.Api.Helpers
var outputPathExists = File.Exists(outputPath);
var transcodingJob = _transcodingJobHelper.GetTranscodingJob(outputPath, TranscodingJobType.Progressive);
- var isTranscodeCached = outputPathExists && transcodingJob != null;
+ var isTranscodeCached = outputPathExists && transcodingJob is not null;
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, streamingRequest.Static || isTranscodeCached, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);
diff --git a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
index fa392e567..010b181f7 100644
--- a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
+++ b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
@@ -117,7 +117,7 @@ namespace Jellyfin.Api.Helpers
TranscodingJobType transcodingJobType,
CancellationTokenSource cancellationTokenSource)
{
- if (_httpContextAccessor.HttpContext == null)
+ if (_httpContextAccessor.HttpContext is null)
{
throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext));
}
@@ -183,7 +183,7 @@ namespace Jellyfin.Api.Helpers
: null;
// If we're burning in subtitles then don't add additional subs to the manifest
- if (state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
+ if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
{
subtitleGroup = null;
}
@@ -195,8 +195,15 @@ namespace Jellyfin.Api.Helpers
var basicPlaylist = AppendPlaylist(builder, state, playlistUrl, totalBitrate, subtitleGroup);
- if (state.VideoStream != null && state.VideoRequest != null)
+ if (state.VideoStream is not null && state.VideoRequest is not null)
{
+ // Provide a workaround for the case issue between flac and fLaC.
+ var flacWaPlaylist = ApplyFlacCaseWorkaround(state, basicPlaylist.ToString());
+ if (!string.IsNullOrEmpty(flacWaPlaylist))
+ {
+ builder.Append(flacWaPlaylist);
+ }
+
// Provide SDR HEVC entrance for backward compatibility.
if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
&& !string.IsNullOrEmpty(state.VideoStream.VideoRange)
@@ -204,7 +211,7 @@ namespace Jellyfin.Api.Helpers
&& string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase))
{
var requestedVideoProfiles = state.GetRequestedProfiles("hevc");
- if (requestedVideoProfiles != null && requestedVideoProfiles.Length > 0)
+ if (requestedVideoProfiles is not null && requestedVideoProfiles.Length > 0)
{
// Force HEVC Main Profile and disable video stream copy.
state.OutputVideoCodec = "hevc";
@@ -215,7 +222,14 @@ namespace Jellyfin.Api.Helpers
var sdrOutputAudioBitrate = _encodingHelper.GetAudioBitrateParam(state.VideoRequest, state.AudioStream) ?? 0;
var sdrTotalBitrate = sdrOutputAudioBitrate + sdrOutputVideoBitrate;
- AppendPlaylist(builder, state, sdrVideoUrl, sdrTotalBitrate, subtitleGroup);
+ var sdrPlaylist = AppendPlaylist(builder, state, sdrVideoUrl, sdrTotalBitrate, subtitleGroup);
+
+ // Provide a workaround for the case issue between flac and fLaC.
+ flacWaPlaylist = ApplyFlacCaseWorkaround(state, sdrPlaylist.ToString());
+ if (!string.IsNullOrEmpty(flacWaPlaylist))
+ {
+ builder.Append(flacWaPlaylist);
+ }
// Restore the video codec
state.OutputVideoCodec = "copy";
@@ -245,12 +259,19 @@ namespace Jellyfin.Api.Helpers
state.VideoStream.Level = originalLevel;
var newPlaylist = ReplacePlaylistCodecsField(basicPlaylist, playlistCodecsField, newPlaylistCodecsField);
builder.Append(newPlaylist);
+
+ // Provide a workaround for the case issue between flac and fLaC.
+ flacWaPlaylist = ApplyFlacCaseWorkaround(state, newPlaylist);
+ if (!string.IsNullOrEmpty(flacWaPlaylist))
+ {
+ builder.Append(flacWaPlaylist);
+ }
}
}
if (EnableAdaptiveBitrateStreaming(state, isLiveStream, enableAdaptiveBitrateStreaming, _httpContextAccessor.HttpContext.GetNormalizedRemoteIp()))
{
- var requestedVideoBitrate = state.VideoRequest == null ? 0 : state.VideoRequest.VideoBitRate ?? 0;
+ var requestedVideoBitrate = state.VideoRequest is null ? 0 : state.VideoRequest.VideoBitRate ?? 0;
// By default, vary by just 200k
var variation = GetBitrateVariation(totalBitrate);
@@ -306,7 +327,7 @@ namespace Jellyfin.Api.Helpers
/// <param name="state">StreamState of the current stream.</param>
private void AppendPlaylistVideoRangeField(StringBuilder builder, StreamState state)
{
- if (state.VideoStream != null && !string.IsNullOrEmpty(state.VideoStream.VideoRange))
+ if (state.VideoStream is not null && !string.IsNullOrEmpty(state.VideoStream.VideoRange))
{
var videoRange = state.VideoStream.VideoRange;
if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
@@ -404,7 +425,7 @@ namespace Jellyfin.Api.Helpers
{
framerate = Math.Round(state.TargetFramerate.GetValueOrDefault(), 3);
}
- else if (state.VideoStream?.RealFrameRate != null)
+ else if (state.VideoStream?.RealFrameRate is not null)
{
framerate = Math.Round(state.VideoStream.RealFrameRate.GetValueOrDefault(), 3);
}
@@ -462,7 +483,7 @@ namespace Jellyfin.Api.Helpers
return;
}
- var selectedIndex = state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Hls ? (int?)null : state.SubtitleStream.Index;
+ var selectedIndex = state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Hls ? (int?)null : state.SubtitleStream.Index;
const string Format = "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"subs\",NAME=\"{0}\",DEFAULT={1},FORCED={2},AUTOSELECT=YES,URI=\"{3}\",LANGUAGE=\"{4}\"";
foreach (var stream in subtitles)
@@ -502,7 +523,7 @@ namespace Jellyfin.Api.Helpers
{
string levelString = string.Empty;
if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
- && state.VideoStream != null
+ && state.VideoStream is not null
&& state.VideoStream.Level.HasValue)
{
levelString = state.VideoStream.Level.ToString() ?? string.Empty;
@@ -603,6 +624,11 @@ namespace Jellyfin.Api.Helpers
return HlsCodecStringHelpers.GetALACString();
}
+ if (string.Equals(state.ActualOutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase))
+ {
+ return HlsCodecStringHelpers.GetOPUSString();
+ }
+
return string.Empty;
}
@@ -701,7 +727,19 @@ namespace Jellyfin.Api.Helpers
return oldPlaylist.Replace(
oldValue.ToString(),
newValue.ToString(),
- StringComparison.OrdinalIgnoreCase);
+ StringComparison.Ordinal);
+ }
+
+ private string ApplyFlacCaseWorkaround(StreamState state, string srcPlaylist)
+ {
+ if (!string.Equals(state.ActualOutputAudioCodec, "flac", StringComparison.OrdinalIgnoreCase))
+ {
+ return string.Empty;
+ }
+
+ var newPlaylist = srcPlaylist.Replace(",flac\"", ",fLaC\"", StringComparison.Ordinal);
+
+ return newPlaylist.Contains(",fLaC\"", StringComparison.Ordinal) ? newPlaylist : string.Empty;
}
}
}
diff --git a/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs b/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs
index a5369c441..cbe82979b 100644
--- a/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs
+++ b/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs
@@ -27,7 +27,7 @@ namespace Jellyfin.Api.Helpers
/// <summary>
/// Codec name for FLAC.
/// </summary>
- public const string FLAC = "fLaC";
+ public const string FLAC = "flac";
/// <summary>
/// Codec name for ALAC.
@@ -35,6 +35,11 @@ namespace Jellyfin.Api.Helpers
public const string ALAC = "alac";
/// <summary>
+ /// Codec name for OPUS.
+ /// </summary>
+ public const string OPUS = "opus";
+
+ /// <summary>
/// Gets a MP3 codec string.
/// </summary>
/// <returns>MP3 codec string.</returns>
@@ -102,6 +107,15 @@ namespace Jellyfin.Api.Helpers
}
/// <summary>
+ /// Gets an OPUS codec string.
+ /// </summary>
+ /// <returns>OPUS codec string.</returns>
+ public static string GetOPUSString()
+ {
+ return OPUS;
+ }
+
+ /// <summary>
/// Gets a H.264 codec string.
/// </summary>
/// <param name="profile">H.264 profile.</param>
diff --git a/Jellyfin.Api/Helpers/HlsHelpers.cs b/Jellyfin.Api/Helpers/HlsHelpers.cs
index 456762147..671107c1f 100644
--- a/Jellyfin.Api/Helpers/HlsHelpers.cs
+++ b/Jellyfin.Api/Helpers/HlsHelpers.cs
@@ -46,8 +46,8 @@ namespace Jellyfin.Api.Helpers
while (!reader.EndOfStream)
{
- var line = await reader.ReadLineAsync().ConfigureAwait(false);
- if (line == null)
+ var line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
+ if (line is null)
{
// Nothing currently in buffer.
break;
diff --git a/Jellyfin.Api/Helpers/MediaInfoHelper.cs b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
index 4441ae023..e8ce1ca2a 100644
--- a/Jellyfin.Api/Helpers/MediaInfoHelper.cs
+++ b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
@@ -127,7 +127,7 @@ namespace Jellyfin.Api.Helpers
// Since we're going to be setting properties on MediaSourceInfos that come out of _mediaSourceManager, we should clone it
// Should we move this directly into MediaSourceManager?
var mediaSourcesClone = JsonSerializer.Deserialize<MediaSourceInfo[]>(JsonSerializer.SerializeToUtf8Bytes(mediaSources));
- if (mediaSourcesClone != null)
+ if (mediaSourcesClone is not null)
{
result.MediaSources = mediaSourcesClone;
}
@@ -247,7 +247,7 @@ namespace Jellyfin.Api.Helpers
? streamBuilder.BuildAudioItem(options)
: streamBuilder.BuildVideoItem(options);
- if (streamInfo != null)
+ if (streamInfo is not null)
{
streamInfo.PlaySessionId = playSessionId;
streamInfo.StartPositionTicks = startTimeTicks;
@@ -262,7 +262,7 @@ namespace Jellyfin.Api.Helpers
mediaSource.SupportsTranscoding =
streamInfo.PlayMethod == PlayMethod.DirectStream
- || mediaSource.TranscodingContainer != null
+ || mediaSource.TranscodingContainer is not null
|| profile.TranscodingProfiles.Any(i => i.Type == streamInfo.MediaType && i.Context == options.Context);
if (item is Audio)
@@ -390,16 +390,16 @@ namespace Jellyfin.Api.Helpers
var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false);
var profile = request.DeviceProfile;
- if (profile == null)
+ if (profile is null)
{
var clientCapabilities = _deviceManager.GetCapabilities(httpContext.User.GetDeviceId());
- if (clientCapabilities != null)
+ if (clientCapabilities is not null)
{
profile = clientCapabilities.DeviceProfile;
}
}
- if (profile != null)
+ if (profile is not null)
{
var item = _libraryManager.GetItemById(request.ItemId);
@@ -431,7 +431,7 @@ namespace Jellyfin.Api.Helpers
}
}
- // here was a check if (result.MediaSource != null) but Rider said it will never be null
+ // here was a check if (result.MediaSource is not null) but Rider said it will never be null
NormalizeMediaSourceContainer(result.MediaSource, profile!, DlnaProfileType.Video);
return result;
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
index 6f5b64ea8..dfeeea2b0 100644
--- a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
+++ b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
@@ -151,7 +151,7 @@ namespace Jellyfin.Api.Helpers
{
_stream.Dispose();
- if (_job != null)
+ if (_job is not null)
{
_transcodingJobHelper?.OnTranscodeEndRequest(_job);
}
@@ -166,7 +166,7 @@ namespace Jellyfin.Api.Helpers
private void UpdateBytesWritten(int totalBytesRead)
{
- if (_job != null)
+ if (_job is not null)
{
_job.BytesDownloaded += totalBytesRead;
}
diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs
index 8c5af013a..035d84513 100644
--- a/Jellyfin.Api/Helpers/RequestHelpers.cs
+++ b/Jellyfin.Api/Helpers/RequestHelpers.cs
@@ -96,7 +96,7 @@ namespace Jellyfin.Api.Helpers
httpContext.GetNormalizedRemoteIp().ToString(),
user).ConfigureAwait(false);
- if (session == null)
+ if (session is null)
{
throw new ArgumentException("Session not found.");
}
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index c8e62999c..d4fc9c020 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -76,7 +76,7 @@ namespace Jellyfin.Api.Helpers
}
streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query);
- if (httpRequest.Path.Value == null)
+ if (httpRequest.Path.Value is null)
{
throw new ResourceNotFoundException(nameof(httpRequest.Path));
}
@@ -137,12 +137,12 @@ namespace Jellyfin.Api.Helpers
? transcodingJobHelper.GetTranscodingJob(streamingRequest.PlaySessionId)
: null;
- if (currentJob != null)
+ if (currentJob is not null)
{
mediaSource = currentJob.MediaSource;
}
- if (mediaSource == null)
+ if (mediaSource is null)
{
var mediaSources = await mediaSourceManager.GetPlaybackMediaSources(libraryManager.GetItemById(streamingRequest.Id), null, false, false, cancellationToken).ConfigureAwait(false);
@@ -150,7 +150,7 @@ namespace Jellyfin.Api.Helpers
? mediaSources[0]
: mediaSources.Find(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.Ordinal));
- if (mediaSource == null && Guid.Parse(streamingRequest.MediaSourceId).Equals(streamingRequest.Id))
+ if (mediaSource is null && Guid.Parse(streamingRequest.MediaSourceId).Equals(streamingRequest.Id))
{
mediaSource = mediaSources[0];
}
@@ -189,7 +189,7 @@ namespace Jellyfin.Api.Helpers
state.OutputAudioChannels = encodingHelper.GetNumAudioChannelsParam(state, state.AudioStream, state.OutputAudioCodec);
- if (state.VideoRequest != null)
+ if (state.VideoRequest is not null)
{
state.OutputVideoCodec = state.Request.VideoCodec;
state.OutputVideoBitrate = encodingHelper.GetVideoBitrateParamValue(state.VideoRequest, state.VideoStream, state.OutputVideoCodec);
@@ -204,7 +204,7 @@ namespace Jellyfin.Api.Helpers
&& !state.VideoRequest.MaxHeight.HasValue;
if (isVideoResolutionNotRequested
- && state.VideoStream != null
+ && state.VideoStream is not null
&& state.VideoRequest.VideoBitRate.HasValue
&& state.VideoStream.BitRate.HasValue
&& state.VideoRequest.VideoBitRate.Value >= state.VideoStream.BitRate.Value)
@@ -281,7 +281,7 @@ namespace Jellyfin.Api.Helpers
Convert.ToInt32(ms)));
}
- if (!isStaticallyStreamed && profile != null)
+ if (!isStaticallyStreamed && profile is not null)
{
AddTimeSeekResponseHeaders(state, responseHeaders, startTimeTicks);
}
@@ -364,9 +364,9 @@ namespace Jellyfin.Api.Helpers
/// </summary>
/// <param name="queryString">The query string.</param>
/// <returns>A <see cref="Dictionary{String,String}"/> containing the stream options.</returns>
- private static Dictionary<string, string> ParseStreamOptions(IQueryCollection queryString)
+ private static Dictionary<string, string?> ParseStreamOptions(IQueryCollection queryString)
{
- Dictionary<string, string> streamOptions = new Dictionary<string, string>();
+ Dictionary<string, string?> streamOptions = new Dictionary<string, string?>();
foreach (var param in queryString)
{
if (char.IsLower(param.Key[0]))
@@ -510,16 +510,16 @@ namespace Jellyfin.Api.Helpers
{
state.DeviceProfile = dlnaManager.GetProfile(deviceProfileId);
- if (state.DeviceProfile == null)
+ if (state.DeviceProfile is null)
{
var caps = deviceManager.GetCapabilities(deviceProfileId);
- state.DeviceProfile = caps == null ? dlnaManager.GetProfile(request.Headers) : caps.DeviceProfile;
+ state.DeviceProfile = caps is null ? dlnaManager.GetProfile(request.Headers) : caps.DeviceProfile;
}
}
var profile = state.DeviceProfile;
- if (profile == null)
+ if (profile is null)
{
// Don't use settings from the default profile.
// Only use a specific profile if it was requested.
@@ -553,7 +553,7 @@ namespace Jellyfin.Api.Helpers
state.TargetVideoCodecTag,
state.IsTargetAVC);
- if (mediaProfile != null)
+ if (mediaProfile is not null)
{
state.MimeType = mediaProfile.MimeType;
}
@@ -562,13 +562,13 @@ namespace Jellyfin.Api.Helpers
{
var transcodingProfile = !state.IsVideoRequest ? profile.GetAudioTranscodingProfile(state.OutputContainer, audioCodec) : profile.GetVideoTranscodingProfile(state.OutputContainer, audioCodec, videoCodec);
- if (transcodingProfile != null)
+ if (transcodingProfile is not null)
{
state.EstimateContentLength = transcodingProfile.EstimateContentLength;
// state.EnableMpegtsM2TsMode = transcodingProfile.EnableMpegtsM2TsMode;
state.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;
- if (state.VideoRequest != null)
+ if (state.VideoRequest is not null)
{
state.VideoRequest.CopyTimestamps = transcodingProfile.CopyTimestamps;
state.VideoRequest.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest;
@@ -616,7 +616,7 @@ namespace Jellyfin.Api.Helpers
request.Static = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
break;
case 4:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.VideoCodec = val;
}
@@ -626,21 +626,21 @@ namespace Jellyfin.Api.Helpers
request.AudioCodec = val;
break;
case 6:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.AudioStreamIndex = int.Parse(val, CultureInfo.InvariantCulture);
}
break;
case 7:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.SubtitleStreamIndex = int.Parse(val, CultureInfo.InvariantCulture);
}
break;
case 8:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.VideoBitRate = int.Parse(val, CultureInfo.InvariantCulture);
}
@@ -653,21 +653,21 @@ namespace Jellyfin.Api.Helpers
request.MaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture);
break;
case 11:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.MaxFramerate = float.Parse(val, CultureInfo.InvariantCulture);
}
break;
case 12:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.MaxWidth = int.Parse(val, CultureInfo.InvariantCulture);
}
break;
case 13:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.MaxHeight = int.Parse(val, CultureInfo.InvariantCulture);
}
@@ -677,28 +677,28 @@ namespace Jellyfin.Api.Helpers
request.StartTimeTicks = long.Parse(val, CultureInfo.InvariantCulture);
break;
case 15:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.Level = val;
}
break;
case 16:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.MaxRefFrames = int.Parse(val, CultureInfo.InvariantCulture);
}
break;
case 17:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.MaxVideoBitDepth = int.Parse(val, CultureInfo.InvariantCulture);
}
break;
case 18:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.Profile = val;
}
@@ -720,14 +720,14 @@ namespace Jellyfin.Api.Helpers
// Duplicating ItemId because of MediaMonkey
break;
case 24:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.CopyTimestamps = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
break;
case 25:
- if (!string.IsNullOrWhiteSpace(val) && videoRequest != null)
+ if (!string.IsNullOrWhiteSpace(val) && videoRequest is not null)
{
if (Enum.TryParse(val, out SubtitleDeliveryMethod method))
{
@@ -740,7 +740,7 @@ namespace Jellyfin.Api.Helpers
request.TranscodingMaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture);
break;
case 27:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
@@ -750,7 +750,7 @@ namespace Jellyfin.Api.Helpers
request.Tag = val;
break;
case 29:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
@@ -760,14 +760,14 @@ namespace Jellyfin.Api.Helpers
request.SubtitleCodec = val;
break;
case 31:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.RequireNonAnamorphic = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
break;
case 32:
- if (videoRequest != null)
+ if (videoRequest is not null)
{
videoRequest.DeInterlace = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
index c663c6e31..77dd51860 100644
--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
@@ -136,10 +136,7 @@ namespace Jellyfin.Api.Helpers
/// <exception cref="ArgumentNullException">Play session id is null.</exception>
public void PingTranscodingJob(string playSessionId, bool? isUserPaused)
{
- if (string.IsNullOrEmpty(playSessionId))
- {
- throw new ArgumentNullException(nameof(playSessionId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(playSessionId);
_logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused);
@@ -416,7 +413,7 @@ namespace Jellyfin.Api.Helpers
}
}
- if (exs != null)
+ if (exs is not null)
{
throw new AggregateException("Error deleting HLS files", exs);
}
@@ -443,7 +440,7 @@ namespace Jellyfin.Api.Helpers
{
var ticks = transcodingPosition?.Ticks;
- if (job != null)
+ if (job is not null)
{
job.Framerate = framerate;
job.CompletionPercentage = percentComplete;
@@ -510,11 +507,11 @@ namespace Jellyfin.Api.Helpers
await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);
- if (state.VideoRequest != null && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
+ if (state.VideoRequest is not null && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
{
var userId = request.HttpContext.User.GetUserId();
var user = userId.Equals(default) ? null : _userManager.GetUserById(userId);
- if (user != null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding))
+ if (user is not null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding))
{
this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);
@@ -522,13 +519,10 @@ namespace Jellyfin.Api.Helpers
}
}
- if (string.IsNullOrEmpty(_mediaEncoder.EncoderPath))
- {
- throw new ArgumentException("FFmpeg path not set.");
- }
+ ArgumentException.ThrowIfNullOrEmpty(_mediaEncoder.EncoderPath);
// If subtitles get burned in fonts may need to be extracted from the media file
- if (state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
+ if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
{
var attachmentPath = Path.Combine(_appPaths.CachePath, "attachments", state.MediaSource.Id);
await _attachmentExtractor.ExtractAllAttachments(state.MediaPath, state.MediaSource, attachmentPath, cancellationTokenSource.Token).ConfigureAwait(false);
@@ -577,7 +571,7 @@ namespace Jellyfin.Api.Helpers
_logger.LogInformation("{Filename} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
var logFilePrefix = "FFmpeg.Transcode-";
- if (state.VideoRequest != null
+ if (state.VideoRequest is not null
&& EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
{
logFilePrefix = EncodingHelper.IsCopyCodec(state.OutputAudioCodec)
@@ -748,7 +742,7 @@ namespace Jellyfin.Api.Helpers
{
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && string.Equals(j.Path, path, StringComparison.OrdinalIgnoreCase));
- if (job != null)
+ if (job is not null)
{
_activeTranscodingJobs.Remove(job);
}
@@ -805,7 +799,7 @@ namespace Jellyfin.Api.Helpers
_encodingHelper.AttachMediaSourceInfo(state, encodingOptions, liveStreamResponse.MediaSource, state.RequestedUrl);
- if (state.VideoRequest != null)
+ if (state.VideoRequest is not null)
{
_encodingHelper.TryStreamCopy(state);
}
@@ -829,7 +823,7 @@ namespace Jellyfin.Api.Helpers
{
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && string.Equals(j.Path, path, StringComparison.OrdinalIgnoreCase));
- if (job == null)
+ if (job is null)
{
return null;
}
diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj
index a4502b612..0317a2f2b 100644
--- a/Jellyfin.Api/Jellyfin.Api.csproj
+++ b/Jellyfin.Api/Jellyfin.Api.csproj
@@ -6,19 +6,19 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->
<NoWarn>AD0001</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.11" />
- <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="6.4.0" />
</ItemGroup>
diff --git a/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs b/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs
index c04f3c721..75e47a71b 100644
--- a/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs
+++ b/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs
@@ -40,7 +40,7 @@ namespace Jellyfin.Api.ModelBinders
{
var value = valueProviderResult.FirstValue;
- if (value != null)
+ if (value is not null)
{
var splitValues = value.Split(',', StringSplitOptions.RemoveEmptyEntries);
var typedValues = GetParsedResult(splitValues, elementType, converter);
diff --git a/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs b/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs
index 2ccfd0c06..da0addd0e 100644
--- a/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs
+++ b/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs
@@ -14,7 +14,7 @@ namespace Jellyfin.Api.ModelBinders
public IModelBinder? GetBinder(ModelBinderProviderContext context)
{
var nullableType = Nullable.GetUnderlyingType(context.Metadata.ModelType);
- if (nullableType == null || !nullableType.IsEnum)
+ if (nullableType is null || !nullableType.IsEnum)
{
// Type isn't nullable or isn't an enum.
return null;
diff --git a/Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs b/Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs
index 639ab0793..4257ba0e2 100644
--- a/Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs
+++ b/Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs
@@ -40,7 +40,7 @@ namespace Jellyfin.Api.ModelBinders
{
var value = valueProviderResult.FirstValue;
- if (value != null)
+ if (value is not null)
{
var splitValues = value.Split('|', StringSplitOptions.RemoveEmptyEntries);
var typedValues = GetParsedResult(splitValues, elementType, converter);
diff --git a/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs b/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs
index ab67c8732..9060500c8 100644
--- a/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs
+++ b/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs
@@ -189,7 +189,7 @@ namespace Jellyfin.Api.Models.PlaybackDtos
{
lock (_timerLock)
{
- if (KillTimer != null)
+ if (KillTimer is not null)
{
KillTimer.Dispose();
KillTimer = null;
@@ -220,7 +220,7 @@ namespace Jellyfin.Api.Models.PlaybackDtos
lock (_timerLock)
{
- if (KillTimer == null)
+ if (KillTimer is null)
{
Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId);
KillTimer = new Timer(new TimerCallback(callback), this, intervalMs, Timeout.Infinite);
@@ -245,7 +245,7 @@ namespace Jellyfin.Api.Models.PlaybackDtos
lock (_timerLock)
{
- if (KillTimer != null)
+ if (KillTimer is not null)
{
var intervalMs = PingTimeout;
diff --git a/Jellyfin.Api/Models/PlaybackDtos/TranscodingThrottler.cs b/Jellyfin.Api/Models/PlaybackDtos/TranscodingThrottler.cs
index 99376873c..9c4e377cd 100644
--- a/Jellyfin.Api/Models/PlaybackDtos/TranscodingThrottler.cs
+++ b/Jellyfin.Api/Models/PlaybackDtos/TranscodingThrottler.cs
@@ -210,7 +210,7 @@ namespace Jellyfin.Api.Models.PlaybackDtos
private void DisposeTimer()
{
- if (_timer != null)
+ if (_timer is not null)
{
_timer.Dispose();
_timer = null;
diff --git a/Jellyfin.Api/Models/StreamingDtos/StreamState.cs b/Jellyfin.Api/Models/StreamingDtos/StreamState.cs
index 8182e3c9e..1fce1d20a 100644
--- a/Jellyfin.Api/Models/StreamingDtos/StreamState.cs
+++ b/Jellyfin.Api/Models/StreamingDtos/StreamState.cs
@@ -43,7 +43,7 @@ namespace Jellyfin.Api.Models.StreamingDtos
set
{
BaseRequest = value;
- IsVideoRequest = VideoRequest != null;
+ IsVideoRequest = VideoRequest is not null;
}
}
diff --git a/Jellyfin.Data/Entities/ActivityLog.cs b/Jellyfin.Data/Entities/ActivityLog.cs
index 1d1b86552..51dd0ffb8 100644
--- a/Jellyfin.Data/Entities/ActivityLog.cs
+++ b/Jellyfin.Data/Entities/ActivityLog.cs
@@ -20,15 +20,8 @@ namespace Jellyfin.Data.Entities
/// <param name="userId">The user id.</param>
public ActivityLog(string name, string type, Guid userId)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
-
- if (string.IsNullOrEmpty(type))
- {
- throw new ArgumentNullException(nameof(type));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
+ ArgumentException.ThrowIfNullOrEmpty(type);
Name = name;
Type = type;
diff --git a/Jellyfin.Data/Entities/Group.cs b/Jellyfin.Data/Entities/Group.cs
index 14da0bb15..1be6f986a 100644
--- a/Jellyfin.Data/Entities/Group.cs
+++ b/Jellyfin.Data/Entities/Group.cs
@@ -18,10 +18,7 @@ namespace Jellyfin.Data.Entities
/// <param name="name">The name of the group.</param>
public Group(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
Id = Guid.NewGuid();
diff --git a/Jellyfin.Data/Entities/Libraries/Artwork.cs b/Jellyfin.Data/Entities/Libraries/Artwork.cs
index 923525fc5..fc3c1036f 100644
--- a/Jellyfin.Data/Entities/Libraries/Artwork.cs
+++ b/Jellyfin.Data/Entities/Libraries/Artwork.cs
@@ -18,10 +18,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="kind">The kind of art.</param>
public Artwork(string path, ArtKind kind)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
Path = path;
Kind = kind;
diff --git a/Jellyfin.Data/Entities/Libraries/Chapter.cs b/Jellyfin.Data/Entities/Libraries/Chapter.cs
index 3d81f713d..f068338f9 100644
--- a/Jellyfin.Data/Entities/Libraries/Chapter.cs
+++ b/Jellyfin.Data/Entities/Libraries/Chapter.cs
@@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="startTime">The start time for this chapter.</param>
public Chapter(string language, long startTime)
{
- if (string.IsNullOrEmpty(language))
- {
- throw new ArgumentNullException(nameof(language));
- }
+ ArgumentException.ThrowIfNullOrEmpty(language);
Language = language;
StartTime = startTime;
diff --git a/Jellyfin.Data/Entities/Libraries/ItemMetadata.cs b/Jellyfin.Data/Entities/Libraries/ItemMetadata.cs
index d429a90c6..fa9276c66 100644
--- a/Jellyfin.Data/Entities/Libraries/ItemMetadata.cs
+++ b/Jellyfin.Data/Entities/Libraries/ItemMetadata.cs
@@ -18,15 +18,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="language">ISO-639-3 3-character language codes.</param>
protected ItemMetadata(string title, string language)
{
- if (string.IsNullOrEmpty(title))
- {
- throw new ArgumentNullException(nameof(title));
- }
-
- if (string.IsNullOrEmpty(language))
- {
- throw new ArgumentNullException(nameof(language));
- }
+ ArgumentException.ThrowIfNullOrEmpty(title);
+ ArgumentException.ThrowIfNullOrEmpty(language);
Title = title;
Language = language;
diff --git a/Jellyfin.Data/Entities/Libraries/MediaFile.cs b/Jellyfin.Data/Entities/Libraries/MediaFile.cs
index 36e1e4777..7b5a3af64 100644
--- a/Jellyfin.Data/Entities/Libraries/MediaFile.cs
+++ b/Jellyfin.Data/Entities/Libraries/MediaFile.cs
@@ -19,10 +19,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="kind">The file kind.</param>
public MediaFile(string path, MediaFileKind kind)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
Path = path;
Kind = kind;
diff --git a/Jellyfin.Data/Entities/Libraries/MetadataProvider.cs b/Jellyfin.Data/Entities/Libraries/MetadataProvider.cs
index b27196078..b38d6a4f1 100644
--- a/Jellyfin.Data/Entities/Libraries/MetadataProvider.cs
+++ b/Jellyfin.Data/Entities/Libraries/MetadataProvider.cs
@@ -16,10 +16,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="name">The name of the metadata provider.</param>
public MetadataProvider(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
}
diff --git a/Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs b/Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs
index 44c198518..a198f53ba 100644
--- a/Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs
+++ b/Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs
@@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="metadataProvider">The metadata provider.</param>
public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
{
- if (string.IsNullOrEmpty(providerId))
- {
- throw new ArgumentNullException(nameof(providerId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(providerId);
ProviderId = providerId;
MetadataProvider = metadataProvider;
diff --git a/Jellyfin.Data/Entities/Libraries/Person.cs b/Jellyfin.Data/Entities/Libraries/Person.cs
index 8b67d920d..90dc55b70 100644
--- a/Jellyfin.Data/Entities/Libraries/Person.cs
+++ b/Jellyfin.Data/Entities/Libraries/Person.cs
@@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="name">The name of the person.</param>
public Person(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
DateAdded = DateTime.UtcNow;
diff --git a/Jellyfin.Data/Entities/Libraries/Release.cs b/Jellyfin.Data/Entities/Libraries/Release.cs
index d3d52bf5c..e68ab9105 100644
--- a/Jellyfin.Data/Entities/Libraries/Release.cs
+++ b/Jellyfin.Data/Entities/Libraries/Release.cs
@@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="name">The name of this release.</param>
public Release(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
diff --git a/Jellyfin.Data/Entities/User.cs b/Jellyfin.Data/Entities/User.cs
index 26c46a704..eb59e70f3 100644
--- a/Jellyfin.Data/Entities/User.cs
+++ b/Jellyfin.Data/Entities/User.cs
@@ -29,20 +29,9 @@ namespace Jellyfin.Data.Entities
/// <param name="passwordResetProviderId">The Id of the user's password reset provider.</param>
public User(string username, string authenticationProviderId, string passwordResetProviderId)
{
- if (string.IsNullOrEmpty(username))
- {
- throw new ArgumentNullException(nameof(username));
- }
-
- if (string.IsNullOrEmpty(authenticationProviderId))
- {
- throw new ArgumentNullException(nameof(authenticationProviderId));
- }
-
- if (string.IsNullOrEmpty(passwordResetProviderId))
- {
- throw new ArgumentNullException(nameof(passwordResetProviderId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(username);
+ ArgumentException.ThrowIfNullOrEmpty(authenticationProviderId);
+ ArgumentException.ThrowIfNullOrEmpty(passwordResetProviderId);
Username = username;
AuthenticationProviderId = authenticationProviderId;
@@ -373,7 +362,7 @@ namespace Jellyfin.Data.Entities
public void SetPermission(PermissionKind kind, bool value)
{
var currentPermission = Permissions.FirstOrDefault(p => p.Kind == kind);
- if (currentPermission == null)
+ if (currentPermission is null)
{
Permissions.Add(new Permission(kind, value));
}
@@ -419,7 +408,7 @@ namespace Jellyfin.Data.Entities
try
{
var parsedValue = converter.ConvertFromString(stringValues[i].Trim());
- if (parsedValue != null)
+ if (parsedValue is not null)
{
parsedValues[convertedCount++] = (T)parsedValue;
}
@@ -442,7 +431,7 @@ namespace Jellyfin.Data.Entities
{
var value = string.Join(Delimiter, values);
var currentPreference = Preferences.FirstOrDefault(p => p.Kind == preference);
- if (currentPreference == null)
+ if (currentPreference is null)
{
Preferences.Add(new Preference(preference, value));
}
@@ -462,7 +451,7 @@ namespace Jellyfin.Data.Entities
{
var value = string.Join(Delimiter, values);
var currentPreference = Preferences.FirstOrDefault(p => p.Kind == preference);
- if (currentPreference == null)
+ if (currentPreference is null)
{
Preferences.Add(new Preference(preference, value));
}
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 47499e038..7fe6466d4 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
@@ -39,7 +39,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
diff --git a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
index 89de998ca..dac3d0a61 100644
--- a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
+++ b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
index 84b261b54..9171c4d6e 100644
--- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs
+++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
@@ -145,12 +145,7 @@ namespace Jellyfin.Drawing.Skia
/// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception>
public string GetImageBlurHash(int xComp, int yComp, string path)
{
- ArgumentNullException.ThrowIfNull(path);
-
- if (path.Length == 0)
- {
- throw new ArgumentException("String can't be empty", nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
var extension = Path.GetExtension(path.AsSpan()).TrimStart('.');
if (!SupportedInputFormats.Contains(extension, StringComparison.OrdinalIgnoreCase))
@@ -250,7 +245,7 @@ namespace Jellyfin.Drawing.Skia
var resultBitmap = SKBitmap.Decode(NormalizePath(path));
- if (resultBitmap == null)
+ if (resultBitmap is null)
{
return Decode(path, true, orientation, out origin);
}
@@ -274,7 +269,7 @@ namespace Jellyfin.Drawing.Skia
{
var bitmap = Decode(path, true, orientation, out var origin);
- if (bitmap != null && origin != SKEncodedOrigin.TopLeft)
+ if (bitmap is not null && origin != SKEncodedOrigin.TopLeft)
{
using (bitmap)
{
@@ -389,15 +384,8 @@ namespace Jellyfin.Drawing.Skia
/// <inheritdoc/>
public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat)
{
- if (inputPath.Length == 0)
- {
- throw new ArgumentException("String can't be empty.", nameof(inputPath));
- }
-
- if (outputPath.Length == 0)
- {
- throw new ArgumentException("String can't be empty.", nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
var inputFormat = Path.GetExtension(inputPath.AsSpan()).TrimStart('.');
if (!SupportedInputFormats.Contains(inputFormat, StringComparison.OrdinalIgnoreCase))
@@ -414,7 +402,7 @@ namespace Jellyfin.Drawing.Skia
var hasIndicator = options.AddPlayedIndicator || options.UnplayedCount.HasValue || !options.PercentPlayed.Equals(0);
using var bitmap = GetBitmap(inputPath, autoOrient, orientation);
- if (bitmap == null)
+ if (bitmap is null)
{
throw new InvalidDataException($"Skia unable to read image {inputPath}");
}
diff --git a/Jellyfin.Drawing.Skia/SkiaHelper.cs b/Jellyfin.Drawing.Skia/SkiaHelper.cs
index 0478fc7c3..23e92dcb2 100644
--- a/Jellyfin.Drawing.Skia/SkiaHelper.cs
+++ b/Jellyfin.Drawing.Skia/SkiaHelper.cs
@@ -34,7 +34,7 @@ namespace Jellyfin.Drawing.Skia
currentIndex++;
- if (bitmap != null)
+ if (bitmap is not null)
{
break;
}
diff --git a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs
index e5fa6c2bd..7fbae3349 100644
--- a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs
+++ b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs
@@ -85,7 +85,7 @@ namespace Jellyfin.Drawing.Skia
break;
}
- if (currentImage == null)
+ if (currentImage is null)
{
throw new ArgumentException("Not enough valid pictures provided to create a splashscreen!");
}
diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
index b55a99405..c8b8f3ace 100644
--- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
+++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
@@ -97,7 +97,7 @@ namespace Jellyfin.Drawing.Skia
canvas.Clear(SKColors.Black);
using var backdrop = SkiaHelper.GetNextValidImage(_skiaEncoder, paths, 0, out _);
- if (backdrop == null)
+ if (backdrop is null)
{
return bitmap;
}
@@ -164,7 +164,7 @@ namespace Jellyfin.Drawing.Skia
using var currentBitmap = SkiaHelper.GetNextValidImage(_skiaEncoder, paths, imageIndex, out int newIndex);
imageIndex = newIndex;
- if (currentBitmap == null)
+ if (currentBitmap is null)
{
continue;
}
diff --git a/Jellyfin.Networking/Jellyfin.Networking.csproj b/Jellyfin.Networking/Jellyfin.Networking.csproj
index d05072152..975d1c8ce 100644
--- a/Jellyfin.Networking/Jellyfin.Networking.csproj
+++ b/Jellyfin.Networking/Jellyfin.Networking.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
index eeb958c62..15ac5c668 100644
--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
@@ -55,7 +55,7 @@ namespace Jellyfin.Server.Implementations.Devices
await using (dbContext.ConfigureAwait(false))
{
deviceOptions = await dbContext.DeviceOptions.AsQueryable().FirstOrDefaultAsync(dev => dev.DeviceId == deviceId).ConfigureAwait(false);
- if (deviceOptions == null)
+ if (deviceOptions is null)
{
deviceOptions = new DeviceOptions(deviceId);
dbContext.DeviceOptions.Add(deviceOptions);
@@ -121,7 +121,7 @@ namespace Jellyfin.Server.Implementations.Devices
.ConfigureAwait(false);
}
- var deviceInfo = device == null ? null : ToDeviceInfo(device);
+ var deviceInfo = device is null ? null : ToDeviceInfo(device);
return deviceInfo;
}
@@ -139,12 +139,12 @@ namespace Jellyfin.Server.Implementations.Devices
devices = devices.Where(device => device.UserId.Equals(query.UserId.Value));
}
- if (query.DeviceId != null)
+ if (query.DeviceId is not null)
{
devices = devices.Where(device => device.DeviceId == query.DeviceId);
}
- if (query.AccessToken != null)
+ if (query.AccessToken is not null)
{
devices = devices.Where(device => device.AccessToken == query.AccessToken);
}
@@ -222,11 +222,7 @@ namespace Jellyfin.Server.Implementations.Devices
public bool CanAccessDevice(User user, string deviceId)
{
ArgumentNullException.ThrowIfNull(user);
-
- if (string.IsNullOrEmpty(deviceId))
- {
- throw new ArgumentNullException(nameof(deviceId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(deviceId);
if (user.HasPermission(PermissionKind.EnableAllDevices) || user.HasPermission(PermissionKind.IsAdministrator))
{
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
index aa6015caa..aeb62e814 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
@@ -38,13 +38,13 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
/// <inheritdoc />
public async Task OnEvent(PlaybackStartEventArgs eventArgs)
{
- if (eventArgs.MediaInfo == null)
+ if (eventArgs.MediaInfo is null)
{
_logger.LogWarning("PlaybackStart reported with null media info.");
return;
}
- if (eventArgs.Item != null && eventArgs.Item.IsThemeMedia)
+ if (eventArgs.Item is not null && eventArgs.Item.IsThemeMedia)
{
// Don't report theme song or local trailer playback
return;
@@ -78,7 +78,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
name = item.SeriesName + " - " + name;
}
- if (item.Artists != null && item.Artists.Count > 0)
+ if (item.Artists is not null && item.Artists.Count > 0)
{
name = item.Artists[0] + " - " + name;
}
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
index 1648b1b47..dd7290fb8 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
@@ -40,13 +40,13 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
{
var item = eventArgs.MediaInfo;
- if (item == null)
+ if (item is null)
{
_logger.LogWarning("PlaybackStopped reported with null media info.");
return;
}
- if (eventArgs.Item != null && eventArgs.Item.IsThemeMedia)
+ if (eventArgs.Item is not null && eventArgs.Item.IsThemeMedia)
{
// Don't report theme song or local trailer playback
return;
@@ -60,7 +60,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
var user = eventArgs.Users[0];
var notificationType = GetPlaybackStoppedNotificationType(item.MediaType);
- if (notificationType == null)
+ if (notificationType is null)
{
return;
}
@@ -86,7 +86,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
name = item.SeriesName + " - " + name;
}
- if (item.Artists != null && item.Artists.Count > 0)
+ if (item.Artists is not null && item.Artists.Count > 0)
{
name = item.Artists[0] + " - " + name;
}
diff --git a/Jellyfin.Server.Implementations/Events/EventManager.cs b/Jellyfin.Server.Implementations/Events/EventManager.cs
index 7f7c4750d..f49ae8e27 100644
--- a/Jellyfin.Server.Implementations/Events/EventManager.cs
+++ b/Jellyfin.Server.Implementations/Events/EventManager.cs
@@ -44,7 +44,7 @@ namespace Jellyfin.Server.Implementations.Events
where T : EventArgs
{
using var scope = _appHost.ServiceProvider?.CreateScope();
- if (scope == null)
+ if (scope is null)
{
return;
}
diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
index f98a0aede..05c622931 100644
--- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
+++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
@@ -27,7 +27,7 @@ public static class ServiceCollectionExtensions
.UseCacheKeyPrefix("EF_")
// Don't cache null values. Remove this optional setting if it's not necessary.
.SkipCachingResults(result =>
- result.Value == null || (result.Value is EFTableRows rows && rows.RowsCount == 0)));
+ result.Value is null || (result.Value is EFTableRows rows && rows.RowsCount == 0)));
serviceCollection.AddPooledDbContextFactory<JellyfinDb>((serviceProvider, opt) =>
{
diff --git a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
index 73e9a5882..d233c00a0 100644
--- a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
+++ b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<!-- Code analysers-->
@@ -28,13 +28,13 @@
<ItemGroup>
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="3.8.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.11" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.11" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.11">
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
- <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.11">
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
diff --git a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
index 33c08c8c2..810e57807 100644
--- a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
@@ -65,7 +65,7 @@ namespace Jellyfin.Server.Implementations.Security
.FirstOrDefaultAsync()
.ConfigureAwait(false);
- if (key == null)
+ if (key is null)
{
return;
}
diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
index 4d1a1b3cf..ec5742bab 100644
--- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
@@ -32,7 +32,7 @@ namespace Jellyfin.Server.Implementations.Security
public Task<AuthorizationInfo> GetAuthorizationInfo(HttpContext requestContext)
{
- if (requestContext.Request.HttpContext.Items.TryGetValue("AuthorizationInfo", out var cached) && cached != null)
+ if (requestContext.Request.HttpContext.Items.TryGetValue("AuthorizationInfo", out var cached) && cached is not null)
{
return Task.FromResult((AuthorizationInfo)cached); // Cache should never contain null
}
@@ -72,7 +72,7 @@ namespace Jellyfin.Server.Implementations.Security
string? version = null;
string? token = null;
- if (auth != null)
+ if (auth is not null)
{
auth.TryGetValue("DeviceId", out deviceId);
auth.TryGetValue("Device", out deviceName);
@@ -127,7 +127,7 @@ namespace Jellyfin.Server.Implementations.Security
{
var device = await dbContext.Devices.FirstOrDefaultAsync(d => d.AccessToken == token).ConfigureAwait(false);
- if (device != null)
+ if (device is not null)
{
authInfo.IsAuthenticated = true;
var updateToken = false;
@@ -189,7 +189,7 @@ namespace Jellyfin.Server.Implementations.Security
else
{
var key = await dbContext.ApiKeys.FirstOrDefaultAsync(apiKey => apiKey.AccessToken == token).ConfigureAwait(false);
- if (key != null)
+ if (key is not null)
{
authInfo.IsAuthenticated = true;
authInfo.Client = key.Name;
diff --git a/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs b/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs
index 7480a05c2..72f3d6e8e 100644
--- a/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs
+++ b/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs
@@ -41,7 +41,7 @@ namespace Jellyfin.Server.Implementations.Users
// This is the version that we need to use for local users. Because reasons.
public Task<ProviderAuthenticationResult> Authenticate(string username, string password, User resolvedUser)
{
- if (resolvedUser == null)
+ if (resolvedUser is null)
{
throw new AuthenticationException("Specified user does not exist.");
}
@@ -58,7 +58,7 @@ namespace Jellyfin.Server.Implementations.Users
}
// Handle the case when the stored password is null, but the user tried to login with a password
- if (resolvedUser.Password == null)
+ if (resolvedUser.Password is null)
{
throw new AuthenticationException("Invalid username or password");
}
diff --git a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
index 87babc05c..fddad1c4f 100644
--- a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
+++ b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
@@ -34,7 +34,7 @@ namespace Jellyfin.Server.Implementations.Users
.FirstOrDefault(pref =>
pref.UserId.Equals(userId) && string.Equals(pref.Client, client) && pref.ItemId.Equals(itemId));
- if (prefs == null)
+ if (prefs is null)
{
prefs = new DisplayPreferences(userId, itemId, client);
_dbContext.DisplayPreferences.Add(prefs);
@@ -49,7 +49,7 @@ namespace Jellyfin.Server.Implementations.Users
var prefs = _dbContext.ItemDisplayPreferences
.FirstOrDefault(pref => pref.UserId.Equals(userId) && pref.ItemId.Equals(itemId) && string.Equals(pref.Client, client));
- if (prefs == null)
+ if (prefs is null)
{
prefs = new ItemDisplayPreferences(userId, Guid.Empty, client);
_dbContext.ItemDisplayPreferences.Add(prefs);
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs
index 25560707a..ae3fcad29 100644
--- a/Jellyfin.Server.Implementations/Users/UserManager.cs
+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs
@@ -286,7 +286,7 @@ namespace Jellyfin.Server.Implementations.Users
/// <inheritdoc/>
public async Task ChangeEasyPassword(User user, string newPassword, string? newPasswordSha1)
{
- if (newPassword != null)
+ if (newPassword is not null)
{
newPasswordSha1 = _cryptoProvider.CreatePasswordHash(newPassword).ToString();
}
@@ -317,7 +317,7 @@ namespace Jellyfin.Server.Implementations.Users
EnableAutoLogin = user.EnableAutoLogin,
LastLoginDate = user.LastLoginDate,
LastActivityDate = user.LastActivityDate,
- PrimaryImageTag = user.ProfileImage != null ? _imageProcessor.GetImageCacheTag(user) : null,
+ PrimaryImageTag = user.ProfileImage is not null ? _imageProcessor.GetImageCacheTag(user) : null,
Configuration = new UserConfiguration
{
SubtitleMode = user.SubtitleMode,
@@ -401,12 +401,12 @@ namespace Jellyfin.Server.Implementations.Users
var authenticationProvider = authResult.AuthenticationProvider;
var success = authResult.Success;
- if (user == null)
+ if (user is null)
{
string updatedUsername = authResult.Username;
if (success
- && authenticationProvider != null
+ && authenticationProvider is not null
&& authenticationProvider is not DefaultAuthenticationProvider)
{
// Trust the username returned by the authentication provider
@@ -416,25 +416,25 @@ namespace Jellyfin.Server.Implementations.Users
// the authentication provider might have created it
user = Users.FirstOrDefault(i => string.Equals(username, i.Username, StringComparison.OrdinalIgnoreCase));
- if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy && user != null)
+ if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy && user is not null)
{
await UpdatePolicyAsync(user.Id, hasNewUserPolicy.GetNewUserPolicy()).ConfigureAwait(false);
}
}
}
- if (success && user != null && authenticationProvider != null)
+ if (success && user is not null && authenticationProvider is not null)
{
var providerId = authenticationProvider.GetType().FullName;
- if (providerId != null && !string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase))
+ if (providerId is not null && !string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase))
{
user.AuthenticationProviderId = providerId;
await UpdateUserAsync(user).ConfigureAwait(false);
}
}
- if (user == null)
+ if (user is null)
{
_logger.LogInformation(
"Authentication request for {UserName} has been denied (IP: {IP}).",
@@ -501,7 +501,7 @@ namespace Jellyfin.Server.Implementations.Users
{
var user = string.IsNullOrWhiteSpace(enteredUsername) ? null : GetUserByName(enteredUsername);
- if (user != null && isInNetwork)
+ if (user is not null && isInNetwork)
{
var passwordResetProvider = GetPasswordResetProvider(user);
var result = await passwordResetProvider
@@ -708,7 +708,7 @@ namespace Jellyfin.Server.Implementations.Users
/// <inheritdoc/>
public async Task ClearProfileImageAsync(User user)
{
- if (user.ProfileImage == null)
+ if (user.ProfileImage is null)
{
return;
}
diff --git a/Jellyfin.Server/Filters/FileResponseFilter.cs b/Jellyfin.Server/Filters/FileResponseFilter.cs
index eae9a8004..544fdbfd6 100644
--- a/Jellyfin.Server/Filters/FileResponseFilter.cs
+++ b/Jellyfin.Server/Filters/FileResponseFilter.cs
@@ -31,7 +31,7 @@ namespace Jellyfin.Server.Filters
.FirstOrDefault(o => o.Key.Equals(SuccessCode, StringComparison.Ordinal));
// Operation doesn't have a response.
- if (response.Value == null)
+ if (response.Value is null)
{
continue;
}
diff --git a/Jellyfin.Server/Filters/SecurityRequirementsOperationFilter.cs b/Jellyfin.Server/Filters/SecurityRequirementsOperationFilter.cs
index 077908895..4af670e9a 100644
--- a/Jellyfin.Server/Filters/SecurityRequirementsOperationFilter.cs
+++ b/Jellyfin.Server/Filters/SecurityRequirementsOperationFilter.cs
@@ -22,7 +22,7 @@ namespace Jellyfin.Server.Filters
foreach (var attribute in context.MethodInfo.GetCustomAttributes(true))
{
if (attribute is AuthorizeAttribute authorizeAttribute
- && authorizeAttribute.Policy != null
+ && authorizeAttribute.Policy is not null
&& !requiredScopes.Contains(authorizeAttribute.Policy, StringComparer.Ordinal))
{
requiredScopes.Add(authorizeAttribute.Policy);
@@ -31,12 +31,12 @@ namespace Jellyfin.Server.Filters
// Add controller scopes if any.
var controllerAttributes = context.MethodInfo.DeclaringType?.GetCustomAttributes(true);
- if (controllerAttributes != null)
+ if (controllerAttributes is not null)
{
foreach (var attribute in controllerAttributes)
{
if (attribute is AuthorizeAttribute authorizeAttribute
- && authorizeAttribute.Policy != null
+ && authorizeAttribute.Policy is not null
&& !requiredScopes.Contains(authorizeAttribute.Policy, StringComparer.Ordinal))
{
requiredScopes.Add(authorizeAttribute.Policy);
diff --git a/Jellyfin.Server/Formatters/CssOutputFormatter.cs b/Jellyfin.Server/Formatters/CssOutputFormatter.cs
index cfc9d1ad3..fdaa48f84 100644
--- a/Jellyfin.Server/Formatters/CssOutputFormatter.cs
+++ b/Jellyfin.Server/Formatters/CssOutputFormatter.cs
@@ -30,7 +30,7 @@ namespace Jellyfin.Server.Formatters
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
{
var stringResponse = context.Object?.ToString();
- return stringResponse == null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
+ return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
}
}
}
diff --git a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
index be0baea2d..156368d69 100644
--- a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
+++ b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
@@ -27,7 +27,7 @@ namespace Jellyfin.Server.Formatters
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
{
var stringResponse = context.Object?.ToString();
- return stringResponse == null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
+ return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
}
}
}
diff --git a/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs b/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs
index bb264d512..fd68975ff 100644
--- a/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs
+++ b/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs
@@ -72,7 +72,7 @@ namespace Jellyfin.Server.Infrastructure
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(result);
- if (range != null && rangeLength == 0)
+ if (range is not null && rangeLength == 0)
{
return Task.CompletedTask;
}
@@ -85,7 +85,7 @@ namespace Jellyfin.Server.Infrastructure
var response = context.HttpContext.Response;
- if (range != null)
+ if (range is not null)
{
return SendFileAsync(
result.FileName,
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 44f92cf83..58b416480 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -8,7 +8,7 @@
<PropertyGroup>
<AssemblyName>jellyfin</AssemblyName>
<OutputType>Exe</OutputType>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<ServerGarbageCollection>false</ServerGarbageCollection>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -35,10 +35,10 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
- <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
- <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
- <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.11" />
- <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.11" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="prometheus-net" Version="7.0.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
@@ -48,7 +48,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Graylog" Version="2.3.0" />
- <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.2" />
+ <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.3" />
</ItemGroup>
<ItemGroup>
diff --git a/Jellyfin.Server/Middleware/ExceptionMiddleware.cs b/Jellyfin.Server/Middleware/ExceptionMiddleware.cs
index db7877c31..91dbce19a 100644
--- a/Jellyfin.Server/Middleware/ExceptionMiddleware.cs
+++ b/Jellyfin.Server/Middleware/ExceptionMiddleware.cs
@@ -105,7 +105,7 @@ namespace Jellyfin.Server.Middleware
if (ex is AggregateException agg)
{
var inner = agg.InnerException;
- if (inner != null)
+ if (inner is not null)
{
return GetActualException(inner);
}
diff --git a/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs b/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs
index cdd86e28e..24807ce38 100644
--- a/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs
+++ b/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs
@@ -28,7 +28,7 @@ namespace Jellyfin.Server.Middleware
public async Task Invoke(HttpContext httpContext)
{
var feature = httpContext.Features.Get<IQueryFeature>();
- if (feature != null)
+ if (feature is not null)
{
httpContext.Features.Set<IQueryFeature>(new UrlDecodeQueryFeature(feature));
}
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
index 37716482c..0fad77cfe 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
@@ -91,7 +91,7 @@ namespace Jellyfin.Server.Migrations.Routines
foreach (var result in results)
{
var dto = JsonSerializer.Deserialize<DisplayPreferencesDto>(result[3].ToBlob(), _jsonOptions);
- if (dto == null)
+ if (dto is null)
{
continue;
}
@@ -108,7 +108,7 @@ namespace Jellyfin.Server.Migrations.Routines
displayPrefs.Add(displayPreferencesKey);
var existingUser = _userManager.GetUserById(dtoUserId);
- if (existingUser == null)
+ if (existingUser is null)
{
_logger.LogWarning("User with ID {UserId} does not exist in the database, skipping migration.", dtoUserId);
continue;
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
index 0c2cc69a7..2dbd82e8f 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
@@ -76,7 +76,7 @@ namespace Jellyfin.Server.Migrations.Routines
foreach (var entry in queryResult)
{
UserMockup? mockup = JsonSerializer.Deserialize<UserMockup>(entry[2].ToBlob(), JsonDefaults.Options);
- if (mockup == null)
+ if (mockup is null)
{
continue;
}
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 1e63b0204..8529a16d3 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -201,7 +202,7 @@ namespace Jellyfin.Server
{
await webHost.StartAsync(_tokenSource.Token).ConfigureAwait(false);
- if (startupConfig.UseUnixSocket() && Environment.OSVersion.Platform == PlatformID.Unix)
+ if (!OperatingSystem.IsWindows() && startupConfig.UseUnixSocket())
{
var socketPath = GetUnixSocketPath(startupConfig, appPaths);
@@ -234,7 +235,7 @@ namespace Jellyfin.Server
finally
{
// Don't throw additional exception if startup failed.
- if (appHost.ServiceProvider != null)
+ if (appHost.ServiceProvider is not null)
{
_logger.LogInformation("Running query planner optimizations in the database... This might take a while");
// Run before disposing the application
@@ -400,7 +401,7 @@ namespace Jellyfin.Server
if (string.IsNullOrEmpty(configDir))
{
- if (options.DataDir != null
+ if (options.DataDir is not null
|| Directory.Exists(Path.Combine(dataDir, "config"))
|| OperatingSystem.IsWindows())
{
@@ -575,7 +576,7 @@ namespace Jellyfin.Server
{
// Use the swagger API page as the default redirect path if not hosting the web client
var inMemoryDefaultConfig = ConfigurationOptions.DefaultConfiguration;
- if (startupConfig != null && !startupConfig.HostWebClient())
+ if (startupConfig is not null && !startupConfig.HostWebClient())
{
inMemoryDefaultConfig[DefaultRedirectKey] = "api-docs/swagger";
}
@@ -635,7 +636,7 @@ namespace Jellyfin.Server
}
string commandLineArgsString;
- if (options.RestartArgs != null)
+ if (options.RestartArgs is not null)
{
commandLineArgsString = options.RestartArgs;
}
@@ -670,7 +671,7 @@ namespace Jellyfin.Server
{
var xdgRuntimeDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR");
var socketFile = "jellyfin.sock";
- if (xdgRuntimeDir == null)
+ if (xdgRuntimeDir is null)
{
// Fall back to config dir
socketPath = Path.Join(appPaths.ConfigurationDirectoryPath, socketFile);
@@ -684,27 +685,15 @@ namespace Jellyfin.Server
return socketPath;
}
+ [UnsupportedOSPlatform("windows")]
private static void SetUnixSocketPermissions(IConfiguration startupConfig, string socketPath)
{
var socketPerms = startupConfig.GetUnixSocketPermissions();
if (!string.IsNullOrEmpty(socketPerms))
{
-#pragma warning disable SA1300 // Entrypoint is case sensitive.
- [DllImport("libc")]
- static extern int chmod(string pathname, int mode);
-#pragma warning restore SA1300
-
- var exitCode = chmod(socketPath, Convert.ToInt32(socketPerms, 8));
-
- if (exitCode < 0)
- {
- _logger.LogError("Failed to set Kestrel unix socket permissions to {SocketPerms}, return code: {ExitCode}", socketPerms, exitCode);
- }
- else
- {
- _logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms);
- }
+ File.SetUnixFileMode(socketPath, (UnixFileMode)Convert.ToInt32(socketPerms, 8));
+ _logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms);
}
}
}
diff --git a/Jellyfin.Server/StartupOptions.cs b/Jellyfin.Server/StartupOptions.cs
index 84ebde68c..0d9f379e0 100644
--- a/Jellyfin.Server/StartupOptions.cs
+++ b/Jellyfin.Server/StartupOptions.cs
@@ -79,21 +79,21 @@ namespace Jellyfin.Server
/// Gets the command line options as a dictionary that can be used in the .NET configuration system.
/// </summary>
/// <returns>The configuration dictionary.</returns>
- public Dictionary<string, string> ConvertToConfig()
+ public Dictionary<string, string?> ConvertToConfig()
{
- var config = new Dictionary<string, string>();
+ var config = new Dictionary<string, string?>();
if (NoWebClient)
{
config.Add(HostWebClientKey, bool.FalseString);
}
- if (PublishedServerUrl != null)
+ if (PublishedServerUrl is not null)
{
config.Add(AddressOverrideKey, PublishedServerUrl);
}
- if (FFmpegPath != null)
+ if (FFmpegPath is not null)
{
config.Add(FfmpegPathKey, FFmpegPath);
}
diff --git a/MediaBrowser.Common/Events/EventHelper.cs b/MediaBrowser.Common/Events/EventHelper.cs
index a9cf86fbc..0e495f4fa 100644
--- a/MediaBrowser.Common/Events/EventHelper.cs
+++ b/MediaBrowser.Common/Events/EventHelper.cs
@@ -19,7 +19,7 @@ namespace MediaBrowser.Common.Events
/// <param name="logger">The logger.</param>
public static void QueueEventIfNotNull(EventHandler? handler, object sender, EventArgs args, ILogger logger)
{
- if (handler != null)
+ if (handler is not null)
{
Task.Run(() =>
{
@@ -45,7 +45,7 @@ namespace MediaBrowser.Common.Events
/// <param name="logger">The logger.</param>
public static void QueueEventIfNotNull<T>(EventHandler<T>? handler, object sender, T args, ILogger logger)
{
- if (handler != null)
+ if (handler is not null)
{
Task.Run(() =>
{
diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
index 1e5877c84..6608704c0 100644
--- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
+++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
@@ -15,8 +15,8 @@ namespace MediaBrowser.Common.Extensions
/// <returns><c>true</c> if the request is coming from LAN, <c>false</c> otherwise.</returns>
public static bool IsLocal(this HttpContext context)
{
- return (context.Connection.LocalIpAddress == null
- && context.Connection.RemoteIpAddress == null)
+ return (context.Connection.LocalIpAddress is null
+ && context.Connection.RemoteIpAddress is null)
|| Equals(context.Connection.LocalIpAddress, context.Connection.RemoteIpAddress);
}
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 7a55f398a..0296974b5 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -19,8 +19,8 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
- <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
@@ -29,7 +29,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
@@ -39,7 +39,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Stability)'=='Unstable'">
diff --git a/MediaBrowser.Common/Plugins/BasePluginOfT.cs b/MediaBrowser.Common/Plugins/BasePluginOfT.cs
index 0da5592d3..152fa8b4a 100644
--- a/MediaBrowser.Common/Plugins/BasePluginOfT.cs
+++ b/MediaBrowser.Common/Plugins/BasePluginOfT.cs
@@ -47,7 +47,7 @@ namespace MediaBrowser.Common.Plugins
var assemblyFilePath = assembly.Location;
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
- if (Version != null && !Directory.Exists(dataFolderPath))
+ if (Version is not null && !Directory.Exists(dataFolderPath))
{
// Try again with the version number appended to the folder name.
dataFolderPath += "_" + Version.ToString();
@@ -103,7 +103,7 @@ namespace MediaBrowser.Common.Plugins
get
{
// Lazy load
- if (_configuration == null)
+ if (_configuration is null)
{
lock (_configurationSyncLock)
{
diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs
index 4c8e2d504..96af423cc 100644
--- a/MediaBrowser.Common/Plugins/LocalPlugin.cs
+++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs
@@ -43,7 +43,7 @@ namespace MediaBrowser.Common.Plugins
{
get
{
- if (_version == null)
+ if (_version is null)
{
_version = Version.Parse(Manifest.Version);
}
@@ -85,9 +85,9 @@ namespace MediaBrowser.Common.Plugins
/// <returns>Comparison result.</returns>
public static int Compare(LocalPlugin a, LocalPlugin b)
{
- if (a == null || b == null)
+ if (a is null || b is null)
{
- throw new ArgumentNullException(a == null ? nameof(a) : nameof(b));
+ throw new ArgumentNullException(a is null ? nameof(a) : nameof(b));
}
var compare = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
@@ -128,7 +128,7 @@ namespace MediaBrowser.Common.Plugins
/// <inheritdoc />
public bool Equals(LocalPlugin? other)
{
- if (other == null)
+ if (other is null)
{
return false;
}
diff --git a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
index 61539cae5..ed7c2c2c1 100644
--- a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
+++ b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
@@ -49,14 +49,14 @@ namespace MediaBrowser.Controller.BaseItemManager
return !baseItem.EnableMediaSourceDisplay;
}
- if (libraryTypeOptions != null)
+ if (libraryTypeOptions is not null)
{
return libraryTypeOptions.MetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
}
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
- return itemConfig == null || !itemConfig.DisabledMetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
+ return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
}
/// <inheritdoc />
@@ -74,14 +74,14 @@ namespace MediaBrowser.Controller.BaseItemManager
return !baseItem.EnableMediaSourceDisplay;
}
- if (libraryTypeOptions != null)
+ if (libraryTypeOptions is not null)
{
return libraryTypeOptions.ImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
}
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
- return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
+ return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
}
/// <summary>
diff --git a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs
index b036425ab..62b70ce53 100644
--- a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs
+++ b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs
@@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Drawing
{
var imageInfo = item.GetImageInfo(imageType, imageIndex);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return null;
}
diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs
index e671e5c71..08c622cde 100644
--- a/MediaBrowser.Controller/Entities/AggregateFolder.cs
+++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs
@@ -67,14 +67,14 @@ namespace MediaBrowser.Controller.Entities
{
lock (_childIdsLock)
{
- if (_childrenIds == null || _childrenIds.Length == 0)
+ if (_childrenIds is null || _childrenIds.Length == 0)
{
var list = base.LoadChildren();
_childrenIds = list.Select(i => i.Id).ToArray();
return list;
}
- return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList();
+ return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i is not null).ToList();
}
}
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs
index 29f7bf92b..c7216a320 100644
--- a/MediaBrowser.Controller/Entities/Audio/Audio.cs
+++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs
@@ -81,8 +81,8 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <returns>System.String.</returns>
protected override string CreateSortName()
{
- return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty)
- + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name;
+ return (ParentIndexNumber is not null ? ParentIndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty)
+ + (IndexNumber is not null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name;
}
public override List<string> GetUserDataKeys()
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
index 6555de855..2dbd513a1 100644
--- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
+++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
@@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Entities.Audio
var artist = GetMusicArtist(new DtoOptions(false));
- if (artist != null)
+ if (artist is not null)
{
id.ArtistProviderIds = artist.ProviderIds;
}
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 7f5f9f74b..32fe1b3b0 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -494,7 +494,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
- if (_sortName == null)
+ if (_sortName is null)
{
if (!string.IsNullOrEmpty(ForcedSortName))
{
@@ -658,7 +658,7 @@ namespace MediaBrowser.Controller.Entities
}
var parent = DisplayParent;
- if (parent != null)
+ if (parent is not null)
{
return parent.OfficialRatingForComparison;
}
@@ -679,7 +679,7 @@ namespace MediaBrowser.Controller.Entities
}
var parent = DisplayParent;
- if (parent != null)
+ if (parent is not null)
{
return parent.CustomRatingForComparison;
}
@@ -880,7 +880,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>System.String.</returns>
protected virtual string CreateSortName()
{
- if (Name == null)
+ if (Name is null)
{
return null; // some items may not have name filled in properly
}
@@ -976,7 +976,7 @@ namespace MediaBrowser.Controller.Entities
{
var parent = GetParent();
- while (parent != null)
+ while (parent is not null)
{
yield return parent;
@@ -1073,7 +1073,7 @@ namespace MediaBrowser.Controller.Entities
{
var stream = i.VideoStream;
- return stream == null || stream.Width == null ? 0 : stream.Width.Value;
+ return stream is null || stream.Width is null ? 0 : stream.Width.Value;
})
.ToList();
}
@@ -1114,7 +1114,7 @@ namespace MediaBrowser.Controller.Entities
}
var video = item as Video;
- if (video != null)
+ if (video is not null)
{
info.IsoType = video.IsoType;
info.VideoType = video.VideoType;
@@ -1153,7 +1153,7 @@ namespace MediaBrowser.Controller.Entities
info.SupportsDirectStream = MediaSourceManager.SupportsDirectStream(info.Path, info.Protocol);
}
- if (video != null && video.VideoType != VideoType.VideoFile)
+ if (video is not null && video.VideoType != VideoType.VideoFile)
{
info.SupportsDirectStream = false;
}
@@ -1330,7 +1330,7 @@ namespace MediaBrowser.Controller.Entities
public void SetParent(Folder parent)
{
- ParentId = parent == null ? Guid.Empty : parent.Id;
+ ParentId = parent is null ? Guid.Empty : parent.Id;
}
/// <summary>
@@ -1534,7 +1534,7 @@ namespace MediaBrowser.Controller.Entities
var maxAllowedRating = user.MaxParentalAgeRating;
- if (maxAllowedRating == null)
+ if (maxAllowedRating is null)
{
return true;
}
@@ -1692,7 +1692,7 @@ namespace MediaBrowser.Controller.Entities
var itemById = LibraryManager.GetItemById(info.ItemId.Value);
- if (itemById != null)
+ if (itemById is not null)
{
return itemById;
}
@@ -1701,7 +1701,7 @@ namespace MediaBrowser.Controller.Entities
var item = FindLinkedChild(info);
// If still null, log
- if (item == null)
+ if (item is null)
{
// Don't keep searching over and over
info.ItemId = Guid.Empty;
@@ -1725,7 +1725,7 @@ namespace MediaBrowser.Controller.Entities
var itemByPath = LibraryManager.FindByPath(path, null);
- if (itemByPath == null)
+ if (itemByPath is null)
{
Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
}
@@ -1737,7 +1737,7 @@ namespace MediaBrowser.Controller.Entities
{
var item = LibraryManager.GetItemById(info.LibraryItemId);
- if (item == null)
+ if (item is null)
{
Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
}
@@ -1755,10 +1755,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throws if name is null.</exception>
public void AddStudio(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
var current = Studios;
@@ -1791,10 +1788,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throwns if name is null.</exception>
public void AddGenre(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
var genres = Genres;
if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
@@ -1892,7 +1886,7 @@ namespace MediaBrowser.Controller.Entities
var existingImage = GetImageInfo(image.Type, index);
- if (existingImage == null)
+ if (existingImage is null)
{
AddImage(image);
}
@@ -1915,7 +1909,7 @@ namespace MediaBrowser.Controller.Entities
var image = GetImageInfo(type, index);
- if (image == null)
+ if (image is null)
{
AddImage(GetImageInfo(file, type));
}
@@ -1942,7 +1936,7 @@ namespace MediaBrowser.Controller.Entities
{
var info = GetImageInfo(type, index);
- if (info == null)
+ if (info is null)
{
// Nothing to do
return;
@@ -2035,7 +2029,7 @@ namespace MediaBrowser.Controller.Entities
{
var chapter = ItemRepository.GetChapter(this, imageIndex);
- if (chapter == null)
+ if (chapter is null)
{
return null;
}
@@ -2060,7 +2054,7 @@ namespace MediaBrowser.Controller.Entities
{
var artist = FindParent<MusicArtist>();
- if (artist != null)
+ if (artist is not null)
{
return artist.GetImages(imageType).ElementAtOrDefault(imageIndex);
}
@@ -2147,7 +2141,7 @@ namespace MediaBrowser.Controller.Entities
foreach (var newImage in images)
{
- if (newImage == null)
+ if (newImage is null)
{
throw new ArgumentException("null image found in list");
}
@@ -2155,7 +2149,7 @@ namespace MediaBrowser.Controller.Entities
var existing = existingImages
.Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
- if (existing == null)
+ if (existing is null)
{
newImageList.Add(newImage);
}
@@ -2241,7 +2235,7 @@ namespace MediaBrowser.Controller.Entities
var info1 = GetImageInfo(type, index1);
var info2 = GetImageInfo(type, index2);
- if (info1 == null || info2 == null)
+ if (info1 is null || info2 is null)
{
// Nothing to do
return Task.CompletedTask;
@@ -2274,14 +2268,14 @@ namespace MediaBrowser.Controller.Entities
{
var userdata = UserDataManager.GetUserData(user, this);
- return userdata != null && userdata.Played;
+ return userdata is not null && userdata.Played;
}
public bool IsFavoriteOrLiked(User user)
{
var userdata = UserDataManager.GetUserData(user, this);
- return userdata != null && (userdata.IsFavorite || (userdata.Likes ?? false));
+ return userdata is not null && (userdata.IsFavorite || (userdata.Likes ?? false));
}
public virtual bool IsUnplayed(User user)
@@ -2290,7 +2284,7 @@ namespace MediaBrowser.Controller.Entities
var userdata = UserDataManager.GetUserData(user, this);
- return userdata == null || !userdata.Played;
+ return userdata is null || !userdata.Played;
}
ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo()
@@ -2445,14 +2439,14 @@ namespace MediaBrowser.Controller.Entities
// Try to retrieve it from the db. If we don't find it, use the resolved version
var video = LibraryManager.GetItemById(id) as Video;
- if (video == null)
+ if (video is null)
{
video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video;
newOptions.ForceSave = true;
}
- if (video == null)
+ if (video is null)
{
return Task.FromResult(true);
}
@@ -2565,7 +2559,7 @@ namespace MediaBrowser.Controller.Entities
{
return ExtraIds
.Select(LibraryManager.GetItemById)
- .Where(i => i != null)
+ .Where(i => i is not null)
.OrderBy(i => i.SortName);
}
@@ -2578,7 +2572,7 @@ namespace MediaBrowser.Controller.Entities
{
return ExtraIds
.Select(LibraryManager.GetItemById)
- .Where(i => i != null)
+ .Where(i => i is not null)
.Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value))
.OrderBy(i => i.SortName);
}
diff --git a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs
index 948eb4375..615d236c7 100644
--- a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs
+++ b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs
@@ -89,13 +89,13 @@ namespace MediaBrowser.Controller.Entities
}
var v = sourceProp.GetValue(source);
- if (v == null)
+ if (v is null)
{
continue;
}
var p = destProps.Find(x => x.Name == sourceProp.Name);
- if (p != null)
+ if (p is not null)
{
p.SetValue(dest, v);
}
diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs
index 1acb92fdc..3005bee0a 100644
--- a/MediaBrowser.Controller/Entities/Extensions.cs
+++ b/MediaBrowser.Controller/Entities/Extensions.cs
@@ -17,16 +17,11 @@ namespace MediaBrowser.Controller.Entities
/// <param name="url">Trailer URL.</param>
public static void AddTrailerUrl(this BaseItem item, string url)
{
- ArgumentNullException.ThrowIfNull(url);
-
- if (url.Length == 0)
- {
- throw new ArgumentException("String can't be empty", nameof(url));
- }
+ ArgumentException.ThrowIfNullOrEmpty(url);
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
- if (current == null)
+ if (current is null)
{
var mediaUrl = new MediaUrl
{
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index 808f91810..e586205c3 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -483,7 +483,7 @@ namespace MediaBrowser.Controller.Entities
}
});
- if (container != null)
+ if (container is not null)
{
await RefreshAllMetadataForContainer(container, refreshOptions, innerProgress, cancellationToken).ConfigureAwait(false);
}
@@ -515,7 +515,7 @@ namespace MediaBrowser.Controller.Entities
async () =>
{
var series = container as Series;
- if (series != null)
+ if (series is not null)
{
await series.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
}
@@ -529,7 +529,7 @@ namespace MediaBrowser.Controller.Entities
{
var container = child as IMetadataContainer;
- if (container != null)
+ if (container is not null)
{
await RefreshAllMetadataForContainer(container, refreshOptions, progress, cancellationToken).ConfigureAwait(false);
}
@@ -703,7 +703,7 @@ namespace MediaBrowser.Controller.Entities
IEnumerable<BaseItem> items;
Func<BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);
- if (query.User == null)
+ if (query.User is null)
{
items = GetRecursiveChildren(filter);
}
@@ -741,7 +741,7 @@ namespace MediaBrowser.Controller.Entities
IEnumerable<BaseItem> itemsList = LibraryManager.GetItemList(query);
var user = query.User;
- if (user != null)
+ if (user is not null)
{
// needed for boxsets
itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User));
@@ -961,7 +961,7 @@ namespace MediaBrowser.Controller.Entities
IEnumerable<BaseItem> items;
- if (query.User == null)
+ if (query.User is null)
{
items = Children.Where(filter);
}
@@ -984,7 +984,7 @@ namespace MediaBrowser.Controller.Entities
var user = query.User;
// Check recursive - don't substitute in plain folder views
- if (user != null)
+ if (user is not null)
{
items = CollapseBoxSetItemsIfNeeded(items, query, this, user, ConfigurationManager, CollectionManager);
}
@@ -1069,7 +1069,7 @@ namespace MediaBrowser.Controller.Entities
if (!param.HasValue)
{
- if (user != null && !configurationManager.Configuration.EnableGroupingIntoCollections)
+ if (user is not null && !configurationManager.Configuration.EnableGroupingIntoCollections)
{
return false;
}
@@ -1311,7 +1311,7 @@ namespace MediaBrowser.Controller.Entities
}
// If there are not sub-folders, proceed as normal.
- if (children == null)
+ if (children is null)
{
children = GetEligibleChildrenForRecursiveChildren(user);
}
@@ -1320,7 +1320,7 @@ namespace MediaBrowser.Controller.Entities
{
bool? isVisibleToUser = null;
- if (query == null || UserViewBuilder.FilterItem(child, query))
+ if (query is null || UserViewBuilder.FilterItem(child, query))
{
isVisibleToUser = child.IsVisible(user);
@@ -1345,7 +1345,7 @@ namespace MediaBrowser.Controller.Entities
{
foreach (var child in GetLinkedChildren(user))
{
- if (query == null || UserViewBuilder.FilterItem(child, query))
+ if (query is null || UserViewBuilder.FilterItem(child, query))
{
if (child.IsVisible(user))
{
@@ -1402,7 +1402,7 @@ namespace MediaBrowser.Controller.Entities
{
foreach (var child in Children)
{
- if (filter == null || filter(child))
+ if (filter is null || filter(child))
{
result[child.Id] = child;
}
@@ -1420,7 +1420,7 @@ namespace MediaBrowser.Controller.Entities
{
foreach (var child in GetLinkedChildren())
{
- if (filter == null || filter(child))
+ if (filter is null || filter(child))
{
result[child.Id] = child;
}
@@ -1441,7 +1441,7 @@ namespace MediaBrowser.Controller.Entities
{
var child = GetLinkedChild(i);
- if (child != null)
+ if (child is not null)
{
list.Add(child);
}
@@ -1467,7 +1467,7 @@ namespace MediaBrowser.Controller.Entities
var child = GetLinkedChild(i);
- if (child != null && child.Id.Equals(itemId))
+ if (child is not null && child.Id.Equals(itemId))
{
return true;
}
@@ -1478,7 +1478,7 @@ namespace MediaBrowser.Controller.Entities
public List<BaseItem> GetLinkedChildren(User user)
{
- if (!FilterLinkedChildrenPerUser || user == null)
+ if (!FilterLinkedChildrenPerUser || user is null)
{
return GetLinkedChildren();
}
@@ -1504,7 +1504,7 @@ namespace MediaBrowser.Controller.Entities
{
var child = GetLinkedChild(i);
- if (child == null)
+ if (child is null)
{
continue;
}
@@ -1547,7 +1547,7 @@ namespace MediaBrowser.Controller.Entities
{
return LinkedChildren
.Select(i => new Tuple<LinkedChild, BaseItem>(i, GetLinkedChild(i)))
- .Where(i => i.Item2 != null);
+ .Where(i => i.Item2 is not null);
}
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)
@@ -1605,7 +1605,7 @@ namespace MediaBrowser.Controller.Entities
return null;
}
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList();
var currentShortcutLinks = LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut).ToList();
@@ -1662,7 +1662,7 @@ namespace MediaBrowser.Controller.Entities
{
// The querying doesn't support virtual unaired
var episode = item as Episode;
- if (episode != null && episode.IsUnaired)
+ if (episode is not null && episode.IsUnaired)
{
continue;
}
@@ -1719,7 +1719,7 @@ namespace MediaBrowser.Controller.Entities
return;
}
- if (itemDto != null)
+ if (itemDto is not null)
{
if (fields.ContainsField(ItemFields.RecursiveItemCount))
{
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index 1bf528538..a1e531904 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -55,7 +55,7 @@ namespace MediaBrowser.Controller.Entities
public InternalItemsQuery(User? user)
: this()
{
- if (user != null)
+ if (user is not null)
{
SetUser(user);
}
@@ -316,7 +316,7 @@ namespace MediaBrowser.Controller.Entities
{
set
{
- if (value == null)
+ if (value is null)
{
ParentId = Guid.Empty;
ParentType = null;
diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs
index ea8555dbf..0171af27c 100644
--- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs
+++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs
@@ -39,6 +39,6 @@ namespace MediaBrowser.Controller.Entities
public string BlurHash { get; set; }
[JsonIgnore]
- public bool IsLocalFile => Path == null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase);
+ public bool IsLocalFile => Path is null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase);
}
}
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 3c12acd90..81f6248fa 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <inheritdoc />
[JsonIgnore]
public IReadOnlyList<Guid> SpecialFeatureIds => GetExtras()
- .Where(extra => extra.ExtraType != null && extra is Video)
+ .Where(extra => extra.ExtraType is not null && extra is Video)
.Select(extra => extra.Id)
.ToArray();
diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs
index 8571bfcea..7f8dc069c 100644
--- a/MediaBrowser.Controller/Entities/PeopleHelper.cs
+++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs
@@ -12,11 +12,7 @@ namespace MediaBrowser.Controller.Entities
public static void AddPerson(List<PersonInfo> people, PersonInfo person)
{
ArgumentNullException.ThrowIfNull(person);
-
- if (string.IsNullOrEmpty(person.Name))
- {
- throw new ArgumentException("The person's name was empty or null.", nameof(person));
- }
+ ArgumentException.ThrowIfNullOrEmpty(person.Name);
// Normalize
if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
@@ -41,7 +37,7 @@ namespace MediaBrowser.Controller.Entities
{
var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase));
- if (existing != null)
+ if (existing is not null)
{
existing.Type = PersonType.GuestStar;
MergeExisting(existing, person);
@@ -53,7 +49,7 @@ namespace MediaBrowser.Controller.Entities
{
// If the actor already exists without a role and we have one, fill it in
var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && (p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase) || p.Type.Equals(PersonType.GuestStar, StringComparison.OrdinalIgnoreCase)));
- if (existing == null)
+ if (existing is null)
{
// Wasn't there - add it
people.Add(person);
@@ -76,7 +72,7 @@ namespace MediaBrowser.Controller.Entities
string.Equals(p.Type, person.Type, StringComparison.OrdinalIgnoreCase));
// Check for dupes based on the combination of Name and Type
- if (existing == null)
+ if (existing is null)
{
people.Add(person);
}
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index 15b721fe6..3f30ac565 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.TV
public string FindSeriesSortName()
{
var series = Series;
- return series == null ? SeriesName : series.SortName;
+ return series is null ? SeriesName : series.SortName;
}
public override double GetDefaultPrimaryImageAspectRatio()
@@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Entities.TV
var list = base.GetUserDataKeys();
var series = Series;
- if (series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
+ if (series is not null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
{
var seriesUserDataKeys = series.GetUserDataKeys();
var take = seriesUserDataKeys.Count;
@@ -181,14 +181,14 @@ namespace MediaBrowser.Controller.Entities.TV
public string FindSeriesPresentationUniqueKey()
{
var series = Series;
- return series == null ? null : series.PresentationUniqueKey;
+ return series is null ? null : series.PresentationUniqueKey;
}
public string FindSeasonName()
{
var season = Season;
- if (season == null)
+ if (season is null)
{
if (ParentIndexNumber.HasValue)
{
@@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Entities.TV
public string FindSeriesName()
{
var series = Series;
- return series == null ? SeriesName : series.Name;
+ return series is null ? SeriesName : series.Name;
}
public Guid FindSeasonId()
@@ -212,11 +212,11 @@ namespace MediaBrowser.Controller.Entities.TV
var season = FindParent<Season>();
// Episodes directly in series folder
- if (season == null)
+ if (season is null)
{
var series = Series;
- if (series != null && ParentIndexNumber.HasValue)
+ if (series is not null && ParentIndexNumber.HasValue)
{
var findNumber = ParentIndexNumber.Value;
@@ -226,7 +226,7 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
- return season == null ? Guid.Empty : season.Id;
+ return season is null ? Guid.Empty : season.Id;
}
/// <summary>
@@ -235,8 +235,8 @@ namespace MediaBrowser.Controller.Entities.TV
/// <returns>System.String.</returns>
protected override string CreateSortName()
{
- return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000 - ", CultureInfo.InvariantCulture) : string.Empty)
- + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name;
+ return (ParentIndexNumber is not null ? ParentIndexNumber.Value.ToString("000 - ", CultureInfo.InvariantCulture) : string.Empty)
+ + (IndexNumber is not null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name;
}
/// <summary>
@@ -262,7 +262,7 @@ namespace MediaBrowser.Controller.Entities.TV
public Guid FindSeriesId()
{
var series = FindParent<Series>();
- return series == null ? Guid.Empty : series.Id;
+ return series is null ? Guid.Empty : series.Id;
}
public override IEnumerable<Guid> GetAncestorIds()
@@ -302,7 +302,7 @@ namespace MediaBrowser.Controller.Entities.TV
var series = Series;
- if (series != null)
+ if (series is not null)
{
id.SeriesProviderIds = series.ProviderIds;
id.SeriesDisplayOrder = series.DisplayOrder;
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs
index 599d35da6..0a040a3c2 100644
--- a/MediaBrowser.Controller/Entities/TV/Season.cs
+++ b/MediaBrowser.Controller/Entities/TV/Season.cs
@@ -64,7 +64,7 @@ namespace MediaBrowser.Controller.Entities.TV
{
var series = Series;
- if (series != null)
+ if (series is not null)
{
return series.Path;
}
@@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Entities.TV
public string FindSeriesSortName()
{
var series = Series;
- return series == null ? SeriesName : series.SortName;
+ return series is null ? SeriesName : series.SortName;
}
public override List<string> GetUserDataKeys()
@@ -101,7 +101,7 @@ namespace MediaBrowser.Controller.Entities.TV
var list = base.GetUserDataKeys();
var series = Series;
- if (series != null)
+ if (series is not null)
{
var newList = series.GetUserDataKeys();
var suffix = (IndexNumber ?? 0).ToString("000", CultureInfo.InvariantCulture);
@@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Entities.TV
if (IndexNumber.HasValue)
{
var series = Series;
- if (series != null)
+ if (series is not null)
{
return series.PresentationUniqueKey + "-" + (IndexNumber ?? 0).ToString("000", CultureInfo.InvariantCulture);
}
@@ -144,12 +144,12 @@ namespace MediaBrowser.Controller.Entities.TV
/// <returns>System.String.</returns>
protected override string CreateSortName()
{
- return IndexNumber != null ? IndexNumber.Value.ToString("0000", CultureInfo.InvariantCulture) : Name;
+ return IndexNumber is not null ? IndexNumber.Value.ToString("0000", CultureInfo.InvariantCulture) : Name;
}
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
{
- if (query.User == null)
+ if (query.User is null)
{
return base.GetItemsInternal(query);
}
@@ -208,13 +208,13 @@ namespace MediaBrowser.Controller.Entities.TV
public string FindSeriesPresentationUniqueKey()
{
var series = Series;
- return series == null ? null : series.PresentationUniqueKey;
+ return series is null ? null : series.PresentationUniqueKey;
}
public string FindSeriesName()
{
var series = Series;
- return series == null ? SeriesName : series.Name;
+ return series is null ? SeriesName : series.Name;
}
public Guid FindSeriesId()
@@ -233,7 +233,7 @@ namespace MediaBrowser.Controller.Entities.TV
var series = Series;
- if (series != null)
+ if (series is not null)
{
id.SeriesProviderIds = series.ProviderIds;
}
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index d66802a64..02312757c 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -218,7 +218,7 @@ namespace MediaBrowser.Controller.Entities.TV
query.IncludeItemTypes = new[] { BaseItemKind.Season };
query.OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) };
- if (user != null && !user.DisplayMissingEpisodes)
+ if (user is not null && !user.DisplayMissingEpisodes)
{
query.IsMissing = false;
}
@@ -266,7 +266,7 @@ namespace MediaBrowser.Controller.Entities.TV
DtoOptions = options
};
- if (user == null || !user.DisplayMissingEpisodes)
+ if (user is null || !user.DisplayMissingEpisodes)
{
query.IsMissing = false;
}
@@ -369,7 +369,7 @@ namespace MediaBrowser.Controller.Entities.TV
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) },
DtoOptions = options
};
- if (user != null)
+ if (user is not null)
{
if (!user.DisplayMissingEpisodes)
{
@@ -384,7 +384,7 @@ namespace MediaBrowser.Controller.Entities.TV
public List<BaseItem> GetSeasonEpisodes(Season parentSeason, User user, IEnumerable<BaseItem> allSeriesEpisodes, DtoOptions options)
{
- if (allSeriesEpisodes == null)
+ if (allSeriesEpisodes is null)
{
return GetSeasonEpisodes(parentSeason, user, options);
}
@@ -426,7 +426,7 @@ namespace MediaBrowser.Controller.Entities.TV
}
var season = episodeItem.Season;
- return season != null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase);
+ return season is not null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase);
});
}
@@ -448,7 +448,7 @@ namespace MediaBrowser.Controller.Entities.TV
{
var episode = i;
- if (episode != null)
+ if (episode is not null)
{
var currentSeasonNumber = episode.AiredSeasonNumber;
diff --git a/MediaBrowser.Controller/Entities/UserItemData.cs b/MediaBrowser.Controller/Entities/UserItemData.cs
index 50ba9ef30..ecca440f0 100644
--- a/MediaBrowser.Controller/Entities/UserItemData.cs
+++ b/MediaBrowser.Controller/Entities/UserItemData.cs
@@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
- if (Rating != null)
+ if (Rating is not null)
{
return Rating >= MinLikeValue;
}
diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs
index e547db523..69743b926 100644
--- a/MediaBrowser.Controller/Entities/UserRootFolder.cs
+++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs
@@ -56,14 +56,14 @@ namespace MediaBrowser.Controller.Entities
{
lock (_childIdsLock)
{
- if (_childrenIds == null)
+ if (_childrenIds is null)
{
var list = base.LoadChildren();
_childrenIds = list.Select(i => i.Id).ToList();
return list;
}
- return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList();
+ return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i is not null).ToList();
}
}
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index f467a6038..c276ab463 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Entities
{
var user = query.User;
- // if (query.IncludeItemTypes != null &&
+ // if (query.IncludeItemTypes is not null &&
// query.IncludeItemTypes.Length == 1 &&
// string.Equals(query.IncludeItemTypes[0], "Playlist", StringComparison.OrdinalIgnoreCase))
// {
@@ -263,7 +263,7 @@ namespace MediaBrowser.Controller.Entities
return null;
}
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.Select(i => GetUserViewWithName(SpecialFolder.MovieGenre, i.SortName, parent));
return GetResult(genres, query);
@@ -391,7 +391,7 @@ namespace MediaBrowser.Controller.Entities
return null;
}
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.Select(i => GetUserViewWithName(SpecialFolder.TvGenre, i.SortName, parent));
return GetResult(genres, query);
@@ -559,7 +559,7 @@ namespace MediaBrowser.Controller.Entities
var val = query.Is3D.Value;
var video = item as Video;
- if (video == null || val != video.Video3DFormat.HasValue)
+ if (video is null || val != video.Video3DFormat.HasValue)
{
return false;
}
@@ -689,7 +689,7 @@ namespace MediaBrowser.Controller.Entities
var video = item as Video;
- if (video == null || val != video.HasSubtitles)
+ if (video is null || val != video.HasSubtitles)
{
return false;
}
@@ -776,7 +776,7 @@ namespace MediaBrowser.Controller.Entities
if (query.VideoTypes.Length > 0)
{
var video = item as Video;
- if (video == null || !query.VideoTypes.Contains(video.VideoType))
+ if (video is null || !query.VideoTypes.Contains(video.VideoType))
{
return false;
}
@@ -791,7 +791,7 @@ namespace MediaBrowser.Controller.Entities
if (query.StudioIds.Length > 0 && !query.StudioIds.Any(id =>
{
var studioItem = libraryManager.GetItemById(id);
- return studioItem != null && item.Studios.Contains(studioItem.Name, StringComparison.OrdinalIgnoreCase);
+ return studioItem is not null && item.Studios.Contains(studioItem.Name, StringComparison.OrdinalIgnoreCase);
}))
{
return false;
@@ -801,7 +801,7 @@ namespace MediaBrowser.Controller.Entities
if (query.GenreIds.Count > 0 && !query.GenreIds.Any(id =>
{
var genreItem = libraryManager.GetItemById(id);
- return genreItem != null && item.Genres.Contains(genreItem.Name, StringComparison.OrdinalIgnoreCase);
+ return genreItem is not null && item.Genres.Contains(genreItem.Name, StringComparison.OrdinalIgnoreCase);
}))
{
return false;
@@ -913,7 +913,7 @@ namespace MediaBrowser.Controller.Entities
{
var episode = item as Episode;
- if (episode == null)
+ if (episode is null)
{
return false;
}
@@ -929,7 +929,7 @@ namespace MediaBrowser.Controller.Entities
private IEnumerable<BaseItem> GetMediaFolders(User user)
{
- if (user == null)
+ if (user is null)
{
return _libraryManager.RootFolder
.Children
@@ -945,14 +945,14 @@ namespace MediaBrowser.Controller.Entities
private BaseItem[] GetMediaFolders(User user, IEnumerable<string> viewTypes)
{
- if (user == null)
+ if (user is null)
{
return GetMediaFolders(null)
.Where(i =>
{
var folder = i as ICollectionFolder;
- return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
+ return folder is not null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
}).ToArray();
}
@@ -961,13 +961,13 @@ namespace MediaBrowser.Controller.Entities
{
var folder = i as ICollectionFolder;
- return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
+ return folder is not null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
}).ToArray();
}
private BaseItem[] GetMediaFolders(Folder parent, User user, IEnumerable<string> viewTypes)
{
- if (parent == null || parent is UserView)
+ if (parent is null || parent is UserView)
{
return GetMediaFolders(user, viewTypes);
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 5de2e0f50..5b7abea10 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -373,7 +373,7 @@ namespace MediaBrowser.Controller.Entities
{
return LinkedAlternateVersions
.Select(GetLinkedChild)
- .Where(i => i != null)
+ .Where(i => i is not null)
.OfType<Video>()
.OrderBy(i => i.SortName);
}
@@ -386,7 +386,7 @@ namespace MediaBrowser.Controller.Entities
{
return GetAdditionalPartIds()
.Select(i => LibraryManager.GetItemById(i))
- .Where(i => i != null)
+ .Where(i => i is not null)
.OfType<Video>()
.OrderBy(i => i.SortName);
}
@@ -469,7 +469,7 @@ namespace MediaBrowser.Controller.Entities
var localAlternates = GetLocalAlternateVersionIds()
.Select(i => LibraryManager.GetItemById(i))
- .Where(i => i != null);
+ .Where(i => i is not null);
foreach (var item in localAlternates)
{
@@ -542,7 +542,7 @@ namespace MediaBrowser.Controller.Entities
return i.Item1 is Video video ? video.GetLocalAlternateVersionIds() : Enumerable.Empty<Guid>();
})
.Select(LibraryManager.GetItemById)
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList();
list.AddRange(localAlternates.Select(i => (i, MediaSourceType.Default)));
diff --git a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs
index 5a7110261..3b5e8ece7 100644
--- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs
+++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs
@@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary>
/// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The FFmpeg probe size option.</returns>
- public static string GetFFmpegProbeSize(this IConfiguration configuration)
+ public static string? GetFFmpegProbeSize(this IConfiguration configuration)
=> configuration[FfmpegProbeSizeKey];
/// <summary>
@@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary>
/// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The FFmpeg analyze duration option.</returns>
- public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration)
+ public static string? GetFFmpegAnalyzeDuration(this IConfiguration configuration)
=> configuration[FfmpegAnalyzeDurationKey];
/// <summary>
@@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary>
/// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The unix socket path.</returns>
- public static string GetUnixSocketPath(this IConfiguration configuration)
+ public static string? GetUnixSocketPath(this IConfiguration configuration)
=> configuration[UnixSocketPathKey];
/// <summary>
@@ -113,7 +113,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary>
/// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The unix socket permissions.</returns>
- public static string GetUnixSocketPermissions(this IConfiguration configuration)
+ public static string? GetUnixSocketPermissions(this IConfiguration configuration)
=> configuration[UnixSocketPermissionsKey];
}
}
diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs
index 71feae536..9f7a93ae2 100644
--- a/MediaBrowser.Controller/IO/FileData.cs
+++ b/MediaBrowser.Controller/IO/FileData.cs
@@ -35,10 +35,7 @@ namespace MediaBrowser.Controller.IO
int flattenFolderDepth = 0,
bool resolveShortcuts = true)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
ArgumentNullException.ThrowIfNull(args);
diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs
index 91d162b41..01986d303 100644
--- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs
+++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs
@@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Library
public LibraryOptions LibraryOptions
{
- get => _libraryOptions ??= Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent);
+ get => _libraryOptions ??= Parent is null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent);
set => _libraryOptions = value;
}
@@ -119,7 +119,7 @@ namespace MediaBrowser.Controller.Library
get
{
var paths = string.IsNullOrEmpty(Path) ? Array.Empty<string>() : new[] { Path };
- return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray();
+ return AdditionalLocations is null ? paths : paths.Concat(AdditionalLocations).ToArray();
}
}
@@ -130,13 +130,13 @@ namespace MediaBrowser.Controller.Library
{
var parent = Parent;
- if (parent != null)
+ if (parent is not null)
{
var item = parent as T;
// Just in case the user decided to nest episodes.
// Not officially supported but in some cases we can handle it.
- if (item == null)
+ if (item is null)
{
var parents = parent.GetParents();
foreach (var currentParent in parents)
@@ -148,7 +148,7 @@ namespace MediaBrowser.Controller.Library
}
}
- return item != null;
+ return item is not null;
}
return false;
@@ -171,10 +171,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception>
public void AddAdditionalLocation(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentException("The path was empty or null.", nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
AdditionalLocations ??= new List<string>();
AdditionalLocations.Add(path);
@@ -190,10 +187,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
public FileSystemMetadata GetFileSystemEntryByName(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentException("The name was empty or null.", nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, name));
}
@@ -206,10 +200,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException">Throws if path is invalid.</exception>
public FileSystemMetadata GetFileSystemEntryByPath(string path)
{
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentException("The path was empty or null.", nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
foreach (var file in FileSystemChildren)
{
@@ -287,14 +278,14 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if the arguments are the same, <c>false</c> otherwise.</returns>
protected bool Equals(ItemResolveArgs args)
{
- if (args != null)
+ if (args is not null)
{
- if (args.Path == null && Path == null)
+ if (args.Path is null && Path is null)
{
return true;
}
- return args.Path != null && BaseItem.FileSystem.AreEqual(args.Path, Path);
+ return args.Path is not null && BaseItem.FileSystem.AreEqual(args.Path, Path);
}
return false;
diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs
index 9d78b8b6c..919570e89 100644
--- a/MediaBrowser.Controller/Library/NameExtensions.cs
+++ b/MediaBrowser.Controller/Library/NameExtensions.cs
@@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Library
private static string RemoveDiacritics(string? name)
{
- if (name == null)
+ if (name is null)
{
return string.Empty;
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
index 335222da9..978826042 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -139,7 +139,7 @@ namespace MediaBrowser.Controller.LiveTv
Path = Path,
RunTimeTicks = RunTimeTicks,
Type = MediaSourceType.Placeholder,
- IsInfiniteStream = RunTimeTicks == null
+ IsInfiniteStream = RunTimeTicks is null
};
list.Add(info);
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
index 6c4a5ea17..514323238 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
@@ -246,7 +246,7 @@ namespace MediaBrowser.Controller.LiveTv
var listings = GetListingsProviderInfo();
- if (listings != null)
+ if (listings is not null)
{
if (!string.IsNullOrEmpty(listings.MoviePrefix) && name.StartsWith(listings.MoviePrefix, StringComparison.OrdinalIgnoreCase))
{
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index d4e025a43..7e3d7a981 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -14,14 +14,14 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
- <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
- <PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
+ <PackageReference Include="System.Threading.Tasks.Dataflow" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
@@ -35,7 +35,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 5e924e4bf..7264c5eed 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -162,7 +162,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private bool IsHwTonemapAvailable(EncodingJobInfo state, EncodingOptions options)
{
- if (state.VideoStream == null
+ if (state.VideoStream is null
|| !options.EnableTonemapping
|| GetVideoColorBitDepth(state) != 10)
{
@@ -189,7 +189,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private bool IsVulkanHwTonemapAvailable(EncodingJobInfo state, EncodingOptions options)
{
- if (state.VideoStream == null)
+ if (state.VideoStream is null)
{
return false;
}
@@ -202,7 +202,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private bool IsVaapiVppTonemapAvailable(EncodingJobInfo state, EncodingOptions options)
{
- if (state.VideoStream == null
+ if (state.VideoStream is null
|| !options.EnableVppTonemapping
|| GetVideoColorBitDepth(state) != 10)
{
@@ -682,7 +682,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public string GetGraphicalSubCanvasSize(EncodingJobInfo state)
{
- if (state.SubtitleStream != null
+ if (state.SubtitleStream is not null
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
&& !state.SubtitleStream.IsTextSubtitleStream)
{
@@ -932,7 +932,7 @@ namespace MediaBrowser.Controller.MediaEncoding
.Append(GetInputPathArgument(state));
// sub2video for external graphical subtitles
- if (state.SubtitleStream != null
+ if (state.SubtitleStream is not null
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
&& !state.SubtitleStream.IsTextSubtitleStream
&& state.SubtitleStream.IsExternal)
@@ -963,7 +963,7 @@ namespace MediaBrowser.Controller.MediaEncoding
arg.Append(" -i file:\"").Append(subtitlePath).Append('\"');
}
- if (state.AudioStream != null && state.AudioStream.IsExternal)
+ if (state.AudioStream is not null && state.AudioStream.IsExternal)
{
// Also seek the external audio stream.
var seekAudioParam = GetFastSeekCommandLineParameter(state, options, segmentContainer);
@@ -1066,7 +1066,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public string GetVideoBitrateParam(EncodingJobInfo state, string videoCodec)
{
- if (state.OutputVideoBitrate == null)
+ if (state.OutputVideoBitrate is null)
{
return string.Empty;
}
@@ -1231,7 +1231,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var maxrate = request.MaxFramerate;
- if (maxrate.HasValue && state.VideoStream != null)
+ if (maxrate.HasValue && state.VideoStream is not null)
{
var contentRate = state.VideoStream.AverageFrameRate ?? state.VideoStream.RealFrameRate;
@@ -1981,7 +1981,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var bitrate = request.VideoBitRate;
- if (videoStream != null)
+ if (videoStream is not null)
{
var isUpscaling = request.Height.HasValue
&& videoStream.Height.HasValue
@@ -2076,7 +2076,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public int? GetAudioBitrateParam(int? audioBitRate, string audioCodec, MediaStream audioStream)
{
- if (audioStream == null)
+ if (audioStream is null)
{
return null;
}
@@ -2130,7 +2130,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// Boost volume to 200% when downsampling from 6ch to 2ch
if (channels.HasValue
&& channels.Value <= 2
- && state.AudioStream != null
+ && state.AudioStream is not null
&& state.AudioStream.Channels.HasValue
&& state.AudioStream.Channels.Value > 5
&& !encodingOptions.DownMixAudioBoost.Equals(1))
@@ -2139,7 +2139,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var isCopyingTimestamps = state.CopyTimestamps || state.TranscodingType != TranscodingJobType.Progressive;
- if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !isCopyingTimestamps)
+ if (state.SubtitleStream is not null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !isCopyingTimestamps)
{
var seconds = TimeSpan.FromTicks(state.StartTimeTicks ?? 0).TotalSeconds;
@@ -2167,7 +2167,7 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <returns>System.Nullable{System.Int32}.</returns>
public int? GetNumAudioChannelsParam(EncodingJobInfo state, MediaStream audioStream, string outputAudioCodec)
{
- if (audioStream == null)
+ if (audioStream is null)
{
return null;
}
@@ -2320,26 +2320,26 @@ namespace MediaBrowser.Controller.MediaEncoding
// If we don't have known media info
// If input is video, use -sn to drop subtitles
// Otherwise just return empty
- if (state.VideoStream == null && state.AudioStream == null)
+ if (state.VideoStream is null && state.AudioStream is null)
{
return state.IsInputVideo ? "-sn" : string.Empty;
}
// We have media info, but we don't know the stream index
- if (state.VideoStream != null && state.VideoStream.Index == -1)
+ if (state.VideoStream is not null && state.VideoStream.Index == -1)
{
return "-sn";
}
// We have media info, but we don't know the stream index
- if (state.AudioStream != null && state.AudioStream.Index == -1)
+ if (state.AudioStream is not null && state.AudioStream.Index == -1)
{
return state.IsInputVideo ? "-sn" : string.Empty;
}
var args = string.Empty;
- if (state.VideoStream != null)
+ if (state.VideoStream is not null)
{
int videoStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.VideoStream);
@@ -2354,12 +2354,12 @@ namespace MediaBrowser.Controller.MediaEncoding
args += "-vn";
}
- if (state.AudioStream != null)
+ if (state.AudioStream is not null)
{
int audioStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.AudioStream);
if (state.AudioStream.IsExternal)
{
- bool hasExternalGraphicsSubs = state.SubtitleStream != null
+ bool hasExternalGraphicsSubs = state.SubtitleStream is not null
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
&& state.SubtitleStream.IsExternal
&& !state.SubtitleStream.IsTextSubtitleStream;
@@ -2385,7 +2385,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var subtitleMethod = state.SubtitleDeliveryMethod;
- if (state.SubtitleStream == null || subtitleMethod == SubtitleDeliveryMethod.Hls)
+ if (state.SubtitleStream is null || subtitleMethod == SubtitleDeliveryMethod.Hls)
{
args += " -map -0:s";
}
@@ -2427,7 +2427,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var stream = streams.FirstOrDefault(s => s.Index == desiredIndex.Value);
- if (stream != null)
+ if (stream is not null)
{
return stream;
}
@@ -2731,7 +2731,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// default
- if (filter == null)
+ if (filter is null)
{
if (requestedHeight > 0)
{
@@ -2814,7 +2814,6 @@ namespace MediaBrowser.Controller.MediaEncoding
{
algorithm = "bt.2390";
}
-
else if (string.Equals(options.TonemappingAlgorithm, "none", StringComparison.OrdinalIgnoreCase))
{
algorithm = "clip";
@@ -2876,7 +2875,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doDeintHevc = state.DeInterlace("h265", true) || state.DeInterlace("hevc", true);
var doDeintH2645 = doDeintH264 || doDeintHevc;
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
@@ -2991,7 +2990,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doDeintH2645 = doDeintH264 || doDeintHevc;
var doCuTonemap = IsHwTonemapAvailable(state, options);
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs
@@ -3181,7 +3180,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doDeintH2645 = doDeintH264 || doDeintHevc;
var doOclTonemap = IsHwTonemapAvailable(state, options);
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs
@@ -3403,7 +3402,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doDeintH2645 = doDeintH264 || doDeintHevc;
var doOclTonemap = IsHwTonemapAvailable(state, options);
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs
@@ -3606,7 +3605,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doTonemap = doVaVppTonemap || doOclTonemap;
var doDeintH2645 = doDeintH264 || doDeintHevc;
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs
@@ -3883,7 +3882,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doTonemap = doVaVppTonemap || doOclTonemap;
var doDeintH2645 = doDeintH264 || doDeintHevc;
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs
@@ -4079,7 +4078,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doVkTonemap = IsVulkanHwTonemapAvailable(state, options);
var doDeintH2645 = doDeintH264 || doDeintHevc;
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs
@@ -4278,7 +4277,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doDeintH2645 = doDeintH264 || doDeintHevc;
var doOclTonemap = IsHwTonemapAvailable(state, options);
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
@@ -4441,12 +4440,12 @@ namespace MediaBrowser.Controller.MediaEncoding
string outputVideoCodec)
{
var videoStream = state.VideoStream;
- if (videoStream == null)
+ if (videoStream is null)
{
return string.Empty;
}
- var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
@@ -4496,7 +4495,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (overlayFilters?.Count > 0
&& subFilters?.Count > 0
- && state.SubtitleStream != null)
+ && state.SubtitleStream is not null)
{
// overlay graphical/text subtitles
var subStr = string.Format(
@@ -4583,7 +4582,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public static int GetVideoColorBitDepth(EncodingJobInfo state)
{
var videoStream = state.VideoStream;
- if (videoStream != null)
+ if (videoStream is not null)
{
if (videoStream.BitDepth.HasValue)
{
@@ -4624,7 +4623,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var videoStream = state.VideoStream;
var mediaSource = state.MediaSource;
- if (videoStream == null || mediaSource == null)
+ if (videoStream is null || mediaSource is null)
{
return null;
}
@@ -5197,7 +5196,7 @@ namespace MediaBrowser.Controller.MediaEncoding
#nullable disable
public void TryStreamCopy(EncodingJobInfo state)
{
- if (state.VideoStream != null && CanStreamCopyVideo(state, state.VideoStream))
+ if (state.VideoStream is not null && CanStreamCopyVideo(state, state.VideoStream))
{
state.OutputVideoCodec = "copy";
}
@@ -5206,13 +5205,13 @@ namespace MediaBrowser.Controller.MediaEncoding
var user = state.User;
// If the user doesn't have access to transcoding, then force stream copy, regardless of whether it will be compatible or not
- if (user != null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding))
+ if (user is not null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding))
{
state.OutputVideoCodec = "copy";
}
}
- if (state.AudioStream != null
+ if (state.AudioStream is not null
&& CanStreamCopyAudio(state, state.AudioStream, state.SupportedAudioCodecs))
{
state.OutputAudioCodec = "copy";
@@ -5222,7 +5221,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var user = state.User;
// If the user doesn't have access to transcoding, then force stream copy, regardless of whether it will be compatible or not
- if (user != null && !user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding))
+ if (user is not null && !user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding))
{
state.OutputAudioCodec = "copy";
}
@@ -5419,7 +5418,7 @@ namespace MediaBrowser.Controller.MediaEncoding
state.SubtitleDeliveryMethod = videoRequest.SubtitleMethod;
state.AudioStream = GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);
- if (state.SubtitleStream != null && !state.SubtitleStream.IsExternal)
+ if (state.SubtitleStream is not null && !state.SubtitleStream.IsExternal)
{
state.InternalSubtitleStreamOffset = mediaStreams.Where(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal).ToList().IndexOf(state.SubtitleStream);
}
@@ -5437,7 +5436,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var request = state.BaseRequest;
var supportedAudioCodecs = state.SupportedAudioCodecs;
- if (request != null && supportedAudioCodecs != null && supportedAudioCodecs.Length > 0)
+ if (request is not null && supportedAudioCodecs is not null && supportedAudioCodecs.Length > 0)
{
var supportedAudioCodecsList = supportedAudioCodecs.ToList();
@@ -5450,7 +5449,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var supportedVideoCodecs = state.SupportedVideoCodecs;
- if (request != null && supportedVideoCodecs != null && supportedVideoCodecs.Length > 0)
+ if (request is not null && supportedVideoCodecs is not null && supportedVideoCodecs.Length > 0)
{
var supportedVideoCodecsList = supportedVideoCodecs.ToList();
@@ -5470,7 +5469,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return;
}
- var inputChannels = audioStream == null ? 6 : audioStream.Channels ?? 6;
+ var inputChannels = audioStream is null ? 6 : audioStream.Channels ?? 6;
if (inputChannels >= 6)
{
return;
@@ -5522,7 +5521,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private void NormalizeSubtitleEmbed(EncodingJobInfo state)
{
- if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed)
+ if (state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed)
{
return;
}
@@ -5537,7 +5536,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public string GetSubtitleEmbedArguments(EncodingJobInfo state)
{
- if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed)
+ if (state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed)
{
return string.Empty;
}
@@ -5618,7 +5617,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (IsCopyCodec(videoCodec))
{
- if (state.VideoStream != null
+ if (state.VideoStream is not null
&& string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{
@@ -5648,7 +5647,7 @@ namespace MediaBrowser.Controller.MediaEncoding
args += keyFrameArg;
- var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hasGraphicalSubs = state.SubtitleStream is not null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
var hasCopyTs = false;
@@ -5668,7 +5667,7 @@ namespace MediaBrowser.Controller.MediaEncoding
args += " -avoid_negative_ts disabled";
- if (!(state.SubtitleStream != null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream))
+ if (!(state.SubtitleStream is not null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream))
{
args += " -start_at_zero";
}
@@ -5695,7 +5694,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public string GetProgressiveVideoAudioArguments(EncodingJobInfo state, EncodingOptions encodingOptions)
{
// If the video doesn't have an audio stream, return a default.
- if (state.AudioStream == null && state.VideoStream != null)
+ if (state.AudioStream is null && state.VideoStream is not null)
{
return string.Empty;
}
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
index c9625cf1d..179cabc84 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
@@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (!_transcodeReasons.HasValue)
{
- if (BaseRequest.TranscodeReasons == null)
+ if (BaseRequest.TranscodeReasons is null)
{
_transcodeReasons = 0;
return 0;
@@ -147,7 +147,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
get
{
- if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue)
+ if (VideoStream is not null && VideoStream.Width.HasValue && VideoStream.Height.HasValue)
{
var size = new ImageDimensions(VideoStream.Width.Value, VideoStream.Height.Value);
@@ -174,7 +174,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
get
{
- if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue)
+ if (VideoStream is not null && VideoStream.Width.HasValue && VideoStream.Height.HasValue)
{
var size = new ImageDimensions(VideoStream.Width.Value, VideoStream.Height.Value);
@@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (BaseRequest.Static
|| EncodingHelper.IsCopyCodec(OutputAudioCodec))
{
- if (AudioStream != null)
+ if (AudioStream is not null)
{
return AudioStream.SampleRate;
}
@@ -227,7 +227,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (BaseRequest.Static
|| EncodingHelper.IsCopyCodec(OutputAudioCodec))
{
- if (AudioStream != null)
+ if (AudioStream is not null)
{
return AudioStream.BitDepth;
}
@@ -305,7 +305,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (BaseRequest.Static
|| EncodingHelper.IsCopyCodec(OutputVideoCodec))
{
- return VideoStream == null ? null : (VideoStream.AverageFrameRate ?? VideoStream.RealFrameRate);
+ return VideoStream is null ? null : (VideoStream.AverageFrameRate ?? VideoStream.RealFrameRate);
}
return BaseRequest.MaxFramerate ?? BaseRequest.Framerate;
@@ -419,7 +419,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
get
{
- if (VideoStream == null)
+ if (VideoStream is null)
{
return null;
}
@@ -437,7 +437,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
get
{
- if (AudioStream == null)
+ if (AudioStream is null)
{
return null;
}
@@ -556,7 +556,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public bool DeInterlace(string videoCodec, bool forceDeinterlaceIfSourceIsInterlaced)
{
var videoStream = VideoStream;
- var isInputInterlaced = videoStream != null && videoStream.IsInterlaced;
+ var isInputInterlaced = videoStream is not null && videoStream.IsInterlaced;
if (!isInputInterlaced)
{
diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
index 52c57b906..fe8e9063e 100644
--- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
@@ -38,7 +38,7 @@ namespace MediaBrowser.Controller.MediaEncoding
Version EncoderVersion { get; }
/// <summary>
- /// Whether p key pausing is supported.
+ /// Gets a value indicating whether p key pausing is supported.
/// </summary>
/// <value><c>true</c> if p key pausing is supported, <c>false</c> otherwise.</value>
bool IsPkeyPauseSupported { get; }
diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
index 2fe3a5472..fc9ea37d1 100644
--- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
+++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
@@ -166,7 +166,7 @@ namespace MediaBrowser.Controller.Net
var data = await GetDataToSend().ConfigureAwait(false);
- if (data != null)
+ if (data is not null)
{
await connection.SendAsync(
new WebSocketMessage<TReturnDataType>
@@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Net
{
var connection = _activeConnections.FirstOrDefault(c => c.Item1 == message.Connection);
- if (connection != null)
+ if (connection is not null)
{
DisposeConnection(connection);
}
diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs
index 7ae9ff746..e6bcc9ea8 100644
--- a/MediaBrowser.Controller/Playlists/Playlist.cs
+++ b/MediaBrowser.Controller/Playlists/Playlist.cs
@@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Playlists
public static List<BaseItem> GetPlaylistItems(string playlistMediaType, IEnumerable<BaseItem> inputItems, User user, DtoOptions options)
{
- if (user != null)
+ if (user is not null)
{
inputItems = inputItems.Where(i => i.IsVisible(user));
}
diff --git a/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs b/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs
index 888ca6c72..9ad0c26b0 100644
--- a/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs
+++ b/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs
@@ -16,6 +16,8 @@ namespace MediaBrowser.Controller.Providers
/// <summary>
/// Interface IRemoteMetadataProvider.
/// </summary>
+ /// <typeparam name="TItemType">The type of <see cref="BaseItem" />.</typeparam>
+ /// <typeparam name="TLookupInfoType">The type of <see cref="ItemLookupInfo" />.</typeparam>
public interface IRemoteMetadataProvider<TItemType, in TLookupInfoType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider, IRemoteSearchProvider<TLookupInfoType>
where TItemType : BaseItem, IHasLookupInfo<TLookupInfoType>
where TLookupInfoType : ItemLookupInfo, new()
@@ -32,6 +34,7 @@ namespace MediaBrowser.Controller.Providers
/// <summary>
/// Interface IRemoteMetadataProvider.
/// </summary>
+ /// <typeparam name="TLookupInfoType">The type of <see cref="ItemLookupInfo" />.</typeparam>
public interface IRemoteSearchProvider<in TLookupInfoType> : IRemoteSearchProvider
where TLookupInfoType : ItemLookupInfo
{
diff --git a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs
index a38bbaf69..8a3709462 100644
--- a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs
+++ b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs
@@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Providers
SearchResult = copy.SearchResult;
RemoveOldMetadata = copy.RemoveOldMetadata;
- if (copy.RefreshPaths != null && copy.RefreshPaths.Length > 0)
+ if (copy.RefreshPaths is not null && copy.RefreshPaths.Length > 0)
{
RefreshPaths ??= Array.Empty<string>();
@@ -58,7 +58,7 @@ namespace MediaBrowser.Controller.Providers
public bool RefreshItem(BaseItem item)
{
- if (RefreshPaths != null && RefreshPaths.Length > 0)
+ if (RefreshPaths is not null && RefreshPaths.Length > 0)
{
return RefreshPaths.Contains(item.Path ?? string.Empty, StringComparison.OrdinalIgnoreCase);
}
diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs
index 58a0fa2a9..952dd4870 100644
--- a/MediaBrowser.Controller/Providers/MetadataResult.cs
+++ b/MediaBrowser.Controller/Providers/MetadataResult.cs
@@ -59,7 +59,7 @@ namespace MediaBrowser.Controller.Providers
/// </summary>
public void ResetPeople()
{
- if (People == null)
+ if (People is null)
{
People = new List<PersonInfo>();
}
@@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Providers
}
}
- if (userData == null)
+ if (userData is null)
{
userData = new UserItemData()
{
diff --git a/MediaBrowser.Controller/Resolvers/ItemResolver.cs b/MediaBrowser.Controller/Resolvers/ItemResolver.cs
index e7bf013fa..a6da8384e 100644
--- a/MediaBrowser.Controller/Resolvers/ItemResolver.cs
+++ b/MediaBrowser.Controller/Resolvers/ItemResolver.cs
@@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Resolvers
{
var item = Resolve(args);
- if (item != null)
+ if (item is not null)
{
SetInitialItemValues(item, args);
}
diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs
index b4520ae48..25bf23d61 100644
--- a/MediaBrowser.Controller/Session/SessionInfo.cs
+++ b/MediaBrowser.Controller/Session/SessionInfo.cs
@@ -64,7 +64,7 @@ namespace MediaBrowser.Controller.Session
{
get
{
- if (Capabilities == null)
+ if (Capabilities is null)
{
return Array.Empty<string>();
}
@@ -182,7 +182,7 @@ namespace MediaBrowser.Controller.Session
{
get
{
- if (Capabilities == null || !Capabilities.SupportsMediaControl)
+ if (Capabilities is null || !Capabilities.SupportsMediaControl)
{
return false;
}
@@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Session
{
get
{
- if (Capabilities == null || !Capabilities.SupportsMediaControl)
+ if (Capabilities is null || !Capabilities.SupportsMediaControl)
{
return false;
}
@@ -239,7 +239,7 @@ namespace MediaBrowser.Controller.Session
/// </summary>
/// <value>The supported commands.</value>
public IReadOnlyList<GeneralCommandType> SupportedCommands
- => Capabilities == null ? Array.Empty<GeneralCommandType>() : Capabilities.SupportedCommands;
+ => Capabilities is null ? Array.Empty<GeneralCommandType>() : Capabilities.SupportedCommands;
public Tuple<ISessionController, bool> EnsureController<T>(Func<SessionInfo, ISessionController> factory)
{
@@ -296,7 +296,7 @@ namespace MediaBrowser.Controller.Session
{
_lastProgressInfo = progressInfo;
- if (_progressTimer == null)
+ if (_progressTimer is null)
{
_progressTimer = new Timer(OnProgressTimerCallback, null, 1000, 1000);
}
@@ -315,7 +315,7 @@ namespace MediaBrowser.Controller.Session
}
var progressInfo = _lastProgressInfo;
- if (progressInfo == null)
+ if (progressInfo is null)
{
return;
}
@@ -357,7 +357,7 @@ namespace MediaBrowser.Controller.Session
{
lock (_progressLock)
{
- if (_progressTimer != null)
+ if (_progressTimer is not null)
{
_progressTimer.Dispose();
_progressTimer = null;
diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
index 3a7685f34..ddbfeb8de 100644
--- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
+++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
@@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
_shuffledPlaylist.Clear();
LastChange = DateTime.UtcNow;
- if (!clearPlayingItem && playingItem != null)
+ if (!clearPlayingItem && playingItem is not null)
{
_sortedPlaylist.Add(playingItem);
if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
@@ -298,7 +298,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
LastChange = DateTime.UtcNow;
- if (playingItem != null)
+ if (playingItem is not null)
{
if (playlistItemIds.Contains(playingItem.PlaylistItemId))
{
diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs
index 9f8e921b4..548ccee2d 100644
--- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs
+++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs
@@ -51,7 +51,7 @@ namespace MediaBrowser.LocalMetadata
var file = GetXmlFile(info, directoryService);
- if (file == null)
+ if (file is null)
{
return Task.FromResult(result);
}
@@ -98,7 +98,7 @@ namespace MediaBrowser.LocalMetadata
{
var file = GetXmlFile(new ItemInfo(item), directoryService);
- if (file == null)
+ if (file is null)
{
return false;
}
diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
index dc13bf4f6..a8e2946f1 100644
--- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
+++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
@@ -32,7 +32,7 @@ namespace MediaBrowser.LocalMetadata.Images
public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
{
var parentPath = Path.GetDirectoryName(item.Path);
- if (parentPath == null)
+ if (parentPath is null)
{
return Enumerable.Empty<LocalImageInfo>();
}
diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
index 70fd68129..894aebed4 100644
--- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
+++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
@@ -94,7 +94,7 @@ namespace MediaBrowser.LocalMetadata.Images
{
var season = item as Season;
var series = season?.Series;
- if (series != null && series.IsFileProtocol)
+ if (series is not null && series.IsFileProtocol)
{
return true;
}
@@ -334,7 +334,7 @@ namespace MediaBrowser.LocalMetadata.Images
var extraFanartFolder = files
.FirstOrDefault(i => string.Equals(i.Name, "extrafanart", StringComparison.OrdinalIgnoreCase));
- if (extraFanartFolder != null)
+ if (extraFanartFolder is not null)
{
PopulateBackdropsFromExtraFanart(extraFanartFolder.FullName, images);
}
@@ -453,7 +453,7 @@ namespace MediaBrowser.LocalMetadata.Images
{
var image = GetImage(files, name, prefix);
- if (image == null)
+ if (image is null)
{
return false;
}
diff --git a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
index 33b082731..de3987b1e 100644
--- a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
+++ b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
@@ -11,7 +11,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
index 92ce14be2..1030cf055 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
@@ -54,11 +54,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(item);
-
- if (string.IsNullOrEmpty(metadataFile))
- {
- throw new ArgumentException("The metadata file was empty or null.", nameof(metadataFile));
- }
+ ArgumentException.ThrowIfNullOrEmpty(metadataFile);
var settings = new XmlReaderSettings
{
@@ -721,7 +717,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
var child = GetShare(subReader);
- if (child != null)
+ if (child is not null)
{
list.Add(child);
}
diff --git a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
index 7df800971..952ed3aac 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
@@ -71,7 +71,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
var child = GetLinkedChild(subReader);
- if (child != null)
+ if (child is not null)
{
list.Add(child);
}
diff --git a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
index b84307cb2..88b190f2b 100644
--- a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
@@ -84,7 +84,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
var child = GetLinkedChild(subReader);
- if (child != null)
+ if (child is not null)
{
list.Add(child);
}
diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
index 2d94c5de8..d92b50474 100644
--- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
@@ -126,7 +126,7 @@ namespace MediaBrowser.LocalMetadata.Savers
var baseItem = item;
- if (baseItem != null)
+ if (baseItem is not null)
{
await AddCommonNodesAsync(baseItem, writer).ConfigureAwait(false);
}
@@ -309,7 +309,7 @@ namespace MediaBrowser.LocalMetadata.Savers
await writer.WriteElementStringAsync(null, "RunningTime", null, Math.Floor(timespan.TotalMinutes).ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
}
- if (item.ProviderIds != null)
+ if (item.ProviderIds is not null)
{
foreach (var providerKey in item.ProviderIds.Keys)
{
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
index 22abf93ac..db177ff76 100644
--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
@@ -62,14 +62,14 @@ namespace MediaBrowser.MediaEncoding.Attachments
var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
var mediaSource = mediaSources
.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
- if (mediaSource == null)
+ if (mediaSource is null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} not found");
}
var mediaAttachment = mediaSource.MediaAttachments
.FirstOrDefault(i => i.Index == attachmentStreamIndex);
- if (mediaAttachment == null)
+ if (mediaAttachment is null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} has no attachment with stream index {attachmentStreamIndex}");
}
@@ -145,15 +145,8 @@ namespace MediaBrowser.MediaEncoding.Attachments
bool isExternal,
CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
-
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(outputPath);
@@ -300,15 +293,9 @@ namespace MediaBrowser.MediaEncoding.Attachments
string outputPath,
CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
index 409379c35..7e026b42e 100644
--- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
@@ -34,7 +34,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
get
{
var parentFolder = System.IO.Path.GetDirectoryName(_impl.FullName);
- if (parentFolder != null)
+ if (parentFolder is not null)
{
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
}
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
index 6ebaa4fff..3e53cbf29 100644
--- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
@@ -48,7 +48,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
MediaStreams = Array.Empty<MediaStream>()
};
- if (playlist == null)
+ if (playlist is null)
{
return outputStream;
}
@@ -89,7 +89,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
outputStream.PlaylistName = playlist.Name;
- if (playlist.StreamClips != null && playlist.StreamClips.Any())
+ if (playlist.StreamClips is not null && playlist.StreamClips.Any())
{
// Get the files in the playlist
outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToArray();
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
index 8c8fc6b0f..8479b7d50 100644
--- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
@@ -188,11 +188,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
// Work out what the version under test is
var version = GetFFmpegVersionInternal(versionOutput);
- _logger.LogInformation("Found ffmpeg version {Version}", version != null ? version.ToString() : "unknown");
+ _logger.LogInformation("Found ffmpeg version {Version}", version is not null ? version.ToString() : "unknown");
- if (version == null)
+ if (version is null)
{
- if (MaxVersion != null) // Version is unknown
+ if (MaxVersion is not null) // Version is unknown
{
if (MinVersion == MaxVersion)
{
@@ -215,7 +215,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_logger.LogWarning("FFmpeg validation: The minimum recommended version is {MinVersion}", MinVersion);
return false;
}
- else if (MaxVersion != null && version > MaxVersion) // Version is above what we recommend
+ else if (MaxVersion is not null && version > MaxVersion) // Version is above what we recommend
{
_logger.LogWarning("FFmpeg validation: The maximum recommended version is {MaxVersion}", MaxVersion);
return false;
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index b7c49ed99..ffaf5246d 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -75,7 +75,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
private bool _isVaapiDeviceInteli965 = false;
private bool _isVaapiDeviceSupportVulkanFmtModifier = false;
- private static string[] _vulkanFmtModifierExts = {
+ private static string[] _vulkanFmtModifierExts =
+ {
"VK_KHR_sampler_ycbcr_conversion",
"VK_EXT_image_drm_format_modifier",
"VK_KHR_external_memory_fd",
@@ -156,7 +157,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_configurationManager.SaveConfiguration("encoding", options);
// Only if mpeg path is set, try and set path to probe
- if (_ffmpegPath != null)
+ if (_ffmpegPath is not null)
{
// Determine a probe path from the mpeg path
_ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1");
@@ -530,12 +531,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
throw;
}
- if (result == null || (result.Streams == null && result.Format == null))
+ if (result is null || (result.Streams is null && result.Format is null))
{
throw new FfmpegException("ffprobe failed - streams and format are both null.");
}
- if (result.Streams != null)
+ if (result.Streams is not null)
{
// Normalize aspect ratio if invalid
foreach (var stream in result.Streams)
@@ -634,13 +635,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
return imageResolutionParameter;
}
-
private async Task<string> ExtractImageInternal(string inputPath, string container, MediaStream videoStream, int? imageStreamIndex, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, ImageFormat? targetFormat, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
var outputExtension = targetFormat switch
{
@@ -660,7 +657,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
var filters = new List<string>();
// deinterlace using bwdif algorithm for video stream.
- if (videoStream != null && videoStream.IsInterlaced)
+ if (videoStream is not null && videoStream.IsInterlaced)
{
filters.Add("bwdif=0:-1:0");
}
@@ -1017,7 +1014,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (!_disposed)
{
- if (Process != null)
+ if (Process is not null)
{
Process.Exited -= OnProcessExited;
DisposeProcess(Process);
diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
index afe4ff4e7..375041490 100644
--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
+++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
@@ -6,13 +6,13 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
@@ -28,8 +28,8 @@
<ItemGroup>
<PackageReference Include="BDInfo" Version="0.7.6.2" />
<PackageReference Include="libse" Version="3.6.5" />
- <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
- <PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
+ <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
</ItemGroup>
diff --git a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs
index 205e84153..1b5b5262a 100644
--- a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs
+++ b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs
@@ -17,17 +17,17 @@ namespace MediaBrowser.MediaEncoding.Probing
{
ArgumentNullException.ThrowIfNull(result);
- if (result.Format?.Tags != null)
+ if (result.Format?.Tags is not null)
{
result.Format.Tags = ConvertDictionaryToCaseInsensitive(result.Format.Tags);
}
- if (result.Streams != null)
+ if (result.Streams is not null)
{
// Convert all dictionaries to case insensitive
foreach (var stream in result.Streams)
{
- if (stream.Tags != null)
+ if (stream.Tags is not null)
{
stream.Tags = ConvertDictionaryToCaseInsensitive(stream.Tags);
}
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 417f1520f..7a3462b97 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -83,16 +83,16 @@ namespace MediaBrowser.MediaEncoding.Probing
var internalStreams = data.Streams ?? Array.Empty<MediaStreamInfo>();
info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format))
- .Where(i => i != null)
+ .Where(i => i is not null)
// Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know how to handle them
.Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
.ToList();
info.MediaAttachments = internalStreams.Select(GetMediaAttachment)
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList();
- if (data.Format != null)
+ if (data.Format is not null)
{
info.Container = NormalizeFormat(data.Format.FormatName);
@@ -110,7 +110,7 @@ namespace MediaBrowser.MediaEncoding.Probing
var tagStream = data.Streams?.FirstOrDefault(i => string.Equals(i.CodecType, tagStreamType, StringComparison.OrdinalIgnoreCase));
- if (tagStream?.Tags != null)
+ if (tagStream?.Tags is not null)
{
foreach (var (key, value) in tagStream.Tags)
{
@@ -118,7 +118,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- if (data.Format?.Tags != null)
+ if (data.Format?.Tags is not null)
{
foreach (var (key, value) in data.Format.Tags)
{
@@ -156,7 +156,7 @@ namespace MediaBrowser.MediaEncoding.Probing
else
{
var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist");
- info.Artists = artist == null
+ info.Artists = artist is null
? Array.Empty<string>()
: SplitDistinctArtists(artist, _nameDelimiters, true).ToArray();
}
@@ -182,7 +182,7 @@ namespace MediaBrowser.MediaEncoding.Probing
FetchStudios(info, tags, "copyright");
var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC");
- if (iTunExtc != null)
+ if (iTunExtc is not null)
{
var parts = iTunExtc.Split('|', StringSplitOptions.RemoveEmptyEntries);
// Example
@@ -199,19 +199,19 @@ namespace MediaBrowser.MediaEncoding.Probing
}
var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI");
- if (iTunXml != null)
+ if (iTunXml is not null)
{
FetchFromItunesInfo(iTunXml, info);
}
- if (data.Format != null && !string.IsNullOrEmpty(data.Format.Duration))
+ if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration))
{
info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCulture)).Ticks;
}
FetchWtvInfo(info, data);
- if (data.Chapters != null)
+ if (data.Chapters is not null)
{
info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray();
}
@@ -459,7 +459,7 @@ namespace MediaBrowser.MediaEncoding.Probing
using (var subtree = reader.ReadSubtree())
{
var dict = GetNameValuePair(subtree);
- if (dict != null)
+ if (dict is not null)
{
pairs.Add(dict);
}
@@ -614,7 +614,7 @@ namespace MediaBrowser.MediaEncoding.Probing
attachment.CodecTag = streamInfo.CodecTagString;
}
- if (streamInfo.Tags != null)
+ if (streamInfo.Tags is not null)
{
attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
@@ -680,7 +680,7 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.CodecTag = streamInfo.CodecTagString;
}
- if (streamInfo.Tags != null)
+ if (streamInfo.Tags is not null)
{
stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
@@ -855,7 +855,7 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.ColorPrimaries = streamInfo.ColorPrimaries;
}
- if (streamInfo.SideDataList != null)
+ if (streamInfo.SideDataList is not null)
{
foreach (var data in streamInfo.SideDataList)
{
@@ -899,7 +899,7 @@ namespace MediaBrowser.MediaEncoding.Probing
// The bitrate info of FLAC musics and some videos is included in formatInfo.
if (bitrate == 0
- && formatInfo != null
+ && formatInfo is not null
&& !string.IsNullOrEmpty(formatInfo.BitRate)
&& (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
{
@@ -934,7 +934,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
var bytes = GetNumberOfBytesFromTags(streamInfo);
- if (durationInSeconds != null && bytes != null)
+ if (durationInSeconds is not null && bytes is not null)
{
var bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
if (bps > 0)
@@ -945,7 +945,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
var disposition = streamInfo.Disposition;
- if (disposition != null)
+ if (disposition is not null)
{
if (disposition.GetValueOrDefault("default") == 1)
{
@@ -989,7 +989,7 @@ namespace MediaBrowser.MediaEncoding.Probing
/// <returns>System.String.</returns>
private string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
{
- if (tags == null)
+ if (tags is null)
{
return null;
}
@@ -1121,7 +1121,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
// Get the first info stream
var stream = result.Streams?.FirstOrDefault(s => string.Equals(s.CodecType, "audio", StringComparison.OrdinalIgnoreCase));
- if (stream == null)
+ if (stream is null)
{
return;
}
@@ -1144,7 +1144,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private int? GetBPSFromTags(MediaStreamInfo streamInfo)
{
- if (streamInfo?.Tags == null)
+ if (streamInfo?.Tags is null)
{
return null;
}
@@ -1161,7 +1161,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
{
- if (streamInfo?.Tags == null)
+ if (streamInfo?.Tags is null)
{
return null;
}
@@ -1177,7 +1177,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
{
- if (streamInfo?.Tags == null)
+ if (streamInfo?.Tags is null)
{
return null;
}
@@ -1195,7 +1195,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private void SetSize(InternalMediaInfoResult data, MediaInfo info)
{
- if (data.Format == null)
+ if (data.Format is null)
{
return;
}
@@ -1294,7 +1294,7 @@ namespace MediaBrowser.MediaEncoding.Probing
// Set album artist
var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
- audio.AlbumArtists = albumArtist != null
+ audio.AlbumArtists = albumArtist is not null
? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
: Array.Empty<string>();
@@ -1489,7 +1489,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var info = new ChapterInfo();
- if (chapter.Tags != null && chapter.Tags.TryGetValue("title", out string name))
+ if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
{
info.Name = name;
}
@@ -1510,7 +1510,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var tags = data.Format?.Tags;
- if (tags == null)
+ if (tags is null)
{
return;
}
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
index 9185faf67..b7c2fd7b1 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
@@ -174,12 +174,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
var result = CharsetDetector.DetectFromStream(stream).Detected;
stream.Position = 0;
- if (result != null)
+ if (result is not null)
{
_logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path);
using var reader = new StreamReader(stream, result.Encoding);
- var text = await reader.ReadToEndAsync().ConfigureAwait(false);
+ var text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
return new MemoryStream(Encoding.UTF8.GetBytes(text));
}
@@ -249,17 +249,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value)
{
+ ArgumentException.ThrowIfNullOrEmpty(format);
+
if (string.Equals(format, SubtitleFormat.ASS, StringComparison.OrdinalIgnoreCase))
{
value = new AssWriter();
return true;
}
- if (string.IsNullOrEmpty(format))
- {
- throw new ArgumentNullException(nameof(format));
- }
-
if (string.Equals(format, "json", StringComparison.OrdinalIgnoreCase))
{
value = new JsonWriter();
@@ -355,15 +352,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
private async Task ConvertTextSubtitleToSrtInternal(MediaStream subtitleStream, MediaSourceInfo mediaSource, string outputPath, CancellationToken cancellationToken)
{
var inputPath = subtitleStream.Path;
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath)));
@@ -522,15 +513,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
string outputPath,
CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath)));
@@ -650,7 +635,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
encoding = reader.CurrentEncoding;
- text = await reader.ReadToEndAsync().ConfigureAwait(false);
+ text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
}
var newText = text.Replace(",Arial,", ",Arial Unicode MS,", StringComparison.Ordinal);
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);
}
diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs
index cbbb343e5..df9d15ec2 100644
--- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs
+++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs
@@ -66,7 +66,7 @@ namespace MediaBrowser.Providers.BoxSets
var libraryFolderIds = item.GetLibraryFolderIds();
var itemLibraryFolderIds = item.LibraryFolderIds;
- if (itemLibraryFolderIds == null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds))
+ if (itemLibraryFolderIds is null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds))
{
item.LibraryFolderIds = libraryFolderIds;
updatedType |= ItemUpdateType.MetadataImport;
diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs
index 4632e1d51..50e704060 100644
--- a/MediaBrowser.Providers/Manager/ImageSaver.cs
+++ b/MediaBrowser.Providers/Manager/ImageSaver.cs
@@ -87,10 +87,7 @@ namespace MediaBrowser.Providers.Manager
public async Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(mimeType))
- {
- throw new ArgumentNullException(nameof(mimeType));
- }
+ ArgumentException.ThrowIfNullOrEmpty(mimeType);
var saveLocally = item.SupportsLocalMetadata && item.IsSaveLocalMetadataEnabled() && !item.ExtraType.HasValue && item is not Audio;
@@ -108,7 +105,7 @@ namespace MediaBrowser.Providers.Manager
{
var series = season.Series;
- if (series != null && series.SupportsLocalMetadata && series.IsSaveLocalMetadataEnabled())
+ if (series is not null && series.SupportsLocalMetadata && series.IsSaveLocalMetadataEnabled())
{
saveLocally = true;
}
@@ -144,7 +141,7 @@ namespace MediaBrowser.Providers.Manager
}
var currentImage = GetCurrentImage(item, type, index);
- var currentImageIsLocalFile = currentImage != null && currentImage.IsLocalFile;
+ var currentImageIsLocalFile = currentImage is not null && currentImage.IsLocalFile;
var currentImagePath = currentImage?.Path;
var savedPaths = new List<string>();
@@ -374,7 +371,7 @@ namespace MediaBrowser.Providers.Manager
if (type == ImageType.Thumb && saveLocally)
{
- if (season != null && season.IndexNumber.HasValue)
+ if (season is not null && season.IndexNumber.HasValue)
{
var seriesFolder = season.SeriesPath;
@@ -397,7 +394,7 @@ namespace MediaBrowser.Providers.Manager
if (type == ImageType.Banner && saveLocally)
{
- if (season != null && season.IndexNumber.HasValue)
+ if (season is not null && season.IndexNumber.HasValue)
{
var seriesFolder = season.SeriesPath;
@@ -533,7 +530,7 @@ namespace MediaBrowser.Providers.Manager
return new[] { GetSavePathForItemInMixedFolder(item, type, "fanart", extension) };
}
- if (season != null && season.IndexNumber.HasValue)
+ if (season is not null && season.IndexNumber.HasValue)
{
var seriesFolder = season.SeriesPath;
@@ -576,7 +573,7 @@ namespace MediaBrowser.Providers.Manager
if (type == ImageType.Primary)
{
- if (season != null && season.IndexNumber.HasValue)
+ if (season is not null && season.IndexNumber.HasValue)
{
var seriesFolder = season.SeriesPath;
diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs
index bbbbfad54..a0f48840e 100644
--- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs
+++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs
@@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.Manager
for (var i = 0; i < _singularImages.Length; i++)
{
var currentImage = item.GetImageInfo(_singularImages[i], 0);
- if (currentImage != null)
+ if (currentImage is not null)
{
singular.Add(currentImage);
}
@@ -395,11 +395,11 @@ namespace MediaBrowser.Providers.Manager
var type = _singularImages[i];
var image = GetFirstLocalImageInfoByType(images, type);
- if (image != null)
+ if (image is not null)
{
var currentImage = item.GetImageInfo(type, 0);
- if (currentImage == null || !string.Equals(currentImage.Path, image.FileInfo.FullName, StringComparison.OrdinalIgnoreCase))
+ if (currentImage is null || !string.Equals(currentImage.Path, image.FileInfo.FullName, StringComparison.OrdinalIgnoreCase))
{
item.SetImagePath(type, image.FileInfo);
changed = true;
@@ -471,7 +471,7 @@ namespace MediaBrowser.Providers.Manager
CancellationToken cancellationToken)
{
var eligibleImages = images
- .Where(i => i.Type == type && (i.Width == null || i.Width >= minWidth))
+ .Where(i => i.Type == type && (i.Width is null || i.Width >= minWidth))
.ToList();
if (EnableImageStub(item) && eligibleImages.Count > 0)
@@ -539,7 +539,7 @@ namespace MediaBrowser.Providers.Manager
if (item is IItemByName and not MusicArtist)
{
var hasDualAccess = item as IHasDualAccess;
- if (hasDualAccess == null || hasDualAccess.IsAccessedByName)
+ if (hasDualAccess is null || hasDualAccess.IsAccessedByName)
{
return true;
}
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index 0f3f1bdcb..5b5ca0fca 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -146,7 +146,7 @@ namespace MediaBrowser.Providers.Manager
{
var id = itemOfType.GetLookupInfo();
- if (refreshOptions.SearchResult != null)
+ if (refreshOptions.SearchResult is not null)
{
ApplySearchResult(id, refreshOptions.SearchResult);
}
@@ -190,7 +190,7 @@ namespace MediaBrowser.Providers.Manager
if (item.IsFileProtocol)
{
var file = TryGetFile(item.Path, refreshOptions.DirectoryService);
- if (file != null)
+ if (file is not null)
{
item.DateModified = file.LastWriteTimeUtc;
}
@@ -243,7 +243,7 @@ namespace MediaBrowser.Providers.Manager
protected async Task SaveItemAsync(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken)
{
- if (result.Item.SupportsPeople && result.People != null)
+ if (result.Item.SupportsPeople && result.People is not null)
{
var baseItem = result.Item;
@@ -815,7 +815,7 @@ namespace MediaBrowser.Providers.Manager
var providerName = provider.GetType().Name;
Logger.LogDebug("Running {Provider} for {Item}", providerName, logName);
- if (id != null && !tmpDataMerged)
+ if (id is not null && !tmpDataMerged)
{
MergeNewData(temp.Item, id);
tmpDataMerged = true;
@@ -918,15 +918,8 @@ namespace MediaBrowser.Providers.Manager
var source = sourceResult.Item;
var target = targetResult.Item;
- if (source == null)
- {
- throw new ArgumentException("Item cannot be null.", nameof(sourceResult));
- }
-
- if (target == null)
- {
- throw new ArgumentException("Item cannot be null.", nameof(targetResult));
- }
+ ArgumentNullException.ThrowIfNull(sourceResult);
+ ArgumentNullException.ThrowIfNull(targetResult);
if (!lockedFields.Contains(MetadataField.Name))
{
@@ -1005,11 +998,11 @@ namespace MediaBrowser.Providers.Manager
if (!lockedFields.Contains(MetadataField.Cast))
{
- if (replaceData || targetResult.People == null || targetResult.People.Count == 0)
+ if (replaceData || targetResult.People is null || targetResult.People.Count == 0)
{
targetResult.People = sourceResult.People;
}
- else if (targetResult.People != null && sourceResult.People != null)
+ else if (targetResult.People is not null && sourceResult.People is not null)
{
MergePeople(sourceResult.People, targetResult.People);
}
@@ -1114,7 +1107,7 @@ namespace MediaBrowser.Providers.Manager
var normalizedName = person.Name.RemoveDiacritics();
var personInSource = source.FirstOrDefault(i => string.Equals(i.Name.RemoveDiacritics(), normalizedName, StringComparison.OrdinalIgnoreCase));
- if (personInSource != null)
+ if (personInSource is not null)
{
foreach (var providerId in personInSource.ProviderIds)
{
@@ -1178,7 +1171,7 @@ namespace MediaBrowser.Providers.Manager
{
if (source is Video sourceCast && target is Video targetCast)
{
- if (replaceData || targetCast.Video3DFormat == null)
+ if (replaceData || targetCast.Video3DFormat is null)
{
targetCast.Video3DFormat = sourceCast.Video3DFormat;
}
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs
index ac4dc1bc3..d3ac2f6cd 100644
--- a/MediaBrowser.Providers/Manager/ProviderManager.cs
+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs
@@ -135,7 +135,7 @@ namespace MediaBrowser.Providers.Manager
var service = _metadataServices.FirstOrDefault(current => current.CanRefreshPrimary(type));
service ??= _metadataServices.FirstOrDefault(current => current.CanRefresh(item));
- if (service == null)
+ if (service is null)
{
_logger.LogError("Unable to find a metadata service for item of type {TypeName}", item.GetType().Name);
return Task.FromResult(ItemUpdateType.None);
@@ -660,7 +660,7 @@ namespace MediaBrowser.Providers.Manager
if (!includeDisabled)
{
- if (libraryOptions.MetadataSavers == null)
+ if (libraryOptions.MetadataSavers is null)
{
if (options.DisabledMetadataSavers.Contains(saver.Name, StringComparison.OrdinalIgnoreCase))
{
@@ -725,7 +725,7 @@ namespace MediaBrowser.Providers.Manager
{
LibraryOptions libraryOptions;
- if (referenceItem == null)
+ if (referenceItem is null)
{
// Give it a dummy path just so that it looks like a file system item
var dummy = new TItemType
@@ -776,7 +776,7 @@ namespace MediaBrowser.Providers.Manager
{
var existingMatch = resultList.FirstOrDefault(i => i.ProviderIds.Any(p => string.Equals(result.GetProviderId(p.Key), p.Value, StringComparison.OrdinalIgnoreCase)));
- if (existingMatch == null)
+ if (existingMatch is null)
{
resultList.Add(result);
}
@@ -831,7 +831,7 @@ namespace MediaBrowser.Providers.Manager
{
var provider = _metadataProviders.OfType<IRemoteSearchProvider>().FirstOrDefault(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ArgumentException("Search provider not found.");
}
@@ -881,7 +881,7 @@ namespace MediaBrowser.Providers.Manager
i.UrlFormatString,
value)
};
- }).Where(i => i != null)
+ }).Where(i => i is not null)
.Concat(item.GetRelatedUrls())!; // We just filtered out all the nulls
}
@@ -1002,7 +1002,7 @@ namespace MediaBrowser.Providers.Manager
try
{
var item = libraryManager.GetItemById(refreshItem.Item1);
- if (item == null)
+ if (item is null)
{
continue;
}
@@ -1071,7 +1071,7 @@ namespace MediaBrowser.Providers.Manager
var musicArtists = albums
.Select(i => i.MusicArtist)
- .Where(i => i != null);
+ .Where(i => i is not null);
var musicArtistRefreshTasks = musicArtists.Select(i => i.ValidateChildren(new SimpleProgress<double>(), options, true, cancellationToken));
diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
index eb921e6f5..d91402f51 100644
--- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj
+++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
@@ -18,9 +18,9 @@
<ItemGroup>
<PackageReference Include="LrcParser" Version="2022.529.1" />
<PackageReference Include="MetaBrainz.MusicBrainz" Version="5.0.0" />
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
- <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="OptimizedPriorityQueue" Version="5.1.0" />
<PackageReference Include="PlaylistsNET" Version="1.2.1" />
@@ -29,14 +29,14 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<!-- Code Analyzers-->
diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
index 3699e8f49..74210b1f2 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
@@ -149,7 +149,7 @@ namespace MediaBrowser.Providers.MediaInfo
tags = file.GetTag(TagTypes.Id3v1);
}
- if (tags != null)
+ if (tags is not null)
{
if (audio.SupportsPeople && !audio.LockedFields.Contains(MetadataField.Cast))
{
diff --git a/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs b/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs
index d60d829de..fed23df15 100644
--- a/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs
@@ -138,7 +138,7 @@ namespace MediaBrowser.Providers.MediaInfo
.FirstOrDefault(attachment => !string.IsNullOrEmpty(attachment.FileName)
&& imageFileNames.Any(name => attachment.FileName.Contains(name, StringComparison.OrdinalIgnoreCase)));
- if (attachmentStream != null)
+ if (attachmentStream is not null)
{
return await ExtractAttachment(item, attachmentStream, mediaSource, cancellationToken);
}
@@ -162,7 +162,7 @@ namespace MediaBrowser.Providers.MediaInfo
&& imageFileNames.Any(name => stream.Comment.Contains(name, StringComparison.OrdinalIgnoreCase)));
// Primary type only: default to first image if none found by label
- if (imageStream == null)
+ if (imageStream is null)
{
if (type == ImageType.Primary)
{
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
index 7412a10d0..58b23a36d 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
@@ -180,7 +180,7 @@ namespace MediaBrowser.Providers.MediaInfo
var startIndex = mediaStreams.Count == 0 ? 0 : (mediaStreams.Max(i => i.Index) + 1);
- if (mediaInfo != null)
+ if (mediaInfo is not null)
{
foreach (var mediaStream in mediaInfo.MediaStreams)
{
@@ -195,7 +195,7 @@ namespace MediaBrowser.Providers.MediaInfo
// .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase);
// For DVDs this may not always be accurate, so don't set the runtime if the item already has one
- var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0;
+ var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks is null || video.RunTimeTicks.Value == 0;
if (needToSetRuntime)
{
@@ -218,7 +218,7 @@ namespace MediaBrowser.Providers.MediaInfo
video.Container = mediaInfo.Container;
chapters = mediaInfo.Chapters ?? Array.Empty<ChapterInfo>();
- if (blurayInfo != null)
+ if (blurayInfo is not null)
{
FetchBdInfo(video, ref chapters, mediaStreams, blurayInfo);
}
@@ -241,7 +241,7 @@ namespace MediaBrowser.Providers.MediaInfo
var libraryOptions = _libraryManager.GetLibraryOptions(video);
- if (mediaInfo != null)
+ if (mediaInfo is not null)
{
FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions);
FetchPeople(video, mediaInfo, options);
@@ -288,7 +288,7 @@ namespace MediaBrowser.Providers.MediaInfo
NormalizeChapterNames(chapters);
var extractDuringScan = false;
- if (libraryOptions != null)
+ if (libraryOptions is not null)
{
extractDuringScan = libraryOptions.ExtractChapterImagesDuringLibraryScan;
}
@@ -333,7 +333,7 @@ namespace MediaBrowser.Providers.MediaInfo
var videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
// Grab the values that ffprobe recorded
- if (videoStream != null)
+ if (videoStream is not null)
{
currentBitRate = videoStream.BitRate;
currentWidth = videoStream.Width;
@@ -349,7 +349,7 @@ namespace MediaBrowser.Providers.MediaInfo
video.RunTimeTicks = blurayInfo.RunTimeTicks;
}
- if (blurayInfo.Chapters != null)
+ if (blurayInfo.Chapters is not null)
{
double[] brChapter = blurayInfo.Chapters;
chapters = new ChapterInfo[brChapter.Length];
@@ -365,7 +365,7 @@ namespace MediaBrowser.Providers.MediaInfo
videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
// Use the ffprobe values if these are empty
- if (videoStream != null)
+ if (videoStream is not null)
{
videoStream.BitRate = IsEmpty(videoStream.BitRate) ? currentBitRate : videoStream.BitRate;
videoStream.Width = IsEmpty(videoStream.Width) ? currentWidth : videoStream.Width;
@@ -572,7 +572,7 @@ namespace MediaBrowser.Providers.MediaInfo
bool requirePerfectMatch;
bool enabled;
- if (libraryOptions.SubtitleDownloadLanguages == null)
+ if (libraryOptions.SubtitleDownloadLanguages is null)
{
subtitleDownloadLanguages = subtitleOptions.DownloadLanguages;
skipIfEmbeddedSubtitlesPresent = subtitleOptions.SkipIfEmbeddedSubtitlesPresent;
@@ -693,7 +693,7 @@ namespace MediaBrowser.Providers.MediaInfo
byte? titleNumber = null;
- if (primaryTitle != null)
+ if (primaryTitle is not null)
{
titleNumber = primaryTitle.VideoTitleSetNumber;
item.RunTimeTicks = GetRuntime(primaryTitle);
diff --git a/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs b/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs
index bb2d584c1..909cbb9b9 100644
--- a/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs
+++ b/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs
@@ -199,7 +199,7 @@ namespace MediaBrowser.Providers.MediaInfo
{
var externalPathInfo = _externalPathParser.ParseFile(file, fileNameWithoutExtension[prefix.Length..].ToString());
- if (externalPathInfo != null)
+ if (externalPathInfo is not null)
{
externalPathInfos.Add(externalPathInfo);
}
diff --git a/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs
index 75f997a28..280021955 100644
--- a/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs
@@ -108,14 +108,14 @@ namespace MediaBrowser.Providers.MediaInfo
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
{
var video = item as Video;
- if (video == null || video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso)
+ if (video is null || video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso)
{
var path = item.Path;
if (!string.IsNullOrWhiteSpace(path) && item.IsFileProtocol)
{
var file = directoryService.GetFile(path);
- if (file != null && file.LastWriteTimeUtc != item.DateModified)
+ if (file is not null && file.LastWriteTimeUtc != item.DateModified)
{
_logger.LogDebug("Refreshing {ItemPath} due to date modified timestamp change.", path);
return true;
@@ -123,7 +123,7 @@ namespace MediaBrowser.Providers.MediaInfo
}
}
- if (item.SupportsLocalMetadata && video != null && !video.IsPlaceHolder
+ if (item.SupportsLocalMetadata && video is not null && !video.IsPlaceHolder
&& !video.SubtitleFiles.SequenceEqual(
_subtitleResolver.GetExternalFiles(video, directoryService, false)
.Select(info => info.Path).ToList(),
@@ -133,7 +133,7 @@ namespace MediaBrowser.Providers.MediaInfo
return true;
}
- if (item.SupportsLocalMetadata && video != null && !video.IsPlaceHolder
+ if (item.SupportsLocalMetadata && video is not null && !video.IsPlaceHolder
&& !video.AudioFiles.SequenceEqual(
_audioResolver.GetExternalFiles(video, directoryService, false)
.Select(info => info.Path).ToList(),
diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
index b2b93940a..20fb4dab9 100644
--- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
+++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
@@ -192,7 +192,7 @@ namespace MediaBrowser.Providers.MediaInfo
var result = searchResults.FirstOrDefault();
- if (result != null)
+ if (result is not null)
{
await _subtitleManager.DownloadSubtitles(video, result.Id, cancellationToken).ConfigureAwait(false);
diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs
index eb9071a52..f21939d2a 100644
--- a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs
+++ b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs
@@ -80,7 +80,7 @@ namespace MediaBrowser.Providers.MediaInfo
bool skipIfEmbeddedSubtitlesPresent;
bool skipIfAudioTrackMatches;
- if (libraryOptions.SubtitleDownloadLanguages == null)
+ if (libraryOptions.SubtitleDownloadLanguages is null)
{
subtitleDownloadLanguages = options.DownloadLanguages;
skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;
@@ -172,7 +172,7 @@ namespace MediaBrowser.Providers.MediaInfo
bool skipIfAudioTrackMatches;
bool requirePerfectMatch;
- if (libraryOptions.SubtitleDownloadLanguages == null)
+ if (libraryOptions.SubtitleDownloadLanguages is null)
{
subtitleDownloadLanguages = options.DownloadLanguages;
skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;
diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
index d4bf62970..ba7ad4072 100644
--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
@@ -89,14 +89,14 @@ namespace MediaBrowser.Providers.MediaInfo
var query = new MediaStreamQuery { ItemId = item.Id, Index = item.DefaultVideoStreamIndex };
var videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
- if (videoStream == null)
+ if (videoStream is null)
{
query.Type = MediaStreamType.Video;
query.Index = null;
videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
}
- if (videoStream == null)
+ if (videoStream is null)
{
_logger.LogInformation("Skipping image extraction: no video stream found for {Path}.", item.Path ?? string.Empty);
return new DynamicImageResponse { HasImage = false };
diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs
index ac40f0b3a..58cd23aa3 100644
--- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs
+++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs
@@ -152,6 +152,7 @@ namespace MediaBrowser.Providers.Music
return ItemUpdateType.MetadataEdit;
}
}
+
return ItemUpdateType.None;
}
diff --git a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs
index fe9986d42..db4c5f436 100644
--- a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs
+++ b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs
@@ -157,7 +157,7 @@ namespace MediaBrowser.Providers.Playlists
if (!string.IsNullOrWhiteSpace(path) && item.IsFileProtocol)
{
var file = directoryService.GetFile(path);
- if (file != null && file.LastWriteTimeUtc != item.DateModified)
+ if (file is not null && file.LastWriteTimeUtc != item.DateModified)
{
_logger.LogDebug("Refreshing {0} due to date modified timestamp change.", path);
return true;
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumImageProvider.cs
index ad0247fb2..7fb438d8a 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumImageProvider.cs
@@ -63,7 +63,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
await using FileStream jsonStream = AsyncFile.OpenRead(path);
var obj = await JsonSerializer.DeserializeAsync<AudioDbAlbumProvider.RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (obj != null && obj.album != null && obj.album.Count > 0)
+ if (obj is not null && obj.album is not null && obj.album.Count > 0)
{
return GetImages(obj.album[0]);
}
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs
index 43f30824b..b92f1f59f 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs
@@ -71,7 +71,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
await using FileStream jsonStream = AsyncFile.OpenRead(path);
var obj = await JsonSerializer.DeserializeAsync<RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (obj != null && obj.album != null && obj.album.Count > 0)
+ if (obj is not null && obj.album is not null && obj.album.Count > 0)
{
result.Item = new MusicAlbum();
result.HasMetadata = true;
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistImageProvider.cs
index 9c2447660..6d67ad634 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistImageProvider.cs
@@ -65,7 +65,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
await using FileStream jsonStream = AsyncFile.OpenRead(path);
var obj = await JsonSerializer.DeserializeAsync<AudioDbArtistProvider.RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (obj != null && obj.artists != null && obj.artists.Count > 0)
+ if (obj is not null && obj.artists is not null && obj.artists.Count > 0)
{
return GetImages(obj.artists[0]);
}
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs
index 538dc67c4..40c489885 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs
@@ -70,7 +70,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
await using FileStream jsonStream = AsyncFile.OpenRead(path);
var obj = await JsonSerializer.DeserializeAsync<RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (obj != null && obj.artists != null && obj.artists.Count > 0)
+ if (obj is not null && obj.artists is not null && obj.artists.Count > 0)
{
result.Item = new MusicArtist();
result.HasMetadata = true;
diff --git a/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs
index 4d9feca6d..34f45f0d5 100644
--- a/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs
+++ b/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs
@@ -13,6 +13,7 @@ using MediaBrowser.Providers.Music;
using MetaBrainz.MusicBrainz;
using MetaBrainz.MusicBrainz.Interfaces.Entities;
using MetaBrainz.MusicBrainz.Interfaces.Searches;
+using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Plugins.MusicBrainz;
@@ -21,16 +22,36 @@ namespace MediaBrowser.Providers.Plugins.MusicBrainz;
/// </summary>
public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder, IDisposable
{
+ private readonly ILogger<MusicBrainzAlbumProvider> _logger;
private readonly Query _musicBrainzQuery;
+ private readonly string _musicBrainzDefaultUri = "https://musicbrainz.org";
/// <summary>
/// Initializes a new instance of the <see cref="MusicBrainzAlbumProvider"/> class.
/// </summary>
- public MusicBrainzAlbumProvider()
+ /// <param name="logger">The logger.</param>
+ public MusicBrainzAlbumProvider(ILogger<MusicBrainzAlbumProvider> logger)
{
+ _logger = logger;
+
MusicBrainz.Plugin.Instance!.ConfigurationChanged += (_, _) =>
{
- Query.DefaultServer = MusicBrainz.Plugin.Instance.Configuration.Server;
+ if (Uri.TryCreate(MusicBrainz.Plugin.Instance.Configuration.Server, UriKind.Absolute, out var server))
+ {
+ Query.DefaultServer = server.Host;
+ Query.DefaultPort = server.Port;
+ Query.DefaultUrlScheme = server.Scheme;
+ }
+ else
+ {
+ // Fallback to official server
+ _logger.LogWarning("Invalid MusicBrainz server specified, falling back to official server");
+ var defaultServer = new Uri(_musicBrainzDefaultUri);
+ Query.DefaultServer = defaultServer.Host;
+ Query.DefaultPort = defaultServer.Port;
+ Query.DefaultUrlScheme = defaultServer.Scheme;
+ }
+
Query.DelayBetweenRequests = MusicBrainz.Plugin.Instance.Configuration.RateLimit;
};
@@ -167,7 +188,7 @@ public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, Albu
// TODO: Actually try to match the release. Simply taking the first result is stupid.
var releaseGroup = await _musicBrainzQuery.LookupReleaseGroupAsync(new Guid(releaseGroupId), Include.None, null, cancellationToken).ConfigureAwait(false);
var release = releaseGroup.Releases?.Count > 0 ? releaseGroup.Releases[0] : null;
- if (release != null)
+ if (release is not null)
{
releaseId = release.Id.ToString();
result.HasMetadata = true;
@@ -193,7 +214,7 @@ public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, Albu
releaseResult = releaseSearchResults.Results.Count > 0 ? releaseSearchResults.Results[0].Item : null;
}
- if (releaseResult != null)
+ if (releaseResult is not null)
{
releaseId = releaseResult.Id.ToString();
diff --git a/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzArtistProvider.cs b/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzArtistProvider.cs
index 2cc3a13be..718b5a1c4 100644
--- a/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzArtistProvider.cs
+++ b/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzArtistProvider.cs
@@ -4,7 +4,6 @@ using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
-using System.Xml;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Providers;
@@ -14,6 +13,7 @@ using MediaBrowser.Providers.Music;
using MetaBrainz.MusicBrainz;
using MetaBrainz.MusicBrainz.Interfaces.Entities;
using MetaBrainz.MusicBrainz.Interfaces.Searches;
+using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Plugins.MusicBrainz;
@@ -22,16 +22,36 @@ namespace MediaBrowser.Providers.Plugins.MusicBrainz;
/// </summary>
public class MusicBrainzArtistProvider : IRemoteMetadataProvider<MusicArtist, ArtistInfo>, IDisposable
{
+ private readonly ILogger<MusicBrainzArtistProvider> _logger;
private readonly Query _musicBrainzQuery;
+ private readonly string _musicBrainzDefaultUri = "https://musicbrainz.org";
/// <summary>
/// Initializes a new instance of the <see cref="MusicBrainzArtistProvider"/> class.
/// </summary>
- public MusicBrainzArtistProvider()
+ /// <param name="logger">The logger.</param>
+ public MusicBrainzArtistProvider(ILogger<MusicBrainzArtistProvider> logger)
{
+ _logger = logger;
+
MusicBrainz.Plugin.Instance!.ConfigurationChanged += (_, _) =>
{
- Query.DefaultServer = MusicBrainz.Plugin.Instance.Configuration.Server;
+ if (Uri.TryCreate(MusicBrainz.Plugin.Instance.Configuration.Server, UriKind.Absolute, out var server))
+ {
+ Query.DefaultServer = server.Host;
+ Query.DefaultPort = server.Port;
+ Query.DefaultUrlScheme = server.Scheme;
+ }
+ else
+ {
+ // Fallback to official server
+ _logger.LogWarning("Invalid MusicBrainz server specified, falling back to official server");
+ var defaultServer = new Uri(_musicBrainzDefaultUri);
+ Query.DefaultServer = defaultServer.Host;
+ Query.DefaultPort = defaultServer.Port;
+ Query.DefaultUrlScheme = defaultServer.Scheme;
+ }
+
Query.DelayBetweenRequests = MusicBrainz.Plugin.Instance.Configuration.RateLimit;
};
@@ -113,7 +133,7 @@ public class MusicBrainzArtistProvider : IRemoteMetadataProvider<MusicArtist, Ar
var singleResult = searchResults.FirstOrDefault();
- if (singleResult != null)
+ if (singleResult is not null)
{
musicBrainzId = singleResult.GetProviderId(MetadataProvider.MusicBrainzArtist);
result.Item.Overview = singleResult.Overview;
diff --git a/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs b/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs
index 8bfdc461e..38379ae5d 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs
@@ -16,7 +16,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
if (reader.TokenType == JsonTokenType.String)
{
var str = reader.GetString();
- if (str == null || str.Equals("N/A", StringComparison.OrdinalIgnoreCase))
+ if (str is null || str.Equals("N/A", StringComparison.OrdinalIgnoreCase))
{
return null;
}
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
index e5753b2b5..3ef94ca93 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
@@ -90,7 +90,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var imdbId = searchInfo.GetProviderId(MetadataProvider.Imdb);
var urlQuery = new StringBuilder("plot=full&r=json");
- if (episodeSearchInfo != null)
+ if (episodeSearchInfo is not null)
{
episodeSearchInfo.SeriesProviderIds.TryGetValue(MetadataProvider.Imdb.ToString(), out imdbId);
if (searchInfo.IndexNumber.HasValue)
@@ -142,7 +142,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
if (isSearch)
{
var searchResultList = await JsonSerializer.DeserializeAsync<SearchResultList>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (searchResultList?.Search != null)
+ if (searchResultList?.Search is not null)
{
var resultCount = searchResultList.Search.Count;
var result = new RemoteSearchResult[resultCount];
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
index 10077e5c8..6713a34e6 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
@@ -141,7 +141,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var seasonResult = await GetSeasonRootObject(seriesImdbId, seasonNumber, cancellationToken).ConfigureAwait(false);
- if (seasonResult?.Episodes == null)
+ if (seasonResult?.Episodes is null)
{
return false;
}
@@ -161,7 +161,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
}
// finally, search by numbers
- if (result == null)
+ if (result is null)
{
foreach (var episode in seasonResult.Episodes)
{
@@ -173,7 +173,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
}
}
- if (result == null)
+ if (result is null)
{
return false;
}
@@ -365,10 +365,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
internal string GetDataFilePath(string imdbId)
{
- if (string.IsNullOrEmpty(imdbId))
- {
- throw new ArgumentNullException(nameof(imdbId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(imdbId);
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
@@ -379,10 +376,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
internal string GetSeasonFilePath(string imdbId, int seasonId)
{
- if (string.IsNullOrEmpty(imdbId))
- {
- throw new ArgumentNullException(nameof(imdbId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(imdbId);
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
@@ -540,10 +534,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
public float? GetRottenTomatoScore()
{
- if (Ratings != null)
+ if (Ratings is not null)
{
var rating = Ratings.FirstOrDefault(i => string.Equals(i.Source, "Rotten Tomatoes", StringComparison.OrdinalIgnoreCase));
- if (rating?.Value != null)
+ if (rating?.Value is not null)
{
var value = rating.Value.TrimEnd('%');
if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var score))
diff --git a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs
index ffbb338e8..4ff9e0247 100644
--- a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs
@@ -70,7 +70,7 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
var imageInfo = GetImage(item, thumbsPath, ImageType.Thumb, "thumb");
- if (imageInfo == null)
+ if (imageInfo is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs
index ef878e670..20898d213 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs
@@ -72,7 +72,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
// TODO use image languages if All Languages isn't toggled, but there's currently no way to get that value in here
var collection = await _tmdbClientManager.GetCollectionAsync(tmdbId, null, null, cancellationToken).ConfigureAwait(false);
- if (collection?.Images == null)
+ if (collection?.Images is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs
index 90f2aa88f..1cce7fc35 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs
@@ -51,7 +51,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
{
var collection = await _tmdbClientManager.GetCollectionAsync(tmdbId, language, TmdbUtils.GetImageLanguagesParam(language), cancellationToken).ConfigureAwait(false);
- if (collection == null)
+ if (collection is null)
{
return Enumerable.Empty<RemoteSearchResult>();
}
@@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
SearchProviderName = Name
};
- if (collection.Images != null)
+ if (collection.Images is not null)
{
result.ImageUrl = _tmdbClientManager.GetPosterUrl(collection.PosterPath);
}
@@ -104,7 +104,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
var cleanedName = TmdbUtils.CleanName(parsedName.Name);
var searchResults = await _tmdbClientManager.SearchCollectionAsync(cleanedName, language, cancellationToken).ConfigureAwait(false);
- if (searchResults != null && searchResults.Count > 0)
+ if (searchResults is not null && searchResults.Count > 0)
{
tmdbId = searchResults[0].Id;
}
@@ -116,7 +116,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
{
var collection = await _tmdbClientManager.GetCollectionAsync(tmdbId, language, TmdbUtils.GetImageLanguagesParam(language), cancellationToken).ConfigureAwait(false);
- if (collection != null)
+ if (collection is not null)
{
var item = new BoxSet
{
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs
index 1646a93d2..01b8bca39 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs
@@ -74,7 +74,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
}
var movieResult = await _tmdbClientManager.FindByExternalIdAsync(movieImdbId, FindExternalSource.Imdb, language, cancellationToken).ConfigureAwait(false);
- if (movieResult?.MovieResults != null && movieResult.MovieResults.Count > 0)
+ if (movieResult?.MovieResults is not null && movieResult.MovieResults.Count > 0)
{
movieTmdbId = movieResult.MovieResults[0].Id;
}
@@ -90,7 +90,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
.GetMovieAsync(movieTmdbId, null, null, cancellationToken)
.ConfigureAwait(false);
- if (movie?.Images == null)
+ if (movie?.Images is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs
index dd2d5d97d..9eced93fa 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs
@@ -72,7 +72,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
Overview = movie.Overview
};
- if (movie.ReleaseDate != null)
+ if (movie.ReleaseDate is not null)
{
var releaseDate = movie.ReleaseDate.Value.ToUniversalTime();
remoteResult.PremiereDate = releaseDate;
@@ -177,7 +177,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
.GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken)
.ConfigureAwait(false);
- if (movieResult == null)
+ if (movieResult is null)
{
return new MetadataResult<Movie>();
}
@@ -199,7 +199,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
movie.SetProviderId(MetadataProvider.Tmdb, tmdbId);
movie.SetProviderId(MetadataProvider.Imdb, movieResult.ImdbId);
- if (movieResult.BelongsToCollection != null)
+ if (movieResult.BelongsToCollection is not null)
{
movie.SetProviderId(MetadataProvider.TmdbCollection, movieResult.BelongsToCollection.Id.ToString(CultureInfo.InvariantCulture));
movie.CollectionName = movieResult.BelongsToCollection.Name;
@@ -207,18 +207,18 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
movie.CommunityRating = Convert.ToSingle(movieResult.VoteAverage);
- if (movieResult.Releases?.Countries != null)
+ if (movieResult.Releases?.Countries is not null)
{
var releases = movieResult.Releases.Countries.Where(i => !string.IsNullOrWhiteSpace(i.Certification)).ToList();
var ourRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, info.MetadataCountryCode, StringComparison.OrdinalIgnoreCase));
var usRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
- if (ourRelease != null)
+ if (ourRelease is not null)
{
movie.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Certification);
}
- else if (usRelease != null)
+ else if (usRelease is not null)
{
movie.OfficialRating = usRelease.Certification;
}
@@ -227,7 +227,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
movie.PremiereDate = movieResult.ReleaseDate;
movie.ProductionYear = movieResult.ReleaseDate?.Year;
- if (movieResult.ProductionCompanies != null)
+ if (movieResult.ProductionCompanies is not null)
{
movie.SetStudios(movieResult.ProductionCompanies.Select(c => c.Name));
}
@@ -239,7 +239,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
movie.AddGenre(genre);
}
- if (movieResult.Keywords?.Keywords != null)
+ if (movieResult.Keywords?.Keywords is not null)
{
for (var i = 0; i < movieResult.Keywords.Keywords.Count; i++)
{
@@ -247,7 +247,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
}
}
- if (movieResult.Credits?.Cast != null)
+ if (movieResult.Credits?.Cast is not null)
{
foreach (var actor in movieResult.Credits.Cast.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
@@ -273,7 +273,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
}
}
- if (movieResult.Credits?.Crew != null)
+ if (movieResult.Credits?.Crew is not null)
{
var keepTypes = new[]
{
@@ -314,7 +314,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
}
}
- if (movieResult.Videos?.Results != null)
+ if (movieResult.Videos?.Results is not null)
{
var trailers = new List<MediaUrl>();
for (var i = 0; i < movieResult.Videos.Results.Count; i++)
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs
index d7f5c99dd..aa46d8f25 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs
@@ -64,7 +64,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
var language = item.GetPreferredMetadataLanguage();
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), language, cancellationToken).ConfigureAwait(false);
- if (personResult?.Images?.Profiles == null)
+ if (personResult?.Images?.Profiles is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs
index d760ad142..b3709baf5 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs
@@ -43,7 +43,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
{
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);
- if (personResult != null)
+ if (personResult is not null)
{
var result = new RemoteSearchResult
{
@@ -52,7 +52,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
Overview = personResult.Biography
};
- if (personResult.Images?.Profiles != null && personResult.Images.Profiles.Count > 0)
+ if (personResult.Images?.Profiles is not null && personResult.Images.Profiles.Count > 0)
{
result.ImageUrl = _tmdbClientManager.GetProfileUrl(personResult.Images.Profiles[0].FilePath);
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs
index 943a3a75b..127d41cc7 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs
@@ -84,7 +84,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.ConfigureAwait(false);
var stills = episodeResult?.Images?.Stills;
- if (stills == null)
+ if (stills is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs
index e20284e6f..35e304a2a 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs
@@ -107,7 +107,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, info.SeriesDisplayOrder, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken)
.ConfigureAwait(false);
- if (episodeResult == null)
+ if (episodeResult is null)
{
return metadataResult;
}
@@ -149,7 +149,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
item.SetProviderId(MetadataProvider.TvRage, externalIds.TvrageId);
}
- if (episodeResult.Videos?.Results != null)
+ if (episodeResult.Videos?.Results is not null)
{
foreach (var video in episodeResult.Videos.Results)
{
@@ -162,7 +162,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var credits = episodeResult.Credits;
- if (credits?.Cast != null)
+ if (credits?.Cast is not null)
{
foreach (var actor in credits.Cast.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
@@ -176,7 +176,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
}
}
- if (credits?.GuestStars != null)
+ if (credits?.GuestStars is not null)
{
foreach (var guest in credits.GuestStars.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
@@ -191,7 +191,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
}
// and the rest from crew
- if (credits?.Crew != null)
+ if (credits?.Crew is not null)
{
foreach (var person in credits.Crew)
{
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs
index da32ea408..fda00537d 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs
@@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var seriesTmdbId = Convert.ToInt32(series?.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
- if (seriesTmdbId <= 0 || season?.IndexNumber == null)
+ if (seriesTmdbId <= 0 || season?.IndexNumber is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
@@ -75,7 +75,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.ConfigureAwait(false);
var posters = seasonResult?.Images?.Posters;
- if (posters == null)
+ if (posters is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs
index 2cf0f399e..3cb72b89b 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs
@@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.GetSeasonAsync(Convert.ToInt32(seriesTmdbId, CultureInfo.InvariantCulture), seasonNumber.Value, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken)
.ConfigureAwait(false);
- if (seasonResult == null)
+ if (seasonResult is null)
{
return result;
}
@@ -79,7 +79,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
// TODO why was this disabled?
var credits = seasonResult.Credits;
- if (credits?.Cast != null)
+ if (credits?.Cast is not null)
{
var cast = credits.Cast.OrderBy(c => c.Order).Take(Plugin.Instance.Configuration.MaxCastMembers).ToList();
for (var i = 0; i < cast.Count; i++)
@@ -94,7 +94,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
}
}
- if (credits?.Crew != null)
+ if (credits?.Crew is not null)
{
foreach (var person in credits.Crew)
{
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs
index e96b680b4..9062f1b85 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs
@@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.GetSeriesAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), null, null, cancellationToken)
.ConfigureAwait(false);
- if (series?.Images == null)
+ if (series?.Images is null)
{
return Enumerable.Empty<RemoteImageInfo>();
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs
index 4e8fdf0ee..959088210 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs
@@ -61,7 +61,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.GetSeriesAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), searchInfo.MetadataLanguage, searchInfo.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
- if (series != null)
+ if (series is not null)
{
var remoteResult = MapTvShowToRemoteSearchResult(series);
@@ -76,7 +76,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.ConfigureAwait(false);
var tvResults = findResult?.TvResults;
- if (tvResults != null)
+ if (tvResults is not null)
{
var imdbIdResults = new RemoteSearchResult[tvResults.Count];
for (var i = 0; i < tvResults.Count; i++)
@@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
.ConfigureAwait(false);
var tvResults = findResult?.TvResults;
- if (tvResults != null)
+ if (tvResults is not null)
{
var tvIdResults = new RemoteSearchResult[tvResults.Count];
for (var i = 0; i < tvResults.Count; i++)
@@ -134,7 +134,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
};
remoteResult.SetProviderId(MetadataProvider.Tmdb, series.Id.ToString(CultureInfo.InvariantCulture));
- if (series.ExternalIds != null)
+ if (series.ExternalIds is not null)
{
if (!string.IsNullOrEmpty(series.ExternalIds.ImdbId))
{
@@ -233,7 +233,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
result.AddPerson(person);
}
- result.HasMetadata = result.Item != null;
+ result.HasMetadata = result.Item is not null;
return result;
}
@@ -252,17 +252,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
series.Overview = seriesResult.Overview;
- if (seriesResult.Networks != null)
+ if (seriesResult.Networks is not null)
{
series.Studios = seriesResult.Networks.Select(i => i.Name).ToArray();
}
- if (seriesResult.Genres != null)
+ if (seriesResult.Genres is not null)
{
series.Genres = seriesResult.Genres.Select(i => i.Name).ToArray();
}
- if (seriesResult.Keywords?.Results != null)
+ if (seriesResult.Keywords?.Results is not null)
{
for (var i = 0; i < seriesResult.Keywords.Results.Count; i++)
{
@@ -288,7 +288,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
series.PremiereDate = seriesResult.FirstAirDate;
var ids = seriesResult.ExternalIds;
- if (ids != null)
+ if (ids is not null)
{
if (!string.IsNullOrWhiteSpace(ids.ImdbId))
{
@@ -312,20 +312,20 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var usRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
var minimumRelease = contentRatings.FirstOrDefault();
- if (ourRelease != null)
+ if (ourRelease is not null)
{
series.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Rating);
}
- else if (usRelease != null)
+ else if (usRelease is not null)
{
series.OfficialRating = usRelease.Rating;
}
- else if (minimumRelease != null)
+ else if (minimumRelease is not null)
{
series.OfficialRating = minimumRelease.Rating;
}
- if (seriesResult.Videos?.Results != null)
+ if (seriesResult.Videos?.Results is not null)
{
foreach (var video in seriesResult.Videos.Results)
{
@@ -341,7 +341,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
private IEnumerable<PersonInfo> GetPersons(TvShow seriesResult)
{
- if (seriesResult.Credits?.Cast != null)
+ if (seriesResult.Credits?.Cast is not null)
{
foreach (var actor in seriesResult.Credits.Cast.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
@@ -363,7 +363,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
}
}
- if (seriesResult.Credits?.Crew != null)
+ if (seriesResult.Credits?.Crew is not null)
{
var keepTypes = new[]
{
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
index 7d7733407..b56c0d748 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
@@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
extraMethods,
cancellationToken).ConfigureAwait(false);
- if (movie != null)
+ if (movie is not null)
{
_memoryCache.Set(key, movie, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
CollectionMethods.Images,
cancellationToken).ConfigureAwait(false);
- if (collection != null)
+ if (collection is not null)
{
_memoryCache.Set(key, collection, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -145,7 +145,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
extraMethods: extraMethods,
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (series != null)
+ if (series is not null)
{
_memoryCache.Set(key, series, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -174,7 +174,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
string.Equals(displayOrder, "tv", StringComparison.Ordinal) ? TvGroupType.TV :
null;
- if (groupType == null)
+ if (groupType is null)
{
return null;
}
@@ -190,7 +190,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
var series = await GetSeriesAsync(tvShowId, language, imageLanguages, cancellationToken).ConfigureAwait(false);
var episodeGroupId = series?.EpisodeGroups.Results.Find(g => g.Type == groupType)?.Id;
- if (episodeGroupId == null)
+ if (episodeGroupId is null)
{
return null;
}
@@ -200,7 +200,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
language: TmdbUtils.NormalizeLanguage(language),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (group != null)
+ if (group is not null)
{
_memoryCache.Set(key, group, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -235,7 +235,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
extraMethods: TvSeasonMethods.Credits | TvSeasonMethods.Images | TvSeasonMethods.ExternalIds | TvSeasonMethods.Videos,
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (season != null)
+ if (season is not null)
{
_memoryCache.Set(key, season, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -265,12 +265,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
await EnsureClientConfigAsync().ConfigureAwait(false);
var group = await GetSeriesGroupAsync(tvShowId, displayOrder, language, imageLanguages, cancellationToken).ConfigureAwait(false);
- if (group != null)
+ if (group is not null)
{
var season = group.Groups.Find(s => s.Order == seasonNumber);
// Episode order starts at 0
var ep = season?.Episodes.Find(e => e.Order == episodeNumber - 1);
- if (ep != null)
+ if (ep is not null)
{
seasonNumber = ep.SeasonNumber;
episodeNumber = ep.EpisodeNumber;
@@ -286,7 +286,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
extraMethods: TvEpisodeMethods.Credits | TvEpisodeMethods.Images | TvEpisodeMethods.ExternalIds | TvEpisodeMethods.Videos,
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (episode != null)
+ if (episode is not null)
{
_memoryCache.Set(key, episode, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -317,7 +317,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
PersonMethods.TvCredits | PersonMethods.MovieCredits | PersonMethods.Images | PersonMethods.ExternalIds,
cancellationToken).ConfigureAwait(false);
- if (person != null)
+ if (person is not null)
{
_memoryCache.Set(key, person, TimeSpan.FromHours(CacheDurationInHours));
}
@@ -353,7 +353,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
TmdbUtils.NormalizeLanguage(language),
cancellationToken).ConfigureAwait(false);
- if (result != null)
+ if (result is not null)
{
_memoryCache.Set(key, result, TimeSpan.FromHours(CacheDurationInHours));
}
diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs
index d0e229b23..1aeffb65f 100644
--- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs
+++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs
@@ -65,11 +65,11 @@ namespace MediaBrowser.Providers.Subtitles
/// <inheritdoc />
public async Task<RemoteSubtitleInfo[]> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
- if (request.Language != null)
+ if (request.Language is not null)
{
var culture = _localization.FindLanguageInfo(request.Language);
- if (culture != null)
+ if (culture is not null)
{
request.TwoLetterISOLanguageName = culture.TwoLetterISOLanguageName;
}
@@ -271,7 +271,7 @@ namespace MediaBrowser.Providers.Subtitles
stream.Position = 0;
}
- if (exs != null)
+ if (exs is not null)
{
throw new AggregateException(exs);
}
diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs
index c09b6d813..a261d7cdb 100644
--- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs
+++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs
@@ -80,7 +80,7 @@ namespace MediaBrowser.Providers.TV
targetItem.Status = sourceItem.Status;
}
- if (replaceData || targetItem.AirDays == null || targetItem.AirDays.Length == 0)
+ if (replaceData || targetItem.AirDays is null || targetItem.AirDays.Length == 0)
{
targetItem.AirDays = sourceItem.AirDays;
}
@@ -201,7 +201,7 @@ namespace MediaBrowser.Providers.TV
var seasonNumber = episode.ParentIndexNumber >= 0 ? episode.ParentIndexNumber : null;
var existingSeason = seasons.FirstOrDefault(i => i.IndexNumber == seasonNumber);
- if (existingSeason == null)
+ if (existingSeason is null)
{
var season = await CreateSeasonAsync(series, seasonNumber, cancellationToken).ConfigureAwait(false);
seasons.Add(season);
diff --git a/MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj b/MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj
index ec062152b..6e82d96d1 100644
--- a/MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj
+++ b/MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj
@@ -15,7 +15,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
index 9e197e737..96c512a46 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
@@ -85,15 +85,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
/// <exception cref="ArgumentException"><c>metadataFile</c> is <c>null</c> or empty.</exception>
public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken)
{
- if (item.Item == null)
+ if (item.Item is null)
{
throw new ArgumentException("Item can't be null.", nameof(item));
}
- if (string.IsNullOrEmpty(metadataFile))
- {
- throw new ArgumentException("The metadata filepath was empty.", nameof(metadataFile));
- }
+ ArgumentException.ThrowIfNullOrEmpty(metadataFile);
_validProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@@ -373,7 +370,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
var val = reader.ReadElementContentAsBoolean();
- if (userData != null)
+ if (userData is not null)
{
userData.Played = val;
}
@@ -384,7 +381,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "playcount":
{
var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val) && userData != null)
+ if (!string.IsNullOrWhiteSpace(val) && userData is not null)
{
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out var count))
{
@@ -398,7 +395,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "lastplayed":
{
var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val) && userData != null)
+ if (!string.IsNullOrWhiteSpace(val) && userData is not null)
{
if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var added))
{
@@ -633,7 +630,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
var val = reader.ReadElementContentAsString();
var hasDisplayOrder = item as IHasDisplayOrder;
- if (hasDisplayOrder != null)
+ if (hasDisplayOrder is not null)
{
if (!string.IsNullOrWhiteSpace(val))
{
@@ -880,7 +877,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
var fileSystemMetadata = _directoryService.GetFile(val);
// non existing file returns null
- if (fileSystemMetadata == null || !fileSystemMetadata.Exists)
+ if (fileSystemMetadata is null || !fileSystemMetadata.Exists)
{
Logger.LogWarning("Artwork file {Path} specified in nfo file for {ItemName} does not exist.", uri, itemResult.Item.Name);
return;
@@ -1018,7 +1015,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
var video = item as Video;
- if (video != null)
+ if (video is not null)
{
if (string.Equals("HSBS", val, StringComparison.OrdinalIgnoreCase))
{
@@ -1198,7 +1195,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
if (float.TryParse(val, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var ratingValue))
{
// if ratingName contains tomato --> assume critic rating
- if (ratingName != null &&
+ if (ratingName is not null &&
ratingName.Contains("tomato", StringComparison.OrdinalIgnoreCase) &&
!ratingName.Contains("audience", StringComparison.OrdinalIgnoreCase))
{
diff --git a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs
index e51055725..ecfed6873 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs
@@ -82,14 +82,14 @@ namespace MediaBrowser.XbmcMetadata.Parsers
var movie = item as Movie;
var tmdbcolid = reader.GetAttribute("tmdbcolid");
- if (!string.IsNullOrWhiteSpace(tmdbcolid) && movie != null)
+ if (!string.IsNullOrWhiteSpace(tmdbcolid) && movie is not null)
{
movie.SetProviderId(MetadataProvider.TmdbCollection, tmdbcolid);
}
var val = reader.ReadInnerXml();
- if (!string.IsNullOrWhiteSpace(val) && movie != null)
+ if (!string.IsNullOrWhiteSpace(val) && movie is not null)
{
// TODO Handle this better later
if (!val.Contains('<', StringComparison.Ordinal))
diff --git a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs
index abd3e78d7..af581fc5d 100644
--- a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs
+++ b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs
@@ -33,7 +33,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
var file = GetXmlFile(info, directoryService);
- if (file == null)
+ if (file is null)
{
return Task.FromResult(result);
}
@@ -64,7 +64,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
{
var file = GetXmlFile(new ItemInfo(item), directoryService);
- if (file == null)
+ if (file is null)
{
return false;
}
diff --git a/MediaBrowser.XbmcMetadata/Providers/BaseVideoNfoProvider.cs b/MediaBrowser.XbmcMetadata/Providers/BaseVideoNfoProvider.cs
index 8574be3f3..9954424a4 100644
--- a/MediaBrowser.XbmcMetadata/Providers/BaseVideoNfoProvider.cs
+++ b/MediaBrowser.XbmcMetadata/Providers/BaseVideoNfoProvider.cs
@@ -55,7 +55,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
result.Images = tmpItem.Images;
result.RemoteImages = tmpItem.RemoteImages;
- if (tmpItem.UserDataList != null)
+ if (tmpItem.UserDataList is not null)
{
result.UserDataList = tmpItem.UserDataList;
}
@@ -66,7 +66,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
{
return MovieNfoSaver.GetMovieSavePaths(info)
.Select(directoryService.GetFile)
- .FirstOrDefault(i => i != null);
+ .FirstOrDefault(i => i is not null);
}
}
}
diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
index 740ca4c49..130d0bfe4 100644
--- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
+++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
@@ -257,7 +257,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
var baseItem = item;
- if (baseItem != null)
+ if (baseItem is not null)
{
AddCommonNodes(baseItem, writer, LibraryManager, UserManager, UserDataManager, ConfigurationManager);
}
@@ -748,7 +748,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
writtenProviderIds.Add(MetadataProvider.TvRage.ToString());
}
- if (item.ProviderIds != null)
+ if (item.ProviderIds is not null)
{
foreach (var providerKey in item.ProviderIds.Keys)
{
@@ -832,7 +832,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
var image = item.GetImageInfo(ImageType.Primary, 0);
- if (image != null)
+ if (image is not null)
{
writer.WriteElementString("poster", GetImagePathToSave(image, libraryManager));
}
@@ -855,7 +855,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
var user = userManager.GetUserById(Guid.Parse(userId));
- if (user == null)
+ if (user is null)
{
return;
}
@@ -947,7 +947,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
var personEntity = libraryManager.GetPerson(person.Name);
var image = personEntity.GetImageInfo(ImageType.Primary, 0);
- if (image != null)
+ if (image is not null)
{
writer.WriteElementString(
"thumb",
diff --git a/README.md b/README.md
index e81ea64c0..1963ba526 100644
--- a/README.md
+++ b/README.md
@@ -80,7 +80,7 @@ These instructions will help you get set up with a local development environment
### Prerequisites
-Before the project can be built, you must first install the [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet) on your system.
+Before the project can be built, you must first install the [.NET 7.0 SDK](https://dotnet.microsoft.com/download/dotnet) on your system.
Instructions to run this project from the command line are included here, but you will also need to install an IDE if you want to debug the server while it is running. Any IDE that supports .NET 6 development will work, but two options are recent versions of [Visual Studio](https://visualstudio.microsoft.com/downloads/) (at least 2022) and [Visual Studio Code](https://code.visualstudio.com/Download).
@@ -137,7 +137,7 @@ A second option is to build the project and then run the resulting executable fi
```bash
dotnet build # Build the project
-cd Jellyfin.Server/bin/Debug/net6.0 # Change into the build output directory
+cd Jellyfin.Server/bin/Debug/net7.0 # Change into the build output directory
```
2. Execute the build output. On Linux, Mac, etc. use `./jellyfin` and on Windows use `jellyfin.exe`.
diff --git a/RSSDP/RSSDP.csproj b/RSSDP/RSSDP.csproj
index 77130983b..df5d982f6 100644
--- a/RSSDP/RSSDP.csproj
+++ b/RSSDP/RSSDP.csproj
@@ -11,7 +11,7 @@
</ItemGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AnalysisMode>AllDisabledByDefault</AnalysisMode>
<Nullable>disable</Nullable>
diff --git a/build.yaml b/build.yaml
index 3f676a5cf..464caf328 100644
--- a/build.yaml
+++ b/build.yaml
@@ -13,5 +13,6 @@ packages:
- centos.amd64
- linux.amd64
- windows.amd64
- - macos
+ - macos.amd64
+ - macos.arm64
- portable
diff --git a/deployment/Dockerfile.macos b/deployment/Dockerfile.macos.amd64
index f63dc2906..62f807687 100644
--- a/deployment/Dockerfile.macos
+++ b/deployment/Dockerfile.macos.amd64
@@ -17,7 +17,7 @@ RUN apt-get update -yqq \
libfreetype6-dev libssl-dev libssl1.1 liblttng-ust0
# Link to docker-build script
-RUN ln -sf ${SOURCE_DIR}/deployment/build.macos /build.sh
+RUN ln -sf ${SOURCE_DIR}/deployment/build.macos.amd64 /build.sh
VOLUME ${SOURCE_DIR}/
diff --git a/deployment/Dockerfile.macos.arm64 b/deployment/Dockerfile.macos.arm64
new file mode 100644
index 000000000..2dfbab9b3
--- /dev/null
+++ b/deployment/Dockerfile.macos.arm64
@@ -0,0 +1,26 @@
+FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim
+# Docker build arguments
+ARG SOURCE_DIR=/jellyfin
+ARG ARTIFACT_DIR=/dist
+# Docker run environment
+ENV SOURCE_DIR=/jellyfin
+ENV ARTIFACT_DIR=/dist
+ENV DEB_BUILD_OPTIONS=noddebs
+ENV ARCH=amd64
+ENV IS_DOCKER=YES
+
+# Prepare Debian build environment
+RUN apt-get update -yqq \
+ && apt-get install -yqq --no-install-recommends \
+ debhelper gnupg devscripts \
+ mmv libcurl4-openssl-dev libfontconfig1-dev \
+ libfreetype6-dev libssl-dev libssl1.1 liblttng-ust0
+
+# Link to docker-build script
+RUN ln -sf ${SOURCE_DIR}/deployment/build.macos.arm64 /build.sh
+
+VOLUME ${SOURCE_DIR}/
+
+VOLUME ${ARTIFACT_DIR}/
+
+ENTRYPOINT ["/build.sh"]
diff --git a/deployment/build.macos b/deployment/build.macos.amd64
index 01c640c8b..eac353877 100755
--- a/deployment/build.macos
+++ b/deployment/build.macos.amd64
@@ -1,6 +1,6 @@
#!/bin/bash
-#= MacOS 10.13+ .tar.gz
+#= macOS 10.13+ amd64 .tar.gz
set -o errexit
set -o xtrace
diff --git a/deployment/build.macos.arm64 b/deployment/build.macos.arm64
new file mode 100755
index 000000000..42da07e2f
--- /dev/null
+++ b/deployment/build.macos.arm64
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#= macOS 11.0+ arm64 .tar.gz
+
+set -o errexit
+set -o xtrace
+
+# Move to source directory
+pushd ${SOURCE_DIR}
+
+# Get version
+if [[ ${IS_UNSTABLE} == 'yes' ]]; then
+ version="${BUILD_ID}"
+else
+ version="$( grep "version:" ./build.yaml | sed -E 's/version: "([0-9\.]+.*)"/\1/' )"
+fi
+
+# Build archives
+dotnet publish Jellyfin.Server --configuration Release --self-contained --runtime osx-arm64 --output dist/jellyfin-server_${version}/ -p:DebugSymbols=false -p:DebugType=none -p:UseAppHost=true
+tar -czf jellyfin-server_${version}_macos-arm64.tar.gz -C dist jellyfin-server_${version}
+rm -rf dist/jellyfin-server_${version}
+
+# Move the artifacts out
+mkdir -p ${ARTIFACT_DIR}/
+mv jellyfin[-_]*.tar.gz ${ARTIFACT_DIR}/
+
+if [[ ${IS_DOCKER} == YES ]]; then
+ chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
+fi
+
+popd
diff --git a/fuzz/Emby.Server.Implementations.Fuzz/Emby.Server.Implementations.Fuzz.csproj b/fuzz/Emby.Server.Implementations.Fuzz/Emby.Server.Implementations.Fuzz.csproj
index e6196e847..6cc814ef4 100644
--- a/fuzz/Emby.Server.Implementations.Fuzz/Emby.Server.Implementations.Fuzz.csproj
+++ b/fuzz/Emby.Server.Implementations.Fuzz/Emby.Server.Implementations.Fuzz.csproj
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
@@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
- <PackageReference Include="Moq" Version="4.18.2" />
+ <PackageReference Include="Moq" Version="4.18.3" />
<PackageReference Include="SharpFuzz" Version="2.0.0" />
</ItemGroup>
diff --git a/fuzz/Jellyfin.Server.Fuzz/Jellyfin.Server.Fuzz.csproj b/fuzz/Jellyfin.Server.Fuzz/Jellyfin.Server.Fuzz.csproj
index 6ffc17ff9..5e7d14b11 100644
--- a/fuzz/Jellyfin.Server.Fuzz/Jellyfin.Server.Fuzz.csproj
+++ b/fuzz/Jellyfin.Server.Fuzz/Jellyfin.Server.Fuzz.csproj
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
diff --git a/jellyfin.ruleset b/jellyfin.ruleset
index 8144db93d..71385cee2 100644
--- a/jellyfin.ruleset
+++ b/jellyfin.ruleset
@@ -23,6 +23,8 @@
<Rule Id="SA1316" Action="Error" />
<!-- error on SA1414: Tuple types in signatures should have element names -->
<Rule Id="SA1414" Action="Error" />
+ <!-- disable warning SA1513: Closing brace should be followed by blank line -->
+ <Rule Id="SA1513" Action="Error" />
<!-- error on SA1518: File is required to end with a single newline character -->
<Rule Id="SA1518" Action="Error" />
<!-- error on SA1629: Documentation text should end with a period -->
diff --git a/src/Jellyfin.Extensions/AlphanumericComparator.cs b/src/Jellyfin.Extensions/AlphanumericComparator.cs
index 98a32d5b2..1b19752bb 100644
--- a/src/Jellyfin.Extensions/AlphanumericComparator.cs
+++ b/src/Jellyfin.Extensions/AlphanumericComparator.cs
@@ -16,15 +16,15 @@ namespace Jellyfin.Extensions
/// <returns>A signed integer that indicates the relative values of <c>x</c> and <c>y</c>.</returns>
public static int CompareValues(string? s1, string? s2)
{
- if (s1 == null && s2 == null)
+ if (s1 is null && s2 is null)
{
return 0;
}
- else if (s1 == null)
+ else if (s1 is null)
{
return -1;
}
- else if (s2 == null)
+ else if (s2 is null)
{
return 1;
}
diff --git a/src/Jellyfin.Extensions/Jellyfin.Extensions.csproj b/src/Jellyfin.Extensions/Jellyfin.Extensions.csproj
index f99cb0406..eaf2bc35c 100644
--- a/src/Jellyfin.Extensions/Jellyfin.Extensions.csproj
+++ b/src/Jellyfin.Extensions/Jellyfin.Extensions.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
diff --git a/src/Jellyfin.MediaEncoding.Hls/Cache/CacheDecorator.cs b/src/Jellyfin.MediaEncoding.Hls/Cache/CacheDecorator.cs
index 09816c960..360a96290 100644
--- a/src/Jellyfin.MediaEncoding.Hls/Cache/CacheDecorator.cs
+++ b/src/Jellyfin.MediaEncoding.Hls/Cache/CacheDecorator.cs
@@ -87,7 +87,7 @@ public class CacheDecorator : IKeyframeExtractor
{
var bytes = File.ReadAllBytes(cachePath);
cachedResult = JsonSerializer.Deserialize<KeyframeData>(bytes, _jsonOptions);
- return cachedResult != null;
+ return cachedResult is not null;
}
cachedResult = null;
diff --git a/src/Jellyfin.MediaEncoding.Hls/Jellyfin.MediaEncoding.Hls.csproj b/src/Jellyfin.MediaEncoding.Hls/Jellyfin.MediaEncoding.Hls.csproj
index 2ff7f9645..32f80812a 100644
--- a/src/Jellyfin.MediaEncoding.Hls/Jellyfin.MediaEncoding.Hls.csproj
+++ b/src/Jellyfin.MediaEncoding.Hls/Jellyfin.MediaEncoding.Hls.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
@@ -23,7 +23,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Jellyfin.MediaEncoding.Keyframes/Jellyfin.MediaEncoding.Keyframes.csproj b/src/Jellyfin.MediaEncoding.Keyframes/Jellyfin.MediaEncoding.Keyframes.csproj
index 8be5cd8dc..b11bdc477 100644
--- a/src/Jellyfin.MediaEncoding.Keyframes/Jellyfin.MediaEncoding.Keyframes.csproj
+++ b/src/Jellyfin.MediaEncoding.Keyframes/Jellyfin.MediaEncoding.Keyframes.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
@@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
+ <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
diff --git a/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj
index a20c9690f..bd412bc76 100644
--- a/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj
+++ b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
@@ -15,8 +15,8 @@
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.9" />
- <PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
diff --git a/tests/Jellyfin.Api.Tests/TestHelpers.cs b/tests/Jellyfin.Api.Tests/TestHelpers.cs
index f9bca4146..5eab3ae6f 100644
--- a/tests/Jellyfin.Api.Tests/TestHelpers.cs
+++ b/tests/Jellyfin.Api.Tests/TestHelpers.cs
@@ -36,7 +36,7 @@ namespace Jellyfin.Api.Tests
user.SetPermission(PermissionKind.IsAdministrator, role.Equals(UserRoles.Administrator, StringComparison.OrdinalIgnoreCase));
// Add access schedules if set.
- if (accessSchedules != null)
+ if (accessSchedules is not null)
{
foreach (var accessSchedule in accessSchedules)
{
diff --git a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
index 95fc1d917..3ca761b3d 100644
--- a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
+++ b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs b/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs
index 985bbcde1..f3ada59db 100644
--- a/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs
+++ b/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs
@@ -1,18 +1,17 @@
using MediaBrowser.Controller.Entities;
using Xunit;
-namespace Jellyfin.Controller.Tests.Entities
+namespace Jellyfin.Controller.Tests.Entities;
+
+public class BaseItemTests
{
- public class BaseItemTests
- {
- [Theory]
- [InlineData("", "")]
- [InlineData("1", "0000000001")]
- [InlineData("t", "t")]
- [InlineData("test", "test")]
- [InlineData("test1", "test0000000001")]
- [InlineData("1test 2", "0000000001test 0000000002")]
- public void BaseItem_ModifySortChunks_Valid(string input, string expected)
- => Assert.Equal(expected, BaseItem.ModifySortChunks(input));
- }
+ [Theory]
+ [InlineData("", "")]
+ [InlineData("1", "0000000001")]
+ [InlineData("t", "t")]
+ [InlineData("test", "test")]
+ [InlineData("test1", "test0000000001")]
+ [InlineData("1test 2", "0000000001test 0000000002")]
+ public void BaseItem_ModifySortChunks_Valid(string input, string expected)
+ => Assert.Equal(expected, BaseItem.ModifySortChunks(input));
}
diff --git a/tests/Jellyfin.Controller.Tests/Jellyfin.Controller.Tests.csproj b/tests/Jellyfin.Controller.Tests/Jellyfin.Controller.Tests.csproj
index d95747206..650973c6a 100644
--- a/tests/Jellyfin.Controller.Tests/Jellyfin.Controller.Tests.csproj
+++ b/tests/Jellyfin.Controller.Tests/Jellyfin.Controller.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj b/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj
index 1444d6faf..cba946800 100644
--- a/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj
+++ b/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Extensions.Tests/Jellyfin.Extensions.Tests.csproj b/tests/Jellyfin.Extensions.Tests/Jellyfin.Extensions.Tests.csproj
index 9e3bef881..075bcaac8 100644
--- a/tests/Jellyfin.Extensions.Tests/Jellyfin.Extensions.Tests.csproj
+++ b/tests/Jellyfin.Extensions.Tests/Jellyfin.Extensions.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj b/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj
index 83ea1907c..f7163edc7 100644
--- a/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj
+++ b/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.MediaEncoding.Keyframes.Tests/Jellyfin.MediaEncoding.Keyframes.Tests.csproj b/tests/Jellyfin.MediaEncoding.Keyframes.Tests/Jellyfin.MediaEncoding.Keyframes.Tests.csproj
index 84a069424..72bfb3fd2 100644
--- a/tests/Jellyfin.MediaEncoding.Keyframes.Tests/Jellyfin.MediaEncoding.Keyframes.Tests.csproj
+++ b/tests/Jellyfin.MediaEncoding.Keyframes.Tests/Jellyfin.MediaEncoding.Keyframes.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
<RootNamespace>Jellyfin.MediaEncoding.Keyframes</RootNamespace>
diff --git a/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj b/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj
index 4cff2143c..e68e7f39a 100644
--- a/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj
+++ b/tests/Jellyfin.MediaEncoding.Tests/Jellyfin.MediaEncoding.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs b/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs
index e1bd2fe0f..5e11a7232 100644
--- a/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs
+++ b/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs
@@ -323,7 +323,7 @@ namespace Jellyfin.Model.Tests
var val = builder.BuildVideoItem(options);
Assert.NotNull(val);
- if (playMethod != null)
+ if (playMethod is not null)
{
Assert.Equal(playMethod, val.PlayMethod);
}
@@ -472,7 +472,7 @@ namespace Jellyfin.Model.Tests
}
}
}
- else if (playMethod == null)
+ else if (playMethod is null)
{
Assert.Null(val.SubProtocol);
Assert.Equal("stream", uri.Filename);
@@ -490,7 +490,7 @@ namespace Jellyfin.Model.Tests
using (var stream = File.OpenRead(path))
{
var value = await JsonSerializer.DeserializeAsync<T>(stream, JsonDefaults.Options);
- if (value != null)
+ if (value is not null)
{
return value;
}
diff --git a/tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj b/tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj
index fbcaa66f4..2c7e393af 100644
--- a/tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj
+++ b/tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
index da0e9f5b1..0d9acf0e1 100644
--- a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
+++ b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs b/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs
index b7b5b54ec..55af33836 100644
--- a/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs
@@ -27,7 +27,7 @@ namespace Jellyfin.Naming.Tests.TV
{
var result = SeasonPathParser.Parse(path, true, true);
- Assert.Equal(result.SeasonNumber != null, result.Success);
+ Assert.Equal(result.SeasonNumber is not null, result.Success);
Assert.Equal(result.SeasonNumber, seasonNumber);
Assert.Equal(isSeasonDirectory, result.IsSeasonFolder);
}
diff --git a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs
index 1762b91b9..511a014a6 100644
--- a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs
@@ -61,7 +61,7 @@ namespace Jellyfin.Naming.Tests.Video
Assert.Equal(is3D, result.Is3D);
- if (format3D == null)
+ if (format3D is null)
{
Assert.Null(result?.Format3D);
}
diff --git a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
index 79f2366b8..287d881a8 100644
--- a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
@@ -25,8 +25,8 @@ namespace Jellyfin.Naming.Tests.Video
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
_namingOptions).ToList();
- Assert.Single(result.Where(v => v.ExtraType == null));
- Assert.Single(result.Where(v => v.ExtraType != null));
+ Assert.Single(result.Where(v => v.ExtraType is null));
+ Assert.Single(result.Where(v => v.ExtraType is not null));
}
[Fact]
@@ -44,8 +44,8 @@ namespace Jellyfin.Naming.Tests.Video
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
_namingOptions).ToList();
- Assert.Single(result.Where(v => v.ExtraType == null));
- Assert.Single(result.Where(v => v.ExtraType != null));
+ Assert.Single(result.Where(v => v.ExtraType is null));
+ Assert.Single(result.Where(v => v.ExtraType is not null));
Assert.Equal(2, result[0].AlternateVersions.Count);
}
diff --git a/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj b/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj
index 8ec0262bd..9e13dd4ad 100644
--- a/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj
+++ b/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj b/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj
index 194229737..2d8e3c8f2 100644
--- a/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj
+++ b/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs b/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs
index 28b2e1d8f..e18faa422 100644
--- a/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs
+++ b/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs
@@ -91,7 +91,7 @@ namespace Jellyfin.Providers.Tests.Manager
// Use type Series to hit DisplayOrder
Assert.False(TestMergeBaseItemData<Series, SeriesInfo>(propName, oldValue, newValue, null, false, out _));
- if (lockField != null)
+ if (lockField is not null)
{
Assert.False(TestMergeBaseItemData<Series, SeriesInfo>(propName, oldValue, newValue, lockField, true, out _));
Assert.False(TestMergeBaseItemData<Series, SeriesInfo>(propName, null, newValue, lockField, false, out _));
@@ -120,7 +120,7 @@ namespace Jellyfin.Providers.Tests.Manager
// Use type Audio to hit AlbumArtists
Assert.False(TestMergeBaseItemData<Audio, SongInfo>(propName, oldValue, newValue, null, false, out _));
- if (lockField != null)
+ if (lockField is not null)
{
Assert.False(TestMergeBaseItemData<Audio, SongInfo>(propName, oldValue, newValue, lockField, true, out _));
Assert.False(TestMergeBaseItemData<Audio, SongInfo>(propName, Array.Empty<string>(), newValue, lockField, false, out _));
@@ -328,11 +328,11 @@ namespace Jellyfin.Providers.Tests.Manager
People = oldValue
};
- var lockedFields = lockField == null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField };
+ var lockedFields = lockField is null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField };
MetadataService<Movie, MovieInfo>.MergeBaseItemData(source, target, lockedFields, replaceData, false);
actualValue = target.People;
- return newValue?.Equals(actualValue) ?? actualValue == null;
+ return newValue?.Equals(actualValue) ?? actualValue is null;
}
/// <summary>
@@ -367,12 +367,12 @@ namespace Jellyfin.Providers.Tests.Manager
};
property.SetValue(target.Item, oldValue);
- var lockedFields = lockField == null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField };
+ var lockedFields = lockField is null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField };
// generic type doesn't actually matter to call the static method, just has to be filled in
MetadataService<TItemType, TIdType>.MergeBaseItemData(source, target, lockedFields, replaceData, false);
actualValue = property.GetValue(target.Item);
- return newValue?.Equals(actualValue) ?? actualValue == null;
+ return newValue?.Equals(actualValue) ?? actualValue is null;
}
}
}
diff --git a/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs b/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs
index 725e295b9..5ca59f0ed 100644
--- a/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs
+++ b/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs
@@ -423,14 +423,14 @@ namespace Jellyfin.Providers.Tests.Manager
where TProviderType : class, IImageProvider
{
Mock<IHasOrder>? hasOrder = null;
- if (order != null)
+ if (order is not null)
{
hasOrder = new Mock<IHasOrder>(MockBehavior.Strict);
hasOrder.Setup(i => i.Order)
.Returns((int)order);
}
- var provider = hasOrder == null
+ var provider = hasOrder is null
? new Mock<TProviderType>(MockBehavior.Strict)
: hasOrder.As<TProviderType>();
provider.Setup(p => p.Name)
@@ -471,14 +471,14 @@ namespace Jellyfin.Providers.Tests.Manager
}
Mock<IHasOrder>? hasOrder = null;
- if (order != null)
+ if (order is not null)
{
- hasOrder = forcedProvider == null ? new Mock<IHasOrder>() : forcedProvider.As<IHasOrder>();
+ hasOrder = forcedProvider is null ? new Mock<IHasOrder>() : forcedProvider.As<IHasOrder>();
hasOrder.Setup(i => i.Order)
.Returns((int)order);
}
- var provider = hasOrder == null
+ var provider = hasOrder is null
? new Mock<TProviderType>(MockBehavior.Strict)
: hasOrder.As<TProviderType>();
provider.Setup(p => p.Name)
@@ -499,7 +499,7 @@ namespace Jellyfin.Providers.Tests.Manager
};
// only create type options if populating it with something
- if (imageFetcherOrder != null || metadataFetcherOrder != null)
+ if (imageFetcherOrder is not null || metadataFetcherOrder is not null)
{
imageFetcherOrder ??= Array.Empty<string>();
metadataFetcherOrder ??= Array.Empty<string>();
@@ -527,7 +527,7 @@ namespace Jellyfin.Providers.Tests.Manager
var serverConfiguration = new ServerConfiguration();
// only create type options if populating it with something
- if (imageFetcherOrder != null || localMetadataReaderOrder != null || metadataFetcherOrder != null)
+ if (imageFetcherOrder is not null || localMetadataReaderOrder is not null || metadataFetcherOrder is not null)
{
imageFetcherOrder ??= Array.Empty<string>();
localMetadataReaderOrder ??= Array.Empty<string>();
diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
index 9b80f0b94..6b2d9021c 100644
--- a/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
+++ b/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
@@ -80,7 +80,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
var actual = await embeddedImageProvider.GetImage(input, type, CancellationToken.None);
Assert.NotNull(actual);
- if (expectedFormat == null)
+ if (expectedFormat is null)
{
Assert.False(actual.HasImage);
}
@@ -131,7 +131,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
var actual = await embeddedImageProvider.GetImage(input, type, CancellationToken.None);
Assert.NotNull(actual);
- if (expectedFormat == null)
+ if (expectedFormat is null)
{
Assert.False(actual.HasImage);
}
diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
index 6b2a05241..7ea6f7d9c 100644
--- a/tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
+++ b/tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
@@ -110,7 +110,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
private static IMediaSourceManager GetMediaSourceManager(Video item, MediaStream? defaultStream, List<MediaStream> mediaStreams)
{
var defaultStreamList = new List<MediaStream>();
- if (defaultStream != null)
+ if (defaultStream is not null)
{
defaultStreamList.Add(defaultStream);
}
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj b/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj
index 918802d77..d91b4f00b 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj
+++ b/tests/Jellyfin.Server.Implementations.Tests/Jellyfin.Server.Implementations.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
<RootNamespace>Jellyfin.Server.Implementations.Tests</RootNamespace>
diff --git a/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs b/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs
index 31f33c682..1bd51b246 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs
@@ -50,7 +50,7 @@ namespace Jellyfin.Server.Implementations.Tests.TypedBaseItem
private static bool IsProjectAssemblyName(string? name)
{
- if (name == null)
+ if (name is null)
{
return false;
}
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs
index 1a720c2f6..3d4c27c95 100644
--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs
+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs
@@ -22,7 +22,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
{
return new ContentResult()
{
- Content = (@params != null && @params.Count > 0)
+ Content = (@params is not null && @params.Count > 0)
? string.Join("&", @params.Select(x => x.Key + "=" + x.Value))
: string.Empty,
ContentType = "text/plain; charset=utf-8",
@@ -42,7 +42,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
{
return new ContentResult()
{
- Content = (@params != null && @params.Count > 0)
+ Content = (@params is not null && @params.Count > 0)
? string.Join("&", @params.Select(x => x.Key + "=" + string.Join(',', x.Value)))
: string.Empty,
ContentType = "text/plain; charset=utf-8",
diff --git a/tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj b/tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj
index 659737392..ecc3ebb86 100644
--- a/tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj
+++ b/tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
@@ -9,8 +9,8 @@
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.9" />
- <PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
diff --git a/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj b/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj
index b2653b28b..0ce2721c7 100644
--- a/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj
+++ b/tests/Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
@@ -10,8 +10,8 @@
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.9" />
- <PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Jellyfin.XbmcMetadata.Tests.csproj b/tests/Jellyfin.XbmcMetadata.Tests/Jellyfin.XbmcMetadata.Tests.csproj
index f03448eed..bde34d639 100644
--- a/tests/Jellyfin.XbmcMetadata.Tests/Jellyfin.XbmcMetadata.Tests.csproj
+++ b/tests/Jellyfin.XbmcMetadata.Tests/Jellyfin.XbmcMetadata.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>