mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-16 20:50:48 +01:00
Merge branch 'master' into network-rewrite
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -49,13 +49,13 @@
|
||||
|
||||
<!-- Code analyzers-->
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
|
||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
||||
<PackageReference Include="SerilogAnalyzer" PrivateAssets="All" />
|
||||
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
|
||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.System;
|
||||
|
||||
namespace MediaBrowser.Common.System
|
||||
{
|
||||
public static class OperatingSystem
|
||||
{
|
||||
// We can't use Interlocked.CompareExchange for enums
|
||||
private static int _id = int.MaxValue;
|
||||
|
||||
public static OperatingSystemId Id
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_id == int.MaxValue)
|
||||
{
|
||||
Interlocked.CompareExchange(ref _id, (int)GetId(), int.MaxValue);
|
||||
}
|
||||
|
||||
return (OperatingSystemId)_id;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Id)
|
||||
{
|
||||
case OperatingSystemId.BSD: return "BSD";
|
||||
case OperatingSystemId.Linux: return "Linux";
|
||||
case OperatingSystemId.Darwin: return "macOS";
|
||||
case OperatingSystemId.Windows: return "Windows";
|
||||
default: throw new PlatformNotSupportedException($"Unknown OS {Id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static OperatingSystemId GetId()
|
||||
{
|
||||
switch (Environment.OSVersion.Platform)
|
||||
{
|
||||
// On .NET Core `MacOSX` got replaced by `Unix`, this case should never be hit.
|
||||
case PlatformID.MacOSX:
|
||||
return OperatingSystemId.Darwin;
|
||||
case PlatformID.Win32NT:
|
||||
return OperatingSystemId.Windows;
|
||||
case PlatformID.Unix:
|
||||
default:
|
||||
{
|
||||
string osDescription = RuntimeInformation.OSDescription;
|
||||
if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return OperatingSystemId.Linux;
|
||||
}
|
||||
else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return OperatingSystemId.Darwin;
|
||||
}
|
||||
else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return OperatingSystemId.BSD;
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException($"Can't resolve OS with description: '{osDescription}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user