Merge pull request #8547 from Bond-009/net7

pull/8686/head
Bond-009 1 year ago committed by GitHub
commit 584c80e323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,7 +7,7 @@ parameters:
default: "ubuntu-latest" default: "ubuntu-latest"
- name: DotNetSdkVersion - name: DotNetSdkVersion
type: string type: string
default: 6.0.x default: 7.0.x
jobs: jobs:
- job: CompatibilityCheck - job: CompatibilityCheck

@ -1,7 +1,7 @@
parameters: parameters:
LinuxImage: 'ubuntu-latest' LinuxImage: 'ubuntu-latest'
RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj' RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj'
DotNetSdkVersion: 6.0.x DotNetSdkVersion: 7.0.x
jobs: jobs:
- job: Build - job: Build
@ -20,35 +20,6 @@ jobs:
submodules: true submodules: true
persistCredentials: 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 - task: UseDotNet@2
displayName: 'Update DotNet' displayName: 'Update DotNet'
inputs: inputs:

@ -205,10 +205,10 @@ jobs:
steps: steps:
- task: UseDotNet@2 - task: UseDotNet@2
displayName: 'Use .NET 6.0 sdk' displayName: 'Use .NET 7.0 sdk'
inputs: inputs:
packageType: 'sdk' packageType: 'sdk'
version: '6.0.x' version: '7.0.x'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: 'Build Stable Nuget packages' displayName: 'Build Stable Nuget packages'

@ -10,7 +10,7 @@ parameters:
default: "tests/**/*Tests.csproj" default: "tests/**/*Tests.csproj"
- name: DotNetSdkVersion - name: DotNetSdkVersion
type: string type: string
default: 6.0.x default: 7.0.x
jobs: jobs:
- job: Test - job: Test
@ -94,5 +94,5 @@ jobs:
displayName: 'Publish OpenAPI Artifact' displayName: 'Publish OpenAPI Artifact'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
inputs: 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' artifactName: 'OpenAPI Spec'

@ -21,10 +21,10 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
- name: Setup .NET Core - name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3 uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
with: with:
dotnet-version: '6.0.x' dotnet-version: '7.0.x'
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@b2a92eb56d8cb930006a1c6ed86b0782dd8a4297 # v2 uses: github/codeql-action/init@b2a92eb56d8cb930006a1c6ed86b0782dd8a4297 # v2

@ -18,10 +18,10 @@ jobs:
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }} repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Setup .NET Core - name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3 uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
with: with:
dotnet-version: '6.0.x' dotnet-version: '7.0.x'
- name: Generate openapi.json - 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" 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 - name: Upload openapi.json
@ -30,7 +30,7 @@ jobs:
name: openapi-head name: openapi-head
retention-days: 14 retention-days: 14
if-no-files-found: error 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: openapi-base:
name: OpenAPI - BASE name: OpenAPI - BASE
@ -42,10 +42,10 @@ jobs:
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
with: with:
ref: ${{ github.base_ref }} ref: ${{ github.base_ref }}
- name: Setup .NET Core - name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3 uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
with: with:
dotnet-version: '6.0.x' dotnet-version: '7.0.x'
- name: Generate openapi.json - 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" 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 - name: Upload openapi.json
@ -54,7 +54,7 @@ jobs:
name: openapi-base name: openapi-base
retention-days: 14 retention-days: 14
if-no-files-found: error 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: openapi-diff:
permissions: permissions:

1
.gitignore vendored

@ -273,7 +273,6 @@ BenchmarkDotNet.Artifacts
# Ignore web artifacts from native builds # Ignore web artifacts from native builds
web/ web/
web-src.* web-src.*
MediaBrowser.WebDashboard/jellyfin-web
apiclient/generated apiclient/generated
# Omnisharp crash logs # Omnisharp crash logs

@ -2,11 +2,11 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": ".NET Core Launch (console)", "name": ".NET Launch (console)",
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net6.0/jellyfin.dll", "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net7.0/jellyfin.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/Jellyfin.Server", "cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole", "console": "internalConsole",
@ -18,11 +18,11 @@
} }
}, },
{ {
"name": ".NET Core Launch (nowebclient)", "name": ".NET Launch (nowebclient)",
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net6.0/jellyfin.dll", "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net7.0/jellyfin.dll",
"args": ["--nowebclient"], "args": ["--nowebclient"],
"cwd": "${workspaceFolder}/Jellyfin.Server", "cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole", "console": "internalConsole",
@ -30,7 +30,7 @@
"internalConsoleOptions": "openOnSessionStart" "internalConsoleOptions": "openOnSessionStart"
}, },
{ {
"name": ".NET Core Attach", "name": ".NET Attach",
"type": "coreclr", "type": "coreclr",
"request": "attach", "request": "attach",
"processId": "${command:pickProcess}" "processId": "${command:pickProcess}"

@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AnalysisMode>AllDisabledByDefault</AnalysisMode> <AnalysisMode>AllDisabledByDefault</AnalysisMode>

@ -199,6 +199,11 @@ namespace Emby.Dlna
if (headers.TryGetValue(header.Name, out StringValues value)) if (headers.TryGetValue(header.Name, out StringValues value))
{ {
if (StringValues.IsNullOrEmpty(value))
{
return false;
}
switch (header.Match) switch (header.Match)
{ {
case HeaderMatchType.Equals: case HeaderMatchType.Equals:
@ -208,7 +213,8 @@ namespace Emby.Dlna
// _logger.LogDebug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch); // _logger.LogDebug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch);
return isMatch; return isMatch;
case HeaderMatchType.Regex: 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: default:
throw new ArgumentException("Unrecognized HeaderMatchType"); throw new ArgumentException("Unrecognized HeaderMatchType");
} }
@ -265,10 +271,7 @@ namespace Emby.Dlna
/// <inheritdoc /> /// <inheritdoc />
public DeviceProfile? GetProfile(string id) public DeviceProfile? GetProfile(string id)
{ {
if (string.IsNullOrEmpty(id)) ArgumentException.ThrowIfNullOrEmpty(id);
{
throw new ArgumentNullException(nameof(id));
}
var info = GetProfileInfosInternal().FirstOrDefault(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase)); var info = GetProfileInfosInternal().FirstOrDefault(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase));
@ -371,10 +374,7 @@ namespace Emby.Dlna
{ {
profile = ReserializeProfile(profile); profile = ReserializeProfile(profile);
if (string.IsNullOrEmpty(profile.Name)) ArgumentException.ThrowIfNullOrEmpty(profile.Name);
{
throw new ArgumentException("Profile is missing Name");
}
var newFilename = _fileSystem.GetValidFilename(profile.Name) + ".xml"; var newFilename = _fileSystem.GetValidFilename(profile.Name) + ".xml";
var path = Path.Combine(UserProfilesPath, newFilename); var path = Path.Combine(UserProfilesPath, newFilename);
@ -387,15 +387,9 @@ namespace Emby.Dlna
{ {
profile = ReserializeProfile(profile); profile = ReserializeProfile(profile);
if (string.IsNullOrEmpty(profile.Id)) ArgumentException.ThrowIfNullOrEmpty(profile.Id);
{
throw new ArgumentException("Profile is missing Id");
}
if (string.IsNullOrEmpty(profile.Name)) ArgumentException.ThrowIfNullOrEmpty(profile.Name);
{
throw new ArgumentException("Profile is missing Name");
}
var current = GetProfileInfosInternal().First(i => string.Equals(i.Info.Id, profileId, StringComparison.OrdinalIgnoreCase)); var current = GetProfileInfosInternal().First(i => string.Equals(i.Info.Id, profileId, StringComparison.OrdinalIgnoreCase));
if (current.Info.Type == DeviceProfileType.System) if (current.Info.Type == DeviceProfileType.System)

@ -17,7 +17,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
@ -80,7 +80,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
namespace Emby.Dlna namespace Emby.Dlna

@ -1017,10 +1017,7 @@ namespace Emby.Dlna.PlayTo
} }
var avService = GetServiceRenderingControl(); var avService = GetServiceRenderingControl();
if (avService is null) ArgumentNullException.ThrowIfNull(avService);
{
throw new ArgumentException("Device AvService is null");
}
string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl); string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl);

@ -936,10 +936,7 @@ namespace Emby.Dlna.PlayTo
private static Guid GetItemId(string url) private static Guid GetItemId(string url)
{ {
if (string.IsNullOrEmpty(url)) ArgumentException.ThrowIfNullOrEmpty(url);
{
throw new ArgumentNullException(nameof(url));
}
var parts = url.Split('/'); var parts = url.Split('/');
@ -962,10 +959,7 @@ namespace Emby.Dlna.PlayTo
public static StreamParams ParseFromUrl(string url, ILibraryManager libraryManager, IMediaSourceManager mediaSourceManager) public static StreamParams ParseFromUrl(string url, ILibraryManager libraryManager, IMediaSourceManager mediaSourceManager)
{ {
if (string.IsNullOrEmpty(url)) ArgumentException.ThrowIfNullOrEmpty(url);
{
throw new ArgumentNullException(nameof(url));
}
var request = new StreamParams var request = new StreamParams
{ {

@ -22,15 +22,8 @@ namespace Emby.Dlna.Server
public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId) public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId)
{ {
if (string.IsNullOrEmpty(serverUdn)) ArgumentException.ThrowIfNullOrEmpty(serverUdn);
{ ArgumentException.ThrowIfNullOrEmpty(serverAddress);
throw new ArgumentNullException(nameof(serverUdn));
}
if (string.IsNullOrEmpty(serverAddress))
{
throw new ArgumentNullException(nameof(serverAddress));
}
_profile = profile; _profile = profile;
_serverUdn = serverUdn; _serverUdn = serverUdn;

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System.Net.Http; using System.Net.Http;

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -503,20 +503,9 @@ namespace Emby.Drawing
/// </exception> /// </exception>
public string GetCachePath(string path, string uniqueName, string fileExtension) public string GetCachePath(string path, string uniqueName, string fileExtension)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{ ArgumentException.ThrowIfNullOrEmpty(uniqueName);
throw new ArgumentNullException(nameof(path)); ArgumentException.ThrowIfNullOrEmpty(fileExtension);
}
if (string.IsNullOrEmpty(uniqueName))
{
throw new ArgumentNullException(nameof(uniqueName));
}
if (string.IsNullOrEmpty(fileExtension))
{
throw new ArgumentNullException(nameof(fileExtension));
}
var filename = uniqueName.GetMD5() + fileExtension; var filename = uniqueName.GetMD5() + fileExtension;

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -19,7 +19,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -601,10 +601,7 @@ namespace Emby.Server.Implementations.Channels
private Guid GetInternalChannelId(string name) private Guid GetInternalChannelId(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel)); return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel));
} }

@ -11,7 +11,7 @@ namespace Emby.Server.Implementations
/// <summary> /// <summary>
/// Gets a new copy of the default configuration options. /// Gets a new copy of the default configuration options.
/// </summary> /// </summary>
public static Dictionary<string, string> DefaultConfiguration => new Dictionary<string, string> public static Dictionary<string, string?> DefaultConfiguration => new Dictionary<string, string?>
{ {
{ HostWebClientKey, bool.TrueString }, { HostWebClientKey, bool.TrueString },
{ DefaultRedirectKey, "web/index.html" }, { DefaultRedirectKey, "web/index.html" },

@ -2,8 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Cryptography;
using static MediaBrowser.Model.Cryptography.Constants; using static MediaBrowser.Model.Cryptography.Constants;
@ -14,25 +12,6 @@ namespace Emby.Server.Implementations.Cryptography
/// </summary> /// </summary>
public class CryptographyProvider : ICryptoProvider 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 /> /// <inheritdoc />
public string DefaultHashMethod => "PBKDF2-SHA512"; public string DefaultHashMethod => "PBKDF2-SHA512";
@ -80,22 +59,7 @@ namespace Emby.Server.Implementations.Cryptography
DefaultOutputLength)); DefaultOutputLength));
} }
if (!_supportedHashMethods.Contains(hash.Id)) throw new NotSupportedException($"Can't verify hash with id: {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));
} }
/// <inheritdoc /> /// <inheritdoc />

@ -140,10 +140,7 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException(nameof(userId)); throw new ArgumentNullException(nameof(userId));
} }
if (string.IsNullOrEmpty(key)) ArgumentException.ThrowIfNullOrEmpty(key);
{
throw new ArgumentNullException(nameof(key));
}
PersistUserData(userId, key, userData, cancellationToken); PersistUserData(userId, key, userData, cancellationToken);
} }
@ -274,10 +271,7 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException(nameof(userId)); throw new ArgumentNullException(nameof(userId));
} }
if (string.IsNullOrEmpty(key)) ArgumentException.ThrowIfNullOrEmpty(key);
{
throw new ArgumentNullException(nameof(key));
}
using (var connection = GetConnection(true)) using (var connection = GetConnection(true))
{ {

@ -23,10 +23,7 @@ namespace Emby.Server.Implementations.Data
/// <exception cref="ArgumentNullException"><c>typeName</c> is null.</exception> /// <exception cref="ArgumentNullException"><c>typeName</c> is null.</exception>
public Type? GetType(string typeName) public Type? GetType(string typeName)
{ {
if (string.IsNullOrEmpty(typeName)) ArgumentException.ThrowIfNullOrEmpty(typeName);
{
throw new ArgumentNullException(nameof(typeName));
}
return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies() return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(k)) .Select(a => a.GetType(k))

@ -25,11 +25,11 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DiscUtils.Udf" Version="0.16.13" /> <PackageReference Include="DiscUtils.Udf" Version="0.16.13" />
<PackageReference Include="Jellyfin.XmlTv" Version="10.8.0" /> <PackageReference Include="Jellyfin.XmlTv" Version="10.8.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.11" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
<PackageReference Include="Mono.Nat" Version="3.0.4" /> <PackageReference Include="Mono.Nat" Version="3.0.4" />
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.0" /> <PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.0" />
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="3.1.0" /> <PackageReference Include="SQLitePCL.pretty.netstandard" Version="3.1.0" />
@ -41,7 +41,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 --> <!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->

@ -40,10 +40,7 @@ namespace Emby.Server.Implementations.IO
private void AddAffectedPath(string path) private void AddAffectedPath(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
if (!_affectedPaths.Contains(path, StringComparer.Ordinal)) if (!_affectedPaths.Contains(path, StringComparer.Ordinal))
{ {
@ -53,10 +50,7 @@ namespace Emby.Server.Implementations.IO
public void AddPath(string path) public void AddPath(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
lock (_timerLock) lock (_timerLock)
{ {

@ -71,20 +71,14 @@ namespace Emby.Server.Implementations.IO
public void ReportFileSystemChangeBeginning(string path) public void ReportFileSystemChangeBeginning(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
TemporarilyIgnore(path); TemporarilyIgnore(path);
} }
public async void ReportFileSystemChangeComplete(string path, bool refreshPath) public async void ReportFileSystemChangeComplete(string path, bool refreshPath)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(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. // 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 // Seeing long delays in some situations, especially over the network, sometimes up to 45 seconds
@ -197,10 +191,7 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c>.</exception>
private static bool ContainsParentFolder(IEnumerable<string> lst, string path) private static bool ContainsParentFolder(IEnumerable<string> lst, string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
path = path.TrimEnd(Path.DirectorySeparatorChar); path = path.TrimEnd(Path.DirectorySeparatorChar);
@ -356,10 +347,7 @@ namespace Emby.Server.Implementations.IO
public void ReportFileSystemChanged(string path) public void ReportFileSystemChanged(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
var monitorPath = !IgnorePatterns.ShouldIgnore(path); var monitorPath = !IgnorePatterns.ShouldIgnore(path);

@ -48,10 +48,7 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException"><paramref name="filename"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="filename"/> is <c>null</c>.</exception>
public virtual bool IsShortcut(string filename) public virtual bool IsShortcut(string filename)
{ {
if (string.IsNullOrEmpty(filename)) ArgumentException.ThrowIfNullOrEmpty(filename);
{
throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename); var extension = Path.GetExtension(filename);
return _shortcutHandlers.Any(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase)); 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> /// <exception cref="ArgumentNullException"><paramref name="filename"/> is <c>null</c>.</exception>
public virtual string? ResolveShortcut(string filename) public virtual string? ResolveShortcut(string filename)
{ {
if (string.IsNullOrEmpty(filename)) ArgumentException.ThrowIfNullOrEmpty(filename);
{
throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename); var extension = Path.GetExtension(filename);
var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase)); var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
@ -136,15 +130,8 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException">The shortcutPath or target is null.</exception> /// <exception cref="ArgumentNullException">The shortcutPath or target is null.</exception>
public virtual void CreateShortcut(string shortcutPath, string target) public virtual void CreateShortcut(string shortcutPath, string target)
{ {
if (string.IsNullOrEmpty(shortcutPath)) ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
{ ArgumentException.ThrowIfNullOrEmpty(target);
throw new ArgumentNullException(nameof(shortcutPath));
}
if (string.IsNullOrEmpty(target))
{
throw new ArgumentNullException(nameof(target));
}
var extension = Path.GetExtension(shortcutPath); var extension = Path.GetExtension(shortcutPath);
var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase)); var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
@ -488,15 +475,8 @@ namespace Emby.Server.Implementations.IO
/// <param name="file2">The file2.</param> /// <param name="file2">The file2.</param>
public virtual void SwapFiles(string file1, string file2) public virtual void SwapFiles(string file1, string file2)
{ {
if (string.IsNullOrEmpty(file1)) ArgumentException.ThrowIfNullOrEmpty(file1);
{ ArgumentException.ThrowIfNullOrEmpty(file2);
throw new ArgumentNullException(nameof(file1));
}
if (string.IsNullOrEmpty(file2))
{
throw new ArgumentNullException(nameof(file2));
}
var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture)); var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
@ -514,15 +494,8 @@ namespace Emby.Server.Implementations.IO
/// <inheritdoc /> /// <inheritdoc />
public virtual bool ContainsSubPath(string parentPath, string path) public virtual bool ContainsSubPath(string parentPath, string path)
{ {
if (string.IsNullOrEmpty(parentPath)) ArgumentException.ThrowIfNullOrEmpty(parentPath);
{ ArgumentException.ThrowIfNullOrEmpty(path);
throw new ArgumentNullException(nameof(parentPath));
}
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(nameof(path));
}
return path.Contains( return path.Contains(
Path.TrimEndingDirectorySeparator(parentPath) + Path.DirectorySeparatorChar, Path.TrimEndingDirectorySeparator(parentPath) + Path.DirectorySeparatorChar,
@ -532,10 +505,7 @@ namespace Emby.Server.Implementations.IO
/// <inheritdoc /> /// <inheritdoc />
public virtual string NormalizePath(string path) public virtual string NormalizePath(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase)) if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
{ {

@ -19,10 +19,7 @@ namespace Emby.Server.Implementations.IO
public string? Resolve(string shortcutPath) public string? Resolve(string shortcutPath)
{ {
if (string.IsNullOrEmpty(shortcutPath)) ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
{
throw new ArgumentException("Shortcut path is empty or null.", nameof(shortcutPath));
}
if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase)) 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) public void Create(string shortcutPath, string targetPath)
{ {
if (string.IsNullOrEmpty(shortcutPath)) ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
{ ArgumentException.ThrowIfNullOrEmpty(targetPath);
throw new ArgumentNullException(nameof(shortcutPath));
}
if (string.IsNullOrEmpty(targetPath))
{
throw new ArgumentNullException(nameof(targetPath));
}
File.WriteAllText(shortcutPath, targetPath); File.WriteAllText(shortcutPath, targetPath);
} }

@ -495,11 +495,7 @@ namespace Emby.Server.Implementations.Library
private Guid GetNewItemIdInternal(string key, Type type, bool forceCaseInsensitive) private Guid GetNewItemIdInternal(string key, Type type, bool forceCaseInsensitive)
{ {
if (string.IsNullOrEmpty(key)) ArgumentException.ThrowIfNullOrEmpty(key);
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullException.ThrowIfNull(type); ArgumentNullException.ThrowIfNull(type);
string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath; string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath;
@ -818,10 +814,7 @@ namespace Emby.Server.Implementations.Library
{ {
// If this returns multiple items it could be tricky figuring out which one is correct. // 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 // In most cases, the newest one will be and the others obsolete but not yet cleaned up
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
var query = new InternalItemsQuery var query = new InternalItemsQuery
{ {
@ -2340,10 +2333,7 @@ namespace Emby.Server.Implementations.Library
string sortName, string sortName,
string uniqueId) string uniqueId)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
var parentIdString = parentId.Equals(default) var parentIdString = parentId.Equals(default)
? null ? null
@ -3125,10 +3115,7 @@ namespace Emby.Server.Implementations.Library
public void RemoveMediaPath(string virtualFolderName, string mediaPath) public void RemoveMediaPath(string virtualFolderName, string mediaPath)
{ {
if (string.IsNullOrEmpty(mediaPath)) ArgumentException.ThrowIfNullOrEmpty(mediaPath);
{
throw new ArgumentNullException(nameof(mediaPath));
}
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath; var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName); var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);

@ -762,10 +762,7 @@ namespace Emby.Server.Implementations.Library
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStreamWithDirectStreamProvider(string id, CancellationToken cancellationToken) public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStreamWithDirectStreamProvider(string id, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(id)) ArgumentException.ThrowIfNullOrEmpty(id);
{
throw new ArgumentNullException(nameof(id));
}
// TODO probably shouldn't throw here but it is kept for "backwards compatibility" // TODO probably shouldn't throw here but it is kept for "backwards compatibility"
var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException(); var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
@ -774,10 +771,7 @@ namespace Emby.Server.Implementations.Library
public ILiveStream GetLiveStreamInfo(string id) public ILiveStream GetLiveStreamInfo(string id)
{ {
if (string.IsNullOrEmpty(id)) ArgumentException.ThrowIfNullOrEmpty(id);
{
throw new ArgumentNullException(nameof(id));
}
if (_openStreams.TryGetValue(id, out ILiveStream info)) if (_openStreams.TryGetValue(id, out ILiveStream info))
{ {
@ -801,10 +795,7 @@ namespace Emby.Server.Implementations.Library
public async Task CloseLiveStream(string id) public async Task CloseLiveStream(string id)
{ {
if (string.IsNullOrEmpty(id)) ArgumentException.ThrowIfNullOrEmpty(id);
{
throw new ArgumentNullException(nameof(id));
}
await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false); await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false);
@ -835,10 +826,7 @@ namespace Emby.Server.Implementations.Library
private (IMediaSourceProvider MediaSourceProvider, string KeyId) GetProvider(string key) private (IMediaSourceProvider MediaSourceProvider, string KeyId) GetProvider(string key)
{ {
if (string.IsNullOrEmpty(key)) ArgumentException.ThrowIfNullOrEmpty(key);
{
throw new ArgumentException("Key can't be empty.", nameof(key));
}
var keys = key.Split(LiveStreamIdDelimeter, 2); var keys = key.Split(LiveStreamIdDelimeter, 2);

@ -25,10 +25,7 @@ namespace Emby.Server.Implementations.Library
public static bool SetInitialItemValues(BaseItem item, Folder? parent, ILibraryManager libraryManager, IDirectoryService directoryService) 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 // This version of the below method has no ItemResolveArgs, so we have to require the path already being set
if (string.IsNullOrEmpty(item.Path)) ArgumentException.ThrowIfNullOrEmpty(item.Path);
{
throw new ArgumentException("Item must have a Path");
}
// If the resolver didn't specify this // If the resolver didn't specify this
if (parent is not null) if (parent is not null)

@ -73,10 +73,7 @@ namespace Emby.Server.Implementations.Library
{ {
var searchTerm = query.SearchTerm; var searchTerm = query.SearchTerm;
if (string.IsNullOrEmpty(searchTerm)) ArgumentException.ThrowIfNullOrEmpty(searchTerm);
{
throw new ArgumentException("SearchTerm can't be empty.", nameof(query));
}
searchTerm = searchTerm.Trim().RemoveDiacritics(); searchTerm = searchTerm.Trim().RemoveDiacritics();

@ -16,10 +16,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
/// <inheritdoc /> /// <inheritdoc />
public override void Add(SeriesTimerInfo item) public override void Add(SeriesTimerInfo item)
{ {
if (string.IsNullOrEmpty(item.Id)) ArgumentException.ThrowIfNullOrEmpty(item.Id);
{
throw new ArgumentException("SeriesTimerInfo.Id cannot be null or empty.");
}
base.Add(item); base.Add(item);
} }

@ -74,10 +74,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public override void Add(TimerInfo item) public override void Add(TimerInfo item)
{ {
if (string.IsNullOrEmpty(item.Id)) ArgumentException.ThrowIfNullOrEmpty(item.Id);
{
throw new ArgumentException("TimerInfo.Id cannot be null or empty.");
}
base.Add(item); base.Add(item);
AddOrUpdateSystemTimer(item); AddOrUpdateSystemTimer(item);

@ -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) public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(channelId)) ArgumentException.ThrowIfNullOrEmpty(channelId);
{
throw new ArgumentNullException(nameof(channelId));
}
// Normalize incoming input // Normalize incoming input
channelId = channelId.Replace(".json.schedulesdirect.org", string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart('I'); channelId = channelId.Replace(".json.schedulesdirect.org", string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart('I');
@ -670,15 +667,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{ {
var token = await GetToken(info, cancellationToken).ConfigureAwait(false); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(token)) ArgumentException.ThrowIfNullOrEmpty(token);
{ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
throw new ArgumentException("Authentication required.");
}
if (string.IsNullOrEmpty(info.ListingsId))
{
throw new ArgumentException("Listings Id required");
}
_logger.LogInformation("Adding new LineUp "); _logger.LogInformation("Adding new LineUp ");
@ -689,17 +679,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken) private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(info.ListingsId)) ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
{
throw new ArgumentException("Listings Id required");
}
var token = await GetToken(info, cancellationToken).ConfigureAwait(false); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(token)) ArgumentException.ThrowIfNullOrEmpty(token);
{
throw new ArgumentException("token required");
}
_logger.LogInformation("Headends on account "); _logger.LogInformation("Headends on account ");
@ -732,23 +716,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{ {
if (validateLogin) if (validateLogin)
{ {
if (string.IsNullOrEmpty(info.Username)) ArgumentException.ThrowIfNullOrEmpty(info.Username);
{ ArgumentException.ThrowIfNullOrEmpty(info.Password);
throw new ArgumentException("Username is required");
}
if (string.IsNullOrEmpty(info.Password))
{
throw new ArgumentException("Password is required");
}
} }
if (validateListings) if (validateListings)
{ {
if (string.IsNullOrEmpty(info.ListingsId)) ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
{
throw new ArgumentException("Listings Id required");
}
var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false); 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) public async Task<List<ChannelInfo>> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
{ {
var listingsId = info.ListingsId; var listingsId = info.ListingsId;
if (string.IsNullOrEmpty(listingsId)) ArgumentException.ThrowIfNullOrEmpty(listingsId);
{
throw new ArgumentException("ListingsId required");
}
var token = await GetToken(info, cancellationToken).ConfigureAwait(false); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(token)) ArgumentException.ThrowIfNullOrEmpty(token);
{
throw new ArgumentException("token required");
}
using var options = new HttpRequestMessage(HttpMethod.Get, ApiUrl + "/lineups/" + listingsId); using var options = new HttpRequestMessage(HttpMethod.Get, ApiUrl + "/lineups/" + listingsId);
options.Headers.TryAddWithoutValidation("token", token); options.Headers.TryAddWithoutValidation("token", token);

@ -131,10 +131,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken) public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(channelId)) ArgumentException.ThrowIfNullOrEmpty(channelId);
{
throw new ArgumentNullException(nameof(channelId));
}
if (IsValidChannelId(channelId)) if (IsValidChannelId(channelId))
{ {
@ -166,10 +163,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<ILiveStream> GetChannelStream(string channelId, string streamId, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken) public async Task<ILiveStream> GetChannelStream(string channelId, string streamId, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(channelId)) ArgumentException.ThrowIfNullOrEmpty(channelId);
{
throw new ArgumentNullException(nameof(channelId));
}
if (!IsValidChannelId(channelId)) if (!IsValidChannelId(channelId))
{ {
@ -223,10 +217,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
protected virtual bool IsValidChannelId(string channelId) protected virtual bool IsValidChannelId(string channelId)
{ {
if (string.IsNullOrEmpty(channelId)) ArgumentException.ThrowIfNullOrEmpty(channelId);
{
throw new ArgumentNullException(nameof(channelId));
}
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
} }

@ -219,10 +219,7 @@ namespace Emby.Server.Implementations.Localization
/// <inheritdoc /> /// <inheritdoc />
public int? GetRatingLevel(string rating) public int? GetRatingLevel(string rating)
{ {
if (string.IsNullOrEmpty(rating)) ArgumentException.ThrowIfNullOrEmpty(rating);
{
throw new ArgumentNullException(nameof(rating));
}
if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase)) if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
{ {
@ -295,10 +292,7 @@ namespace Emby.Server.Implementations.Localization
private Dictionary<string, string> GetLocalizationDictionary(string culture) private Dictionary<string, string> GetLocalizationDictionary(string culture)
{ {
if (string.IsNullOrEmpty(culture)) ArgumentException.ThrowIfNullOrEmpty(culture);
{
throw new ArgumentNullException(nameof(culture));
}
const string Prefix = "Core"; 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) private async Task<Dictionary<string, string>> GetDictionary(string prefix, string culture, string baseFilename)
{ {
if (string.IsNullOrEmpty(culture)) ArgumentException.ThrowIfNullOrEmpty(culture);
{
throw new ArgumentNullException(nameof(culture));
}
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

@ -502,15 +502,8 @@ namespace Emby.Server.Implementations.Playlists
private static string MakeRelativePath(string folderPath, string fileAbsolutePath) private static string MakeRelativePath(string folderPath, string fileAbsolutePath)
{ {
if (string.IsNullOrEmpty(folderPath)) ArgumentException.ThrowIfNullOrEmpty(folderPath);
{ ArgumentException.ThrowIfNullOrEmpty(fileAbsolutePath);
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));
}
if (!folderPath.EndsWith(Path.DirectorySeparatorChar)) if (!folderPath.EndsWith(Path.DirectorySeparatorChar))
{ {

@ -210,10 +210,7 @@ namespace Emby.Server.Implementations.Plugins
/// <param name="folder">Folder of the plugin.</param> /// <param name="folder">Folder of the plugin.</param>
public void ImportPluginFrom(string folder) public void ImportPluginFrom(string folder)
{ {
if (string.IsNullOrEmpty(folder)) ArgumentException.ThrowIfNullOrEmpty(folder);
{
throw new ArgumentNullException(nameof(folder));
}
// Load the plugin. // Load the plugin.
var plugin = LoadManifest(folder); var plugin = LoadManifest(folder);

@ -71,25 +71,10 @@ namespace Emby.Server.Implementations.QuickConnect
/// <inheritdoc/> /// <inheritdoc/>
public QuickConnectResult TryConnect(AuthorizationInfo authorizationInfo) public QuickConnectResult TryConnect(AuthorizationInfo authorizationInfo)
{ {
if (string.IsNullOrEmpty(authorizationInfo.DeviceId)) ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.DeviceId);
{ ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.Device);
throw new ArgumentException(nameof(authorizationInfo.DeviceId) + " is required"); ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.Client);
} ArgumentException.ThrowIfNullOrEmpty(authorizationInfo.Version);
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");
}
AssertActive(); AssertActive();
ExpireRequests(); ExpireRequests();

@ -264,20 +264,9 @@ namespace Emby.Server.Implementations.Session
{ {
CheckDisposed(); CheckDisposed();
if (string.IsNullOrEmpty(appName)) ArgumentException.ThrowIfNullOrEmpty(appName);
{ ArgumentException.ThrowIfNullOrEmpty(appVersion);
throw new ArgumentNullException(nameof(appName)); ArgumentException.ThrowIfNullOrEmpty(deviceId);
}
if (string.IsNullOrEmpty(appVersion))
{
throw new ArgumentNullException(nameof(appVersion));
}
if (string.IsNullOrEmpty(deviceId))
{
throw new ArgumentNullException(nameof(deviceId));
}
var activityDate = DateTime.UtcNow; var activityDate = DateTime.UtcNow;
var session = await GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false); var session = await GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false);
@ -478,10 +467,7 @@ namespace Emby.Server.Implementations.Session
{ {
CheckDisposed(); CheckDisposed();
if (string.IsNullOrEmpty(deviceId)) ArgumentException.ThrowIfNullOrEmpty(deviceId);
{
throw new ArgumentNullException(nameof(deviceId));
}
var key = GetSessionKey(appName, deviceId); var key = GetSessionKey(appName, deviceId);
@ -1571,10 +1557,7 @@ namespace Emby.Server.Implementations.Session
{ {
CheckDisposed(); CheckDisposed();
if (string.IsNullOrEmpty(accessToken)) ArgumentException.ThrowIfNullOrEmpty(accessToken);
{
throw new ArgumentNullException(nameof(accessToken));
}
var existing = (await _deviceManager.GetDevices( var existing = (await _deviceManager.GetDevices(
new DeviceQuery new DeviceQuery
@ -1744,10 +1727,7 @@ namespace Emby.Server.Implementations.Session
/// <inheritdoc /> /// <inheritdoc />
public void ReportNowViewingItem(string sessionId, string itemId) public void ReportNowViewingItem(string sessionId, string itemId)
{ {
if (string.IsNullOrEmpty(itemId)) ArgumentException.ThrowIfNullOrEmpty(itemId);
{
throw new ArgumentNullException(nameof(itemId));
}
var item = _libraryManager.GetItemById(new Guid(itemId)); var item = _libraryManager.GetItemById(new Guid(itemId));
var session = GetSession(sessionId); var session = GetSession(sessionId);

@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers
foreach (var key in displayPreferences.CustomPrefs.Keys.Where(key => key.StartsWith("homesection", StringComparison.OrdinalIgnoreCase))) 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)) if (!Enum.TryParse<HomeSectionType>(displayPreferences.CustomPrefs[key], true, out var type))
{ {
type = order < 8 ? defaults[order] : HomeSectionType.None; type = order < 8 ? defaults[order] : HomeSectionType.None;

@ -28,6 +28,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
namespace Jellyfin.Api.Controllers namespace Jellyfin.Api.Controllers
@ -2026,8 +2027,13 @@ namespace Jellyfin.Api.Controllers
} }
var acceptParam = Request.Query[HeaderNames.Accept]; 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) if (!supportsWebP)
{ {
@ -2049,7 +2055,8 @@ namespace Jellyfin.Api.Controllers
formats.Add(ImageFormat.Jpg); formats.Add(ImageFormat.Jpg);
formats.Add(ImageFormat.Png); 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); formats.Add(ImageFormat.Gif);
} }

@ -294,10 +294,7 @@ namespace Jellyfin.Api.Controllers
{ {
var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false); var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
if (command is null) ArgumentNullException.ThrowIfNull(command);
{
throw new ArgumentException("Request body may not be null");
}
command.ControllingUserId = currentSession.UserId; command.ControllingUserId = currentSession.UserId;

@ -46,7 +46,7 @@ namespace Jellyfin.Api.Helpers
while (!reader.EndOfStream) while (!reader.EndOfStream)
{ {
var line = await reader.ReadLineAsync().ConfigureAwait(false); var line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
if (line is null) if (line is null)
{ {
// Nothing currently in buffer. // Nothing currently in buffer.

@ -364,9 +364,9 @@ namespace Jellyfin.Api.Helpers
/// </summary> /// </summary>
/// <param name="queryString">The query string.</param> /// <param name="queryString">The query string.</param>
/// <returns>A <see cref="Dictionary{String,String}"/> containing the stream options.</returns> /// <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) foreach (var param in queryString)
{ {
if (char.IsLower(param.Key[0])) if (char.IsLower(param.Key[0]))

@ -136,10 +136,7 @@ namespace Jellyfin.Api.Helpers
/// <exception cref="ArgumentNullException">Play session id is null.</exception> /// <exception cref="ArgumentNullException">Play session id is null.</exception>
public void PingTranscodingJob(string playSessionId, bool? isUserPaused) public void PingTranscodingJob(string playSessionId, bool? isUserPaused)
{ {
if (string.IsNullOrEmpty(playSessionId)) ArgumentException.ThrowIfNullOrEmpty(playSessionId);
{
throw new ArgumentNullException(nameof(playSessionId));
}
_logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); _logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused);
@ -522,10 +519,7 @@ namespace Jellyfin.Api.Helpers
} }
} }
if (string.IsNullOrEmpty(_mediaEncoder.EncoderPath)) ArgumentException.ThrowIfNullOrEmpty(_mediaEncoder.EncoderPath);
{
throw new ArgumentException("FFmpeg path not set.");
}
// If subtitles get burned in fonts may need to be extracted from the media file // If subtitles get burned in fonts may need to be extracted from the media file
if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode) if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 --> <!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->
<NoWarn>AD0001</NoWarn> <NoWarn>AD0001</NoWarn>
@ -17,8 +17,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="6.4.0" /> <PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="6.4.0" />
</ItemGroup> </ItemGroup>

@ -20,15 +20,8 @@ namespace Jellyfin.Data.Entities
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
public ActivityLog(string name, string type, Guid userId) public ActivityLog(string name, string type, Guid userId)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{ ArgumentException.ThrowIfNullOrEmpty(type);
throw new ArgumentNullException(nameof(name));
}
if (string.IsNullOrEmpty(type))
{
throw new ArgumentNullException(nameof(type));
}
Name = name; Name = name;
Type = type; Type = type;

@ -18,10 +18,7 @@ namespace Jellyfin.Data.Entities
/// <param name="name">The name of the group.</param> /// <param name="name">The name of the group.</param>
public Group(string name) public Group(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
Id = Guid.NewGuid(); Id = Guid.NewGuid();

@ -18,10 +18,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="kind">The kind of art.</param> /// <param name="kind">The kind of art.</param>
public Artwork(string path, ArtKind kind) public Artwork(string path, ArtKind kind)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
Path = path; Path = path;
Kind = kind; Kind = kind;

@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="startTime">The start time for this chapter.</param> /// <param name="startTime">The start time for this chapter.</param>
public Chapter(string language, long startTime) public Chapter(string language, long startTime)
{ {
if (string.IsNullOrEmpty(language)) ArgumentException.ThrowIfNullOrEmpty(language);
{
throw new ArgumentNullException(nameof(language));
}
Language = language; Language = language;
StartTime = startTime; StartTime = startTime;

@ -18,15 +18,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
protected ItemMetadata(string title, string language) protected ItemMetadata(string title, string language)
{ {
if (string.IsNullOrEmpty(title)) ArgumentException.ThrowIfNullOrEmpty(title);
{ ArgumentException.ThrowIfNullOrEmpty(language);
throw new ArgumentNullException(nameof(title));
}
if (string.IsNullOrEmpty(language))
{
throw new ArgumentNullException(nameof(language));
}
Title = title; Title = title;
Language = language; Language = language;

@ -19,10 +19,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="kind">The file kind.</param> /// <param name="kind">The file kind.</param>
public MediaFile(string path, MediaFileKind kind) public MediaFile(string path, MediaFileKind kind)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
Path = path; Path = path;
Kind = kind; Kind = kind;

@ -16,10 +16,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="name">The name of the metadata provider.</param> /// <param name="name">The name of the metadata provider.</param>
public MetadataProvider(string name) public MetadataProvider(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
} }

@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="metadataProvider">The metadata provider.</param> /// <param name="metadataProvider">The metadata provider.</param>
public MetadataProviderId(string providerId, MetadataProvider metadataProvider) public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
{ {
if (string.IsNullOrEmpty(providerId)) ArgumentException.ThrowIfNullOrEmpty(providerId);
{
throw new ArgumentNullException(nameof(providerId));
}
ProviderId = providerId; ProviderId = providerId;
MetadataProvider = metadataProvider; MetadataProvider = metadataProvider;

@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="name">The name of the person.</param> /// <param name="name">The name of the person.</param>
public Person(string name) public Person(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
DateAdded = DateTime.UtcNow; DateAdded = DateTime.UtcNow;

@ -17,10 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <param name="name">The name of this release.</param> /// <param name="name">The name of this release.</param>
public Release(string name) public Release(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;

@ -29,20 +29,9 @@ namespace Jellyfin.Data.Entities
/// <param name="passwordResetProviderId">The Id of the user's password reset provider.</param> /// <param name="passwordResetProviderId">The Id of the user's password reset provider.</param>
public User(string username, string authenticationProviderId, string passwordResetProviderId) public User(string username, string authenticationProviderId, string passwordResetProviderId)
{ {
if (string.IsNullOrEmpty(username)) ArgumentException.ThrowIfNullOrEmpty(username);
{ ArgumentException.ThrowIfNullOrEmpty(authenticationProviderId);
throw new ArgumentNullException(nameof(username)); ArgumentException.ThrowIfNullOrEmpty(passwordResetProviderId);
}
if (string.IsNullOrEmpty(authenticationProviderId))
{
throw new ArgumentNullException(nameof(authenticationProviderId));
}
if (string.IsNullOrEmpty(passwordResetProviderId))
{
throw new ArgumentNullException(nameof(passwordResetProviderId));
}
Username = username; Username = username;
AuthenticationProviderId = authenticationProviderId; AuthenticationProviderId = authenticationProviderId;

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>
@ -39,7 +39,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -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> /// <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) public string GetImageBlurHash(int xComp, int yComp, string path)
{ {
ArgumentNullException.ThrowIfNull(path); ArgumentException.ThrowIfNullOrEmpty(path);
if (path.Length == 0)
{
throw new ArgumentException("String can't be empty", nameof(path));
}
var extension = Path.GetExtension(path.AsSpan()).TrimStart('.'); var extension = Path.GetExtension(path.AsSpan()).TrimStart('.');
if (!SupportedInputFormats.Contains(extension, StringComparison.OrdinalIgnoreCase)) if (!SupportedInputFormats.Contains(extension, StringComparison.OrdinalIgnoreCase))
@ -389,15 +384,8 @@ namespace Jellyfin.Drawing.Skia
/// <inheritdoc/> /// <inheritdoc/>
public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat) public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat)
{ {
if (inputPath.Length == 0) ArgumentException.ThrowIfNullOrEmpty(inputPath);
{ ArgumentException.ThrowIfNullOrEmpty(outputPath);
throw new ArgumentException("String can't be empty.", nameof(inputPath));
}
if (outputPath.Length == 0)
{
throw new ArgumentException("String can't be empty.", nameof(outputPath));
}
var inputFormat = Path.GetExtension(inputPath.AsSpan()).TrimStart('.'); var inputFormat = Path.GetExtension(inputPath.AsSpan()).TrimStart('.');
if (!SupportedInputFormats.Contains(inputFormat, StringComparison.OrdinalIgnoreCase)) if (!SupportedInputFormats.Contains(inputFormat, StringComparison.OrdinalIgnoreCase))

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -222,11 +222,7 @@ namespace Jellyfin.Server.Implementations.Devices
public bool CanAccessDevice(User user, string deviceId) public bool CanAccessDevice(User user, string deviceId)
{ {
ArgumentNullException.ThrowIfNull(user); ArgumentNullException.ThrowIfNull(user);
ArgumentException.ThrowIfNullOrEmpty(deviceId);
if (string.IsNullOrEmpty(deviceId))
{
throw new ArgumentNullException(nameof(deviceId));
}
if (user.HasPermission(PermissionKind.EnableAllDevices) || user.HasPermission(PermissionKind.IsAdministrator)) if (user.HasPermission(PermissionKind.EnableAllDevices) || user.HasPermission(PermissionKind.IsAdministrator))
{ {

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
@ -28,13 +28,13 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="3.8.0" /> <PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="3.8.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> <PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.11" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.11" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.11"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.11"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

@ -8,7 +8,7 @@
<PropertyGroup> <PropertyGroup>
<AssemblyName>jellyfin</AssemblyName> <AssemblyName>jellyfin</AssemblyName>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<ServerGarbageCollection>false</ServerGarbageCollection> <ServerGarbageCollection>false</ServerGarbageCollection>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
@ -35,10 +35,10 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" /> <PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.11" /> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.11" /> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="prometheus-net" Version="7.0.0" /> <PackageReference Include="prometheus-net" Version="7.0.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" /> <PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />

@ -7,6 +7,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -201,7 +202,7 @@ namespace Jellyfin.Server
{ {
await webHost.StartAsync(_tokenSource.Token).ConfigureAwait(false); 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); var socketPath = GetUnixSocketPath(startupConfig, appPaths);
@ -691,27 +692,15 @@ namespace Jellyfin.Server
return socketPath; return socketPath;
} }
[UnsupportedOSPlatform("windows")]
private static void SetUnixSocketPermissions(IConfiguration startupConfig, string socketPath) private static void SetUnixSocketPermissions(IConfiguration startupConfig, string socketPath)
{ {
var socketPerms = startupConfig.GetUnixSocketPermissions(); var socketPerms = startupConfig.GetUnixSocketPermissions();
if (!string.IsNullOrEmpty(socketPerms)) if (!string.IsNullOrEmpty(socketPerms))
{ {
#pragma warning disable SA1300 // Entrypoint is case sensitive. File.SetUnixFileMode(socketPath, (UnixFileMode)Convert.ToInt32(socketPerms, 8));
[DllImport("libc")] _logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms);
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);
}
} }
} }
} }

@ -79,9 +79,9 @@ namespace Jellyfin.Server
/// Gets the command line options as a dictionary that can be used in the .NET configuration system. /// Gets the command line options as a dictionary that can be used in the .NET configuration system.
/// </summary> /// </summary>
/// <returns>The configuration dictionary.</returns> /// <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) if (NoWebClient)
{ {

@ -19,8 +19,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
@ -29,7 +29,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>

@ -1755,10 +1755,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throws if name is null.</exception> /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
public void AddStudio(string name) public void AddStudio(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
var current = Studios; var current = Studios;
@ -1791,10 +1788,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throwns if name is null.</exception> /// <exception cref="ArgumentNullException">Throwns if name is null.</exception>
public void AddGenre(string name) public void AddGenre(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentNullException(nameof(name));
}
var genres = Genres; var genres = Genres;
if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase)) if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))

@ -17,12 +17,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="url">Trailer URL.</param> /// <param name="url">Trailer URL.</param>
public static void AddTrailerUrl(this BaseItem item, string url) public static void AddTrailerUrl(this BaseItem item, string url)
{ {
ArgumentNullException.ThrowIfNull(url); ArgumentException.ThrowIfNullOrEmpty(url);
if (url.Length == 0)
{
throw new ArgumentException("String can't be empty", nameof(url));
}
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase)); var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));

@ -12,11 +12,7 @@ namespace MediaBrowser.Controller.Entities
public static void AddPerson(List<PersonInfo> people, PersonInfo person) public static void AddPerson(List<PersonInfo> people, PersonInfo person)
{ {
ArgumentNullException.ThrowIfNull(person); ArgumentNullException.ThrowIfNull(person);
ArgumentException.ThrowIfNullOrEmpty(person.Name);
if (string.IsNullOrEmpty(person.Name))
{
throw new ArgumentException("The person's name was empty or null.", nameof(person));
}
// Normalize // Normalize
if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase)) if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))

@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary> /// </summary>
/// <param name="configuration">The configuration to read the setting from.</param> /// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The FFmpeg probe size option.</returns> /// <returns>The FFmpeg probe size option.</returns>
public static string GetFFmpegProbeSize(this IConfiguration configuration) public static string? GetFFmpegProbeSize(this IConfiguration configuration)
=> configuration[FfmpegProbeSizeKey]; => configuration[FfmpegProbeSizeKey];
/// <summary> /// <summary>
@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary> /// </summary>
/// <param name="configuration">The configuration to read the setting from.</param> /// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The FFmpeg analyze duration option.</returns> /// <returns>The FFmpeg analyze duration option.</returns>
public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration) public static string? GetFFmpegAnalyzeDuration(this IConfiguration configuration)
=> configuration[FfmpegAnalyzeDurationKey]; => configuration[FfmpegAnalyzeDurationKey];
/// <summary> /// <summary>
@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary> /// </summary>
/// <param name="configuration">The configuration to read the setting from.</param> /// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The unix socket path.</returns> /// <returns>The unix socket path.</returns>
public static string GetUnixSocketPath(this IConfiguration configuration) public static string? GetUnixSocketPath(this IConfiguration configuration)
=> configuration[UnixSocketPathKey]; => configuration[UnixSocketPathKey];
/// <summary> /// <summary>
@ -113,7 +113,7 @@ namespace MediaBrowser.Controller.Extensions
/// </summary> /// </summary>
/// <param name="configuration">The configuration to read the setting from.</param> /// <param name="configuration">The configuration to read the setting from.</param>
/// <returns>The unix socket permissions.</returns> /// <returns>The unix socket permissions.</returns>
public static string GetUnixSocketPermissions(this IConfiguration configuration) public static string? GetUnixSocketPermissions(this IConfiguration configuration)
=> configuration[UnixSocketPermissionsKey]; => configuration[UnixSocketPermissionsKey];
} }
} }

@ -35,10 +35,7 @@ namespace MediaBrowser.Controller.IO
int flattenFolderDepth = 0, int flattenFolderDepth = 0,
bool resolveShortcuts = true) bool resolveShortcuts = true)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(args); ArgumentNullException.ThrowIfNull(args);

@ -171,10 +171,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception>
public void AddAdditionalLocation(string path) public void AddAdditionalLocation(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentException("The path was empty or null.", nameof(path));
}
AdditionalLocations ??= new List<string>(); AdditionalLocations ??= new List<string>();
AdditionalLocations.Add(path); AdditionalLocations.Add(path);
@ -190,10 +187,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
public FileSystemMetadata GetFileSystemEntryByName(string name) public FileSystemMetadata GetFileSystemEntryByName(string name)
{ {
if (string.IsNullOrEmpty(name)) ArgumentException.ThrowIfNullOrEmpty(name);
{
throw new ArgumentException("The name was empty or null.", nameof(name));
}
return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, 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> /// <exception cref="ArgumentNullException">Throws if path is invalid.</exception>
public FileSystemMetadata GetFileSystemEntryByPath(string path) public FileSystemMetadata GetFileSystemEntryByPath(string path)
{ {
if (string.IsNullOrEmpty(path)) ArgumentException.ThrowIfNullOrEmpty(path);
{
throw new ArgumentException("The path was empty or null.", nameof(path));
}
foreach (var file in FileSystemChildren) foreach (var file in FileSystemChildren)
{ {

@ -18,10 +18,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.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="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>
<ItemGroup> <ItemGroup>
@ -35,7 +35,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>

@ -11,7 +11,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -54,11 +54,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken) public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken)
{ {
ArgumentNullException.ThrowIfNull(item); ArgumentNullException.ThrowIfNull(item);
ArgumentException.ThrowIfNullOrEmpty(metadataFile);
if (string.IsNullOrEmpty(metadataFile))
{
throw new ArgumentException("The metadata file was empty or null.", nameof(metadataFile));
}
var settings = new XmlReaderSettings var settings = new XmlReaderSettings
{ {

@ -145,15 +145,8 @@ namespace MediaBrowser.MediaEncoding.Attachments
bool isExternal, bool isExternal,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(inputPath)) ArgumentException.ThrowIfNullOrEmpty(inputPath);
{ ArgumentException.ThrowIfNullOrEmpty(outputPath);
throw new ArgumentNullException(nameof(inputPath));
}
if (string.IsNullOrEmpty(outputPath))
{
throw new ArgumentNullException(nameof(outputPath));
}
Directory.CreateDirectory(outputPath); Directory.CreateDirectory(outputPath);
@ -300,15 +293,9 @@ namespace MediaBrowser.MediaEncoding.Attachments
string outputPath, string outputPath,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(inputPath)) ArgumentException.ThrowIfNullOrEmpty(inputPath);
{
throw new ArgumentNullException(nameof(inputPath));
}
if (string.IsNullOrEmpty(outputPath)) ArgumentException.ThrowIfNullOrEmpty(outputPath);
{
throw new ArgumentNullException(nameof(outputPath));
}
Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); Directory.CreateDirectory(Path.GetDirectoryName(outputPath));

@ -637,10 +637,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private async Task<string> ExtractImageInternal(string inputPath, string container, MediaStream videoStream, int? imageStreamIndex, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, ImageFormat? targetFormat, CancellationToken cancellationToken) 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)) ArgumentException.ThrowIfNullOrEmpty(inputPath);
{
throw new ArgumentNullException(nameof(inputPath));
}
var outputExtension = targetFormat switch var outputExtension = targetFormat switch
{ {

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
@ -28,8 +28,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BDInfo" Version="0.7.6.2" /> <PackageReference Include="BDInfo" Version="0.7.6.2" />
<PackageReference Include="libse" Version="3.6.5" /> <PackageReference Include="libse" Version="3.6.5" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" /> <PackageReference Include="UTF.Unknown" Version="2.5.1" />
</ItemGroup> </ItemGroup>

@ -179,7 +179,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
_logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path); _logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path);
using var reader = new StreamReader(stream, result.Encoding); 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)); 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) private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value)
{ {
ArgumentException.ThrowIfNullOrEmpty(format);
if (string.Equals(format, SubtitleFormat.ASS, StringComparison.OrdinalIgnoreCase)) if (string.Equals(format, SubtitleFormat.ASS, StringComparison.OrdinalIgnoreCase))
{ {
value = new AssWriter(); value = new AssWriter();
return true; return true;
} }
if (string.IsNullOrEmpty(format))
{
throw new ArgumentNullException(nameof(format));
}
if (string.Equals(format, "json", StringComparison.OrdinalIgnoreCase)) if (string.Equals(format, "json", StringComparison.OrdinalIgnoreCase))
{ {
value = new JsonWriter(); value = new JsonWriter();
@ -355,15 +352,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
private async Task ConvertTextSubtitleToSrtInternal(MediaStream subtitleStream, MediaSourceInfo mediaSource, string outputPath, CancellationToken cancellationToken) private async Task ConvertTextSubtitleToSrtInternal(MediaStream subtitleStream, MediaSourceInfo mediaSource, string outputPath, CancellationToken cancellationToken)
{ {
var inputPath = subtitleStream.Path; var inputPath = subtitleStream.Path;
if (string.IsNullOrEmpty(inputPath)) ArgumentException.ThrowIfNullOrEmpty(inputPath);
{
throw new ArgumentNullException(nameof(inputPath));
}
if (string.IsNullOrEmpty(outputPath)) ArgumentException.ThrowIfNullOrEmpty(outputPath);
{
throw new ArgumentNullException(nameof(outputPath));
}
Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(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, string outputPath,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(inputPath)) ArgumentException.ThrowIfNullOrEmpty(inputPath);
{
throw new ArgumentNullException(nameof(inputPath));
}
if (string.IsNullOrEmpty(outputPath)) ArgumentException.ThrowIfNullOrEmpty(outputPath);
{
throw new ArgumentNullException(nameof(outputPath));
}
Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(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; 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); var newText = text.Replace(",Arial,", ",Arial Unicode MS,", StringComparison.Ordinal);

@ -29,12 +29,7 @@ namespace MediaBrowser.Model.Cryptography
public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters) public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters)
{ {
ArgumentNullException.ThrowIfNull(id); ArgumentException.ThrowIfNullOrEmpty(id);
if (id.Length == 0)
{
throw new ArgumentException("String can't be empty", nameof(id));
}
Id = id; Id = id;
_hash = hash; _hash = hash;

@ -9,10 +9,7 @@ namespace MediaBrowser.Model.Dlna
{ {
public SearchCriteria(string search) public SearchCriteria(string search)
{ {
if (search.Length == 0) ArgumentException.ThrowIfNullOrEmpty(search);
{
throw new ArgumentException("String can't be empty.", nameof(search));
}
SearchType = SearchType.Unknown; SearchType = SearchType.Unknown;

@ -1496,10 +1496,7 @@ namespace MediaBrowser.Model.Dlna
throw new ArgumentException("ItemId is required"); throw new ArgumentException("ItemId is required");
} }
if (string.IsNullOrEmpty(options.DeviceId)) ArgumentException.ThrowIfNullOrEmpty(options.DeviceId);
{
throw new ArgumentException("DeviceId is required");
}
if (options.Profile is null) if (options.Profile is null)
{ {

@ -620,10 +620,7 @@ namespace MediaBrowser.Model.Dlna
public string ToUrl(string baseUrl, string accessToken) public string ToUrl(string baseUrl, string accessToken)
{ {
if (string.IsNullOrEmpty(baseUrl)) ArgumentException.ThrowIfNullOrEmpty(baseUrl);
{
throw new ArgumentNullException(nameof(baseUrl));
}
var list = new List<string>(); var list = new List<string>();
foreach (NameValuePair pair in BuildParams(this, accessToken)) foreach (NameValuePair pair in BuildParams(this, accessToken))
@ -664,10 +661,7 @@ namespace MediaBrowser.Model.Dlna
private string GetUrl(string baseUrl, string queryString) private string GetUrl(string baseUrl, string queryString)
{ {
if (string.IsNullOrEmpty(baseUrl)) ArgumentException.ThrowIfNullOrEmpty(baseUrl);
{
throw new ArgumentNullException(nameof(baseUrl));
}
string extension = string.IsNullOrEmpty(Container) ? string.Empty : "." + Container; string extension = string.IsNullOrEmpty(Container) ? string.Empty : "." + Container;

@ -14,7 +14,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>
@ -34,13 +34,13 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> <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"> <PackageReference Include="MimeTypes" Version="2.4.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.Globalization" Version="4.3.0" /> <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>
<ItemGroup> <ItemGroup>

@ -140,10 +140,7 @@ namespace MediaBrowser.Model.Net
[return: NotNullIfNotNull("defaultValue")] [return: NotNullIfNotNull("defaultValue")]
public static string? GetMimeType(string filename, string? defaultValue = null) public static string? GetMimeType(string filename, string? defaultValue = null)
{ {
if (filename.Length == 0) ArgumentException.ThrowIfNullOrEmpty(filename);
{
throw new ArgumentException("String can't be empty.", nameof(filename));
}
var ext = Path.GetExtension(filename); var ext = Path.GetExtension(filename);
@ -168,10 +165,7 @@ namespace MediaBrowser.Model.Net
public static string? ToExtension(string mimeType) public static string? ToExtension(string mimeType)
{ {
if (mimeType.Length == 0) ArgumentException.ThrowIfNullOrEmpty(mimeType);
{
throw new ArgumentException("String can't be empty.", nameof(mimeType));
}
// handle text/html; charset=UTF-8 // handle text/html; charset=UTF-8
mimeType = mimeType.AsSpan().LeftPart(';').ToString(); mimeType = mimeType.AsSpan().LeftPart(';').ToString();

@ -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) public async Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(mimeType)) ArgumentException.ThrowIfNullOrEmpty(mimeType);
{
throw new ArgumentNullException(nameof(mimeType));
}
var saveLocally = item.SupportsLocalMetadata && item.IsSaveLocalMetadataEnabled() && !item.ExtraType.HasValue && item is not Audio; var saveLocally = item.SupportsLocalMetadata && item.IsSaveLocalMetadataEnabled() && !item.ExtraType.HasValue && item is not Audio;

@ -918,15 +918,8 @@ namespace MediaBrowser.Providers.Manager
var source = sourceResult.Item; var source = sourceResult.Item;
var target = targetResult.Item; var target = targetResult.Item;
if (source is null) ArgumentNullException.ThrowIfNull(sourceResult);
{ ArgumentNullException.ThrowIfNull(targetResult);
throw new ArgumentException("Item cannot be null.", nameof(sourceResult));
}
if (target is null)
{
throw new ArgumentException("Item cannot be null.", nameof(targetResult));
}
if (!lockedFields.Contains(MetadataField.Name)) if (!lockedFields.Contains(MetadataField.Name))
{ {

@ -18,9 +18,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="LrcParser" Version="2022.529.1" /> <PackageReference Include="LrcParser" Version="2022.529.1" />
<PackageReference Include="MetaBrainz.MusicBrainz" Version="5.0.0" /> <PackageReference Include="MetaBrainz.MusicBrainz" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="OptimizedPriorityQueue" Version="5.1.0" /> <PackageReference Include="OptimizedPriorityQueue" Version="5.1.0" />
<PackageReference Include="PlaylistsNET" Version="1.2.1" /> <PackageReference Include="PlaylistsNET" Version="1.2.1" />
@ -29,7 +29,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>

@ -365,10 +365,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
internal string GetDataFilePath(string imdbId) internal string GetDataFilePath(string imdbId)
{ {
if (string.IsNullOrEmpty(imdbId)) ArgumentException.ThrowIfNullOrEmpty(imdbId);
{
throw new ArgumentNullException(nameof(imdbId));
}
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb"); var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
@ -379,10 +376,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
internal string GetSeasonFilePath(string imdbId, int seasonId) internal string GetSeasonFilePath(string imdbId, int seasonId)
{ {
if (string.IsNullOrEmpty(imdbId)) ArgumentException.ThrowIfNullOrEmpty(imdbId);
{
throw new ArgumentNullException(nameof(imdbId));
}
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb"); var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");

@ -15,7 +15,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>

@ -90,10 +90,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
throw new ArgumentException("Item can't be null.", nameof(item)); throw new ArgumentException("Item can't be null.", nameof(item));
} }
if (string.IsNullOrEmpty(metadataFile)) ArgumentException.ThrowIfNullOrEmpty(metadataFile);
{
throw new ArgumentException("The metadata filepath was empty.", nameof(metadataFile));
}
_validProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); _validProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

@ -80,7 +80,7 @@ These instructions will help you get set up with a local development environment
### Prerequisites ### 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). 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 ```bash
dotnet build # Build the project 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`. 2. Execute the build output. On Linux, Mac, etc. use `./jellyfin` and on Windows use `jellyfin.exe`.

@ -11,7 +11,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AnalysisMode>AllDisabledByDefault</AnalysisMode> <AnalysisMode>AllDisabledByDefault</AnalysisMode>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save