More warnings (removed)

This commit is contained in:
Bond_009 2019-12-11 00:13:57 +01:00
parent 67922dff50
commit 2ef4ffd698
99 changed files with 397 additions and 294 deletions

View File

@ -23,7 +23,7 @@
<!-- Code analysers--> <!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" PrivateAssets="All" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" /> <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />

View File

@ -22,9 +22,10 @@
<!-- Code analysers--> <!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -180,11 +181,7 @@ namespace Emby.Server.Implementations
/// Gets the plugins. /// Gets the plugins.
/// </summary> /// </summary>
/// <value>The plugins.</value> /// <value>The plugins.</value>
public IPlugin[] Plugins public IReadOnlyList<IPlugin> Plugins => _plugins;
{
get => _plugins;
protected set => _plugins = value;
}
/// <summary> /// <summary>
/// Gets or sets the logger factory. /// Gets or sets the logger factory.
@ -1051,7 +1048,7 @@ namespace Emby.Server.Implementations
} }
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>()); ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
Plugins = GetExports<IPlugin>() _plugins = GetExports<IPlugin>()
.Select(LoadPlugin) .Select(LoadPlugin)
.Where(i => i != null) .Where(i => i != null)
.ToArray(); .ToArray();
@ -1683,9 +1680,9 @@ namespace Emby.Server.Implementations
/// <param name="plugin">The plugin.</param> /// <param name="plugin">The plugin.</param>
public void RemovePlugin(IPlugin plugin) public void RemovePlugin(IPlugin plugin)
{ {
var list = Plugins.ToList(); var list = _plugins.ToList();
list.Remove(plugin); list.Remove(plugin);
Plugins = list.ToArray(); _plugins = list.ToArray();
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System.Collections.Generic; using System.Collections.Generic;
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.Cryptography
/// <summary> /// <summary>
/// Releases unmanaged and - optionally - managed resources. /// Releases unmanaged and - optionally - managed resources.
/// </summary> /// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (_disposed) if (_disposed)

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Threading; using System.Threading;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Globalization; using System.Globalization;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.Diagnostics;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -29,10 +29,10 @@
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" /> <PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.1" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.0.1" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.0" />
<PackageReference Include="Mono.Nat" Version="2.0.0" /> <PackageReference Include="Mono.Nat" Version="2.0.0" />
<PackageReference Include="ServiceStack.Text.Core" Version="5.7.0" /> <PackageReference Include="ServiceStack.Text.Core" Version="5.7.0" />
<PackageReference Include="sharpcompress" Version="0.24.0" /> <PackageReference Include="sharpcompress" Version="0.24.0" />
@ -52,10 +52,10 @@
<!-- Code analysers--> <!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" /> <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -218,7 +219,6 @@ namespace Emby.Server.Implementations.HttpServer
case FileNotFoundException _: case FileNotFoundException _:
case ResourceNotFoundException _: return 404; case ResourceNotFoundException _: return 404;
case MethodNotAllowedException _: return 405; case MethodNotAllowedException _: return 405;
case RemoteServiceUnavailableException _: return 502;
default: return 500; default: return 500;
} }
} }

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Threading; using System.Threading;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
namespace Emby.Server.Implementations.IO namespace Emby.Server.Implementations.IO
{ {

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Buffers; using System.Buffers;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -70,9 +70,9 @@ namespace Emby.Server.Implementations.Library
byte[] calculatedHash = _cryptographyProvider.ComputeHash( byte[] calculatedHash = _cryptographyProvider.ComputeHash(
readyHash.Id, readyHash.Id,
passwordbytes, passwordbytes,
readyHash.Salt); readyHash.Salt.ToArray());
if (calculatedHash.SequenceEqual(readyHash.Hash)) if (readyHash.Hash.SequenceEqual(calculatedHash))
{ {
success = true; success = true;
} }
@ -148,17 +148,18 @@ namespace Emby.Server.Implementations.Library
// TODO: make use of iterations parameter? // TODO: make use of iterations parameter?
PasswordHash passwordHash = PasswordHash.Parse(user.Password); PasswordHash passwordHash = PasswordHash.Parse(user.Password);
var salt = passwordHash.Salt.ToArray();
return new PasswordHash( return new PasswordHash(
passwordHash.Id, passwordHash.Id,
_cryptographyProvider.ComputeHash( _cryptographyProvider.ComputeHash(
passwordHash.Id, passwordHash.Id,
Encoding.UTF8.GetBytes(str), Encoding.UTF8.GetBytes(str),
passwordHash.Salt), salt),
passwordHash.Salt, salt,
passwordHash.Parameters.ToDictionary(x => x.Key, y => y.Value)).ToString(); passwordHash.Parameters.ToDictionary(x => x.Key, y => y.Value)).ToString();
} }
public byte[] GetHashed(User user, string str) public ReadOnlySpan<byte> GetHashed(User user, string str)
{ {
if (string.IsNullOrEmpty(user.Password)) if (string.IsNullOrEmpty(user.Password))
{ {
@ -170,7 +171,7 @@ namespace Emby.Server.Implementations.Library
return _cryptographyProvider.ComputeHash( return _cryptographyProvider.ComputeHash(
passwordHash.Id, passwordHash.Id,
Encoding.UTF8.GetBytes(str), Encoding.UTF8.GetBytes(str),
passwordHash.Salt); passwordHash.Salt.ToArray());
} }
} }
} }

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Globalization; using System.Globalization;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -480,7 +481,7 @@ namespace Emby.Server.Implementations.Library
var hash = _cryptoProvider.ComputeHash( var hash = _cryptoProvider.ComputeHash(
passwordHash.Id, passwordHash.Id,
Encoding.UTF8.GetBytes(password), Encoding.UTF8.GetBytes(password),
passwordHash.Salt); passwordHash.Salt.ToArray());
success = passwordHash.Hash.SequenceEqual(hash); success = passwordHash.Hash.SequenceEqual(hash);
} }

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -19,7 +19,7 @@
<!-- Code analysers--> <!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" PrivateAssets="All" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" /> <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />

View File

@ -24,13 +24,13 @@
<ItemGroup> <ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" /> <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup> </ItemGroup>
<!-- Code analyzers--> <!-- Code analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" /> <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@ -39,8 +39,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" /> <PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" /> <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" /> <PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -15,24 +16,24 @@ namespace MediaBrowser.Common.Cryptography
public class PasswordHash public class PasswordHash
{ {
private readonly Dictionary<string, string> _parameters; private readonly Dictionary<string, string> _parameters;
private readonly byte[] _salt;
private readonly byte[] _hash;
public PasswordHash(string id, byte[] hash) public PasswordHash(string id, byte[] hash)
: this(id, hash, Array.Empty<byte>()) : this(id, hash, Array.Empty<byte>())
{ {
} }
public PasswordHash(string id, byte[] hash, byte[] salt) public PasswordHash(string id, byte[] hash, byte[] salt)
: this(id, hash, salt, new Dictionary<string, string>()) : this(id, hash, salt, new Dictionary<string, string>())
{ {
} }
public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters) public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters)
{ {
Id = id; Id = id;
Hash = hash; _hash = hash;
Salt = salt; _salt = salt;
_parameters = parameters; _parameters = parameters;
} }
@ -45,25 +46,24 @@ namespace MediaBrowser.Common.Cryptography
/// <summary> /// <summary>
/// Gets the additional parameters used by the hash function. /// Gets the additional parameters used by the hash function.
/// </summary> /// </summary>
/// <value></value>
public IReadOnlyDictionary<string, string> Parameters => _parameters; public IReadOnlyDictionary<string, string> Parameters => _parameters;
/// <summary> /// <summary>
/// Gets the salt used for hashing the password. /// Gets the salt used for hashing the password.
/// </summary> /// </summary>
/// <value>Returns the salt used for hashing the password.</value> /// <value>Returns the salt used for hashing the password.</value>
public byte[] Salt { get; } public ReadOnlySpan<byte> Salt => _salt;
/// <summary> /// <summary>
/// Gets the hashed password. /// Gets the hashed password.
/// </summary> /// </summary>
/// <value>Return the hashed password.</value> /// <value>Return the hashed password.</value>
public byte[] Hash { get; } public ReadOnlySpan<byte> Hash => _hash;
public static PasswordHash Parse(string hashString) public static PasswordHash Parse(string hashString)
{ {
string[] splitted = hashString.Split('$');
// The string should at least contain the hash function and the hash itself // The string should at least contain the hash function and the hash itself
string[] splitted = hashString.Split('$');
if (splitted.Length < 3) if (splitted.Length < 3)
{ {
throw new ArgumentException("String doesn't contain enough segments", nameof(hashString)); throw new ArgumentException("String doesn't contain enough segments", nameof(hashString));
@ -77,7 +77,7 @@ namespace MediaBrowser.Common.Cryptography
// Optional parameters // Optional parameters
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, string> parameters = new Dictionary<string, string>();
if (splitted[index].IndexOf('=') != -1) if (splitted[index].IndexOf('=', StringComparison.Ordinal) != -1)
{ {
foreach (string paramset in splitted[index++].Split(',')) foreach (string paramset in splitted[index++].Split(','))
{ {
@ -98,6 +98,7 @@ namespace MediaBrowser.Common.Cryptography
byte[] hash; byte[] hash;
byte[] salt; byte[] salt;
// Check if the string also contains a salt // Check if the string also contains a salt
if (splitted.Length - index == 2) if (splitted.Length - index == 2)
{ {
@ -141,14 +142,14 @@ namespace MediaBrowser.Common.Cryptography
.Append(Id); .Append(Id);
SerializeParameters(str); SerializeParameters(str);
if (Salt.Length != 0) if (_salt.Length != 0)
{ {
str.Append('$') str.Append('$')
.Append(Hex.Encode(Salt, false)); .Append(Hex.Encode(_salt, false));
} }
return str.Append('$') return str.Append('$')
.Append(Hex.Encode(Hash, false)).ToString(); .Append(Hex.Encode(_hash, false)).ToString();
} }
} }
} }

View File

@ -1,15 +1,13 @@
#pragma warning disable CS1591
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace MediaBrowser.Common.Events namespace MediaBrowser.Common.Events
{ {
// TODO: @bond Remove
/// <summary> /// <summary>
/// Class EventHelper /// Class EventHelper.
/// </summary> /// </summary>
// TODO: @bond Remove
public static class EventHelper public static class EventHelper
{ {
/// <summary> /// <summary>
@ -40,7 +38,7 @@ namespace MediaBrowser.Common.Events
/// <summary> /// <summary>
/// Queues the event. /// Queues the event.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">Argument type for the <c>handler</c>.</typeparam>
/// <param name="handler">The handler.</param> /// <param name="handler">The handler.</param>
/// <param name="sender">The sender.</param> /// <param name="sender">The sender.</param>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>

View File

@ -1,12 +1,12 @@
using System; using System;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Security.Cryptography;
namespace MediaBrowser.Common.Extensions namespace MediaBrowser.Common.Extensions
{ {
/// <summary> /// <summary>
/// Class BaseExtensions /// Class BaseExtensions.
/// </summary> /// </summary>
public static class BaseExtensions public static class BaseExtensions
{ {
@ -30,10 +30,13 @@ namespace MediaBrowser.Common.Extensions
/// <returns><see cref="Guid" />.</returns> /// <returns><see cref="Guid" />.</returns>
public static Guid GetMD5(this string str) public static Guid GetMD5(this string str)
{ {
#pragma warning disable CA5351
using (var provider = MD5.Create()) using (var provider = MD5.Create())
{ {
return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str))); return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
} }
#pragma warning restore CA5351
} }
} }
} }

View File

@ -5,7 +5,7 @@ namespace MediaBrowser.Common.Extensions
/// <summary> /// <summary>
/// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />. /// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />.
/// </summary> /// </summary>
public static class CollectionExtensions public static class CopyToExtensions
{ {
/// <summary> /// <summary>
/// Copies all the elements of the current collection to the specified list /// Copies all the elements of the current collection to the specified list
@ -14,7 +14,7 @@ namespace MediaBrowser.Common.Extensions
/// <param name="source">The current collection that is the source of the elements.</param> /// <param name="source">The current collection that is the source of the elements.</param>
/// <param name="destination">The list that is the destination of the elements copied from the current collection.</param> /// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
/// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param> /// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">The type of the array.</typeparam>
public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0) public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0)
{ {
for (int i = 0; i < source.Count; i++) for (int i = 0; i < source.Count; i++)

View File

@ -0,0 +1,26 @@
using System;
namespace MediaBrowser.Common.Extensions
{
/// <summary>
/// Class MethodNotAllowedException.
/// </summary>
public class MethodNotAllowedException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="MethodNotAllowedException" /> class.
/// </summary>
public MethodNotAllowedException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MethodNotAllowedException" /> class.
/// </summary>
/// <param name="message">The message.</param>
public MethodNotAllowedException(string message)
: base(message)
{
}
}
}

View File

@ -0,0 +1,26 @@
#pragma warning disable CS1591
#pragma warning disable SA1600
using System;
namespace MediaBrowser.Common.Extensions
{
public class RateLimitExceededException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="RateLimitExceededException" /> class.
/// </summary>
public RateLimitExceededException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RateLimitExceededException" /> class.
/// </summary>
/// <param name="message">The message.</param>
public RateLimitExceededException(string message)
: base(message)
{
}
}
}

View File

@ -1,11 +1,9 @@
#pragma warning disable CS1591
using System; using System;
namespace MediaBrowser.Common.Extensions namespace MediaBrowser.Common.Extensions
{ {
/// <summary> /// <summary>
/// Class ResourceNotFoundException /// Class ResourceNotFoundException.
/// </summary> /// </summary>
public class ResourceNotFoundException : Exception public class ResourceNotFoundException : Exception
{ {
@ -14,7 +12,6 @@ namespace MediaBrowser.Common.Extensions
/// </summary> /// </summary>
public ResourceNotFoundException() public ResourceNotFoundException()
{ {
} }
/// <summary> /// <summary>
@ -24,66 +21,6 @@ namespace MediaBrowser.Common.Extensions
public ResourceNotFoundException(string message) public ResourceNotFoundException(string message)
: base(message) : base(message)
{ {
}
}
/// <summary>
/// Class MethodNotAllowedException
/// </summary>
public class MethodNotAllowedException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="MethodNotAllowedException" /> class.
/// </summary>
public MethodNotAllowedException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MethodNotAllowedException" /> class.
/// </summary>
/// <param name="message">The message.</param>
public MethodNotAllowedException(string message)
: base(message)
{
}
}
public class RemoteServiceUnavailableException : Exception
{
public RemoteServiceUnavailableException()
{
}
public RemoteServiceUnavailableException(string message)
: base(message)
{
}
}
public class RateLimitExceededException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="RateLimitExceededException" /> class.
/// </summary>
public RateLimitExceededException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RateLimitExceededException" /> class.
/// </summary>
/// <param name="message">The message.</param>
public RateLimitExceededException(string message)
: base(message)
{
} }
} }
} }

View File

@ -14,11 +14,11 @@ namespace MediaBrowser.Common
internal const int LastHexSymbol = 0x66; // 102: f internal const int LastHexSymbol = 0x66; // 102: f
/// <summary> /// <summary>
/// Map from an ASCII char to its hex value shifted, /// Gets an map from an ASCII char to its hex value shifted,
/// e.g. <c>b</c> -> 11. 0xFF means it's not a hex symbol. /// e.g. <c>b</c> -> 11. 0xFF means it's not a hex symbol.
/// </summary> /// </summary>
/// <value></value> internal static ReadOnlySpan<byte> HexLookup => new byte[]
internal static ReadOnlySpan<byte> HexLookup => new byte[] { {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@ -29,10 +29,10 @@ namespace MediaBrowser.Common
}; };
/// <summary> /// <summary>
/// Encodes <c>bytes</c> as a hex string. /// Encodes each element of the specified bytes as its hexadecimal string representation.
/// </summary> /// </summary>
/// <param name="bytes"></param> /// <param name="bytes">An array of bytes.</param>
/// <param name="lowercase"></param> /// <param name="lowercase"><c>true</c> to use lowercase hexadecimal characters; otherwise <c>false</c>.</param>
/// <returns><c>bytes</c> as a hex string.</returns> /// <returns><c>bytes</c> as a hex string.</returns>
public static string Encode(ReadOnlySpan<byte> bytes, bool lowercase = true) public static string Encode(ReadOnlySpan<byte> bytes, bool lowercase = true)
{ {

View File

@ -8,10 +8,15 @@ using Microsoft.Extensions.DependencyInjection;
namespace MediaBrowser.Common namespace MediaBrowser.Common
{ {
/// <summary> /// <summary>
/// An interface to be implemented by the applications hosting a kernel /// An interface to be implemented by the applications hosting a kernel.
/// </summary> /// </summary>
public interface IApplicationHost public interface IApplicationHost
{ {
/// <summary>
/// Occurs when [has pending restart changed].
/// </summary>
event EventHandler HasPendingRestartChanged;
/// <summary> /// <summary>
/// Gets the name. /// Gets the name.
/// </summary> /// </summary>
@ -25,13 +30,13 @@ namespace MediaBrowser.Common
string SystemId { get; } string SystemId { get; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance has pending kernel reload. /// Gets a value indicating whether this instance has pending kernel reload.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
bool HasPendingRestart { get; } bool HasPendingRestart { get; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance is currently shutting down. /// Gets a value indicating whether this instance is currently shutting down.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is shutting down; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is shutting down; otherwise, <c>false</c>.</value>
bool IsShuttingDown { get; } bool IsShuttingDown { get; }
@ -43,26 +48,11 @@ namespace MediaBrowser.Common
bool CanSelfRestart { get; } bool CanSelfRestart { get; }
/// <summary> /// <summary>
/// Get the version class of the system. /// Gets the version class of the system.
/// </summary> /// </summary>
/// <value><see cref="PackageVersionClass.Release" /> or <see cref="PackageVersionClass.Beta" />.</value> /// <value><see cref="PackageVersionClass.Release" /> or <see cref="PackageVersionClass.Beta" />.</value>
PackageVersionClass SystemUpdateLevel { get; } PackageVersionClass SystemUpdateLevel { get; }
/// <summary>
/// Occurs when [has pending restart changed].
/// </summary>
event EventHandler HasPendingRestartChanged;
/// <summary>
/// Notifies the pending restart.
/// </summary>
void NotifyPendingRestart();
/// <summary>
/// Restarts this instance.
/// </summary>
void Restart();
/// <summary> /// <summary>
/// Gets the application version. /// Gets the application version.
/// </summary> /// </summary>
@ -87,6 +77,22 @@ namespace MediaBrowser.Common
/// </summary> /// </summary>
string ApplicationUserAgentAddress { get; } string ApplicationUserAgentAddress { get; }
/// <summary>
/// Gets the plugins.
/// </summary>
/// <value>The plugins.</value>
IReadOnlyList<IPlugin> Plugins { get; }
/// <summary>
/// Notifies the pending restart.
/// </summary>
void NotifyPendingRestart();
/// <summary>
/// Restarts this instance.
/// </summary>
void Restart();
/// <summary> /// <summary>
/// Gets the exports. /// Gets the exports.
/// </summary> /// </summary>
@ -98,21 +104,16 @@ namespace MediaBrowser.Common
/// <summary> /// <summary>
/// Resolves this instance. /// Resolves this instance.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">The <c>Type</c>.</typeparam>
/// <returns>``0.</returns> /// <returns>``0.</returns>
T Resolve<T>(); T Resolve<T>();
/// <summary> /// <summary>
/// Shuts down. /// Shuts down.
/// </summary> /// </summary>
/// <returns>A task.</returns>
Task Shutdown(); Task Shutdown();
/// <summary>
/// Gets the plugins.
/// </summary>
/// <value>The plugins.</value>
IPlugin[] Plugins { get; }
/// <summary> /// <summary>
/// Removes the plugin. /// Removes the plugin.
/// </summary> /// </summary>
@ -122,6 +123,8 @@ namespace MediaBrowser.Common
/// <summary> /// <summary>
/// Inits this instance. /// Inits this instance.
/// </summary> /// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <returns>A task.</returns>
Task InitAsync(IServiceCollection serviceCollection); Task InitAsync(IServiceCollection serviceCollection);
/// <summary> /// <summary>

View File

@ -12,8 +12,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" /> <PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -27,9 +27,16 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <!-- Code analyzers-->
<!-- We need at least C# 7.1 for the "default literal" feature--> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<LangVersion>latest</LangVersion> <!-- <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" /> -->
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<!-- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" /> -->
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
namespace MediaBrowser.Common.Net namespace MediaBrowser.Common.Net
{ {

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,10 +9,21 @@ using Microsoft.Net.Http.Headers;
namespace MediaBrowser.Common.Net namespace MediaBrowser.Common.Net
{ {
/// <summary> /// <summary>
/// Class HttpRequestOptions /// Class HttpRequestOptions.
/// </summary> /// </summary>
public class HttpRequestOptions public class HttpRequestOptions
{ {
/// <summary>
/// Initializes a new instance of the <see cref="HttpRequestOptions"/> class.
/// </summary>
public HttpRequestOptions()
{
RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
CacheMode = CacheMode.None;
DecompressionMethod = CompressionMethod.Deflate;
}
/// <summary> /// <summary>
/// Gets or sets the URL. /// Gets or sets the URL.
/// </summary> /// </summary>
@ -71,14 +83,17 @@ namespace MediaBrowser.Common.Net
public string RequestContentType { get; set; } public string RequestContentType { get; set; }
public string RequestContent { get; set; } public string RequestContent { get; set; }
public byte[] RequestContentBytes { get; set; } public byte[] RequestContentBytes { get; set; }
public bool BufferContent { get; set; } public bool BufferContent { get; set; }
public bool LogErrorResponseBody { get; set; } public bool LogErrorResponseBody { get; set; }
public bool EnableKeepAlive { get; set; } public bool EnableKeepAlive { get; set; }
public CacheMode CacheMode { get; set; } public CacheMode CacheMode { get; set; }
public TimeSpan CacheLength { get; set; } public TimeSpan CacheLength { get; set; }
public bool EnableDefaultUserAgent { get; set; } public bool EnableDefaultUserAgent { get; set; }
@ -89,17 +104,6 @@ namespace MediaBrowser.Common.Net
return value; return value;
} }
/// <summary>
/// Initializes a new instance of the <see cref="HttpRequestOptions"/> class.
/// </summary>
public HttpRequestOptions()
{
RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
CacheMode = CacheMode.None;
DecompressionMethod = CompressionMethod.Deflate;
}
} }
public enum CacheMode public enum CacheMode

View File

@ -1,5 +1,3 @@
#pragma warning disable CS1591
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
@ -8,10 +6,25 @@ using System.Net.Http.Headers;
namespace MediaBrowser.Common.Net namespace MediaBrowser.Common.Net
{ {
/// <summary> /// <summary>
/// Class HttpResponseInfo /// Class HttpResponseInfo.
/// </summary> /// </summary>
public class HttpResponseInfo : IDisposable public class HttpResponseInfo : IDisposable
{ {
#pragma warning disable CS1591
#pragma warning disable SA1600
public HttpResponseInfo()
{
}
public HttpResponseInfo(HttpResponseHeaders headers, HttpContentHeaders contentHeader)
{
Headers = headers;
ContentHeaders = contentHeader;
}
#pragma warning restore CS1591
#pragma warning restore SA1600
/// <summary> /// <summary>
/// Gets or sets the type of the content. /// Gets or sets the type of the content.
/// </summary> /// </summary>
@ -60,21 +73,10 @@ namespace MediaBrowser.Common.Net
/// <value>The content headers.</value> /// <value>The content headers.</value>
public HttpContentHeaders ContentHeaders { get; set; } public HttpContentHeaders ContentHeaders { get; set; }
public HttpResponseInfo()
{
}
public HttpResponseInfo(HttpResponseHeaders headers, HttpContentHeaders contentHeader)
{
Headers = headers;
ContentHeaders = contentHeader;
}
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() public void Dispose()
{ {
// Only IDisposable for backwards compatibility // backwards compatibility
} }
} }
} }

View File

@ -1,12 +1,12 @@
using System; using System;
using System.IO; using System.IO;
using System.Threading.Tasks;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Net namespace MediaBrowser.Common.Net
{ {
/// <summary> /// <summary>
/// Interface IHttpClient /// Interface IHttpClient.
/// </summary> /// </summary>
public interface IHttpClient public interface IHttpClient
{ {

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,20 +12,20 @@ namespace MediaBrowser.Common.Net
{ {
event EventHandler NetworkChanged; event EventHandler NetworkChanged;
Func<string[]> LocalSubnetsFn { get; set; }
/// <summary> /// <summary>
/// Gets a random port number that is currently available /// Gets a random port number that is currently available.
/// </summary> /// </summary>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
int GetRandomUnusedTcpPort(); int GetRandomUnusedTcpPort();
int GetRandomUnusedUdpPort(); int GetRandomUnusedUdpPort();
Func<string[]> LocalSubnetsFn { get; set; }
/// <summary> /// <summary>
/// Returns MAC Address from first Network Card in Computer /// Returns the MAC Address from first Network Card in Computer.
/// </summary> /// </summary>
/// <returns>[string] MAC Address</returns> /// <returns>The MAC Address.</returns>
List<PhysicalAddress> GetMacAddresses(); List<PhysicalAddress> GetMacAddresses();
/// <summary> /// <summary>

View File

@ -1,4 +1,4 @@
#pragma warning disable CS1591 #pragma warning disable SA1402
using System; using System;
using System.IO; using System.IO;
@ -8,10 +8,13 @@ using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Common.Plugins namespace MediaBrowser.Common.Plugins
{ {
/// <summary>
/// Provides a common base class for all plugins.
/// </summary>
public abstract class BasePlugin : IPlugin, IPluginAssembly public abstract class BasePlugin : IPlugin, IPluginAssembly
{ {
/// <summary> /// <summary>
/// Gets the name of the plugin /// Gets the name of the plugin.
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
public abstract string Name { get; } public abstract string Name { get; }
@ -29,17 +32,23 @@ namespace MediaBrowser.Common.Plugins
public virtual Guid Id { get; private set; } public virtual Guid Id { get; private set; }
/// <summary> /// <summary>
/// Gets the plugin version /// Gets the plugin version.
/// </summary> /// </summary>
/// <value>The version.</value> /// <value>The version.</value>
public Version Version { get; private set; } public Version Version { get; private set; }
/// <summary> /// <summary>
/// Gets the path to the assembly file /// Gets the path to the assembly file.
/// </summary> /// </summary>
/// <value>The assembly file path.</value> /// <value>The assembly file path.</value>
public string AssemblyFilePath { get; private set; } public string AssemblyFilePath { get; private set; }
/// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed.
/// </summary>
/// <value>The data folder path.</value>
public string DataFolderPath { get; private set; }
/// <summary> /// <summary>
/// Gets the plugin info. /// Gets the plugin info.
/// </summary> /// </summary>
@ -62,9 +71,9 @@ namespace MediaBrowser.Common.Plugins
/// </summary> /// </summary>
public virtual void OnUninstalling() public virtual void OnUninstalling()
{ {
} }
/// <inheritdoc />
public void SetAttributes(string assemblyFilePath, string dataFolderPath, Version assemblyVersion) public void SetAttributes(string assemblyFilePath, string dataFolderPath, Version assemblyVersion)
{ {
AssemblyFilePath = assemblyFilePath; AssemblyFilePath = assemblyFilePath;
@ -72,25 +81,48 @@ namespace MediaBrowser.Common.Plugins
Version = assemblyVersion; Version = assemblyVersion;
} }
/// <inheritdoc />
public void SetId(Guid assemblyId) public void SetId(Guid assemblyId)
{ {
Id = assemblyId; Id = assemblyId;
} }
/// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed
/// </summary>
/// <value>The data folder path.</value>
public string DataFolderPath { get; private set; }
} }
/// <summary> /// <summary>
/// Provides a common base class for all plugins /// Provides a common base class for all plugins.
/// </summary> /// </summary>
/// <typeparam name="TConfigurationType">The type of the T configuration type.</typeparam> /// <typeparam name="TConfigurationType">The type of the T configuration type.</typeparam>
public abstract class BasePlugin<TConfigurationType> : BasePlugin, IHasPluginConfiguration public abstract class BasePlugin<TConfigurationType> : BasePlugin, IHasPluginConfiguration
where TConfigurationType : BasePluginConfiguration where TConfigurationType : BasePluginConfiguration
{ {
/// <summary>
/// The _configuration sync lock.
/// </summary>
private readonly object _configurationSyncLock = new object();
/// <summary>
/// The _save lock.
/// </summary>
private readonly object _configurationSaveLock = new object();
private Action<string> _directoryCreateFn;
/// <summary>
/// The _configuration.
/// </summary>
private TConfigurationType _configuration;
/// <summary>
/// Initializes a new instance of the <see cref="BasePlugin{TConfigurationType}" /> class.
/// </summary>
/// <param name="applicationPaths">The application paths.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
protected BasePlugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
{
ApplicationPaths = applicationPaths;
XmlSerializer = xmlSerializer;
}
/// <summary> /// <summary>
/// Gets the application paths. /// Gets the application paths.
/// </summary> /// </summary>
@ -104,34 +136,19 @@ namespace MediaBrowser.Common.Plugins
protected IXmlSerializer XmlSerializer { get; private set; } protected IXmlSerializer XmlSerializer { get; private set; }
/// <summary> /// <summary>
/// Gets the type of configuration this plugin uses /// Gets the type of configuration this plugin uses.
/// </summary> /// </summary>
/// <value>The type of the configuration.</value> /// <value>The type of the configuration.</value>
public Type ConfigurationType => typeof(TConfigurationType); public Type ConfigurationType => typeof(TConfigurationType);
private Action<string> _directoryCreateFn;
public void SetStartupInfo(Action<string> directoryCreateFn)
{
// hack alert, until the .net core transition is complete
_directoryCreateFn = directoryCreateFn;
}
/// <summary> /// <summary>
/// Gets the name the assembly file /// Gets the name the assembly file.
/// </summary> /// </summary>
/// <value>The name of the assembly file.</value> /// <value>The name of the assembly file.</value>
protected string AssemblyFileName => Path.GetFileName(AssemblyFilePath); protected string AssemblyFileName => Path.GetFileName(AssemblyFilePath);
/// <summary> /// <summary>
/// The _configuration sync lock /// Gets or sets the plugin's configuration.
/// </summary>
private readonly object _configurationSyncLock = new object();
/// <summary>
/// The _configuration
/// </summary>
private TConfigurationType _configuration;
/// <summary>
/// Gets the plugin's configuration
/// </summary> /// </summary>
/// <value>The configuration.</value> /// <value>The configuration.</value>
public TConfigurationType Configuration public TConfigurationType Configuration
@ -149,11 +166,38 @@ namespace MediaBrowser.Common.Plugins
} }
} }
} }
return _configuration; return _configuration;
} }
protected set => _configuration = value; protected set => _configuration = value;
} }
/// <summary>
/// Gets the name of the configuration file. Subclasses should override.
/// </summary>
/// <value>The name of the configuration file.</value>
public virtual string ConfigurationFileName => Path.ChangeExtension(AssemblyFileName, ".xml");
/// <summary>
/// Gets the full path to the configuration file.
/// </summary>
/// <value>The configuration file path.</value>
public string ConfigurationFilePath => Path.Combine(ApplicationPaths.PluginConfigurationsPath, ConfigurationFileName);
/// <summary>
/// Gets the plugin's configuration.
/// </summary>
/// <value>The configuration.</value>
BasePluginConfiguration IHasPluginConfiguration.Configuration => Configuration;
/// <inheritdoc />
public void SetStartupInfo(Action<string> directoryCreateFn)
{
// hack alert, until the .net core transition is complete
_directoryCreateFn = directoryCreateFn;
}
private TConfigurationType LoadConfiguration() private TConfigurationType LoadConfiguration()
{ {
var path = ConfigurationFilePath; var path = ConfigurationFilePath;
@ -169,35 +213,7 @@ namespace MediaBrowser.Common.Plugins
} }
/// <summary> /// <summary>
/// Gets the name of the configuration file. Subclasses should override /// Saves the current configuration to the file system.
/// </summary>
/// <value>The name of the configuration file.</value>
public virtual string ConfigurationFileName => Path.ChangeExtension(AssemblyFileName, ".xml");
/// <summary>
/// Gets the full path to the configuration file
/// </summary>
/// <value>The configuration file path.</value>
public string ConfigurationFilePath => Path.Combine(ApplicationPaths.PluginConfigurationsPath, ConfigurationFileName);
/// <summary>
/// Initializes a new instance of the <see cref="BasePlugin{TConfigurationType}" /> class.
/// </summary>
/// <param name="applicationPaths">The application paths.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
protected BasePlugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
{
ApplicationPaths = applicationPaths;
XmlSerializer = xmlSerializer;
}
/// <summary>
/// The _save lock
/// </summary>
private readonly object _configurationSaveLock = new object();
/// <summary>
/// Saves the current configuration to the file system
/// </summary> /// </summary>
public virtual void SaveConfiguration() public virtual void SaveConfiguration()
{ {
@ -209,12 +225,7 @@ namespace MediaBrowser.Common.Plugins
} }
} }
/// <summary> /// <inheritdoc />
/// Completely overwrites the current configuration with a new copy
/// Returns true or false indicating success or failure
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <exception cref="ArgumentNullException">configuration</exception>
public virtual void UpdateConfiguration(BasePluginConfiguration configuration) public virtual void UpdateConfiguration(BasePluginConfiguration configuration)
{ {
if (configuration == null) if (configuration == null)
@ -227,12 +238,7 @@ namespace MediaBrowser.Common.Plugins
SaveConfiguration(); SaveConfiguration();
} }
/// <summary> /// <inheritdoc />
/// Gets the plugin's configuration
/// </summary>
/// <value>The configuration.</value>
BasePluginConfiguration IHasPluginConfiguration.Configuration => Configuration;
public override PluginInfo GetPluginInfo() public override PluginInfo GetPluginInfo()
{ {
var info = base.GetPluginInfo(); var info = base.GetPluginInfo();
@ -242,10 +248,4 @@ namespace MediaBrowser.Common.Plugins
return info; return info;
} }
} }
public interface IPluginAssembly
{
void SetAttributes(string assemblyFilePath, string dataFolderPath, Version assemblyVersion);
void SetId(Guid assemblyId);
}
} }

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
@ -6,12 +7,12 @@ using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Common.Plugins namespace MediaBrowser.Common.Plugins
{ {
/// <summary> /// <summary>
/// Interface IPlugin /// Interface IPlugin.
/// </summary> /// </summary>
public interface IPlugin public interface IPlugin
{ {
/// <summary> /// <summary>
/// Gets the name of the plugin /// Gets the name of the plugin.
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
string Name { get; } string Name { get; }
@ -29,19 +30,19 @@ namespace MediaBrowser.Common.Plugins
Guid Id { get; } Guid Id { get; }
/// <summary> /// <summary>
/// Gets the plugin version /// Gets the plugin version.
/// </summary> /// </summary>
/// <value>The version.</value> /// <value>The version.</value>
Version Version { get; } Version Version { get; }
/// <summary> /// <summary>
/// Gets the path to the assembly file /// Gets the path to the assembly file.
/// </summary> /// </summary>
/// <value>The assembly file path.</value> /// <value>The assembly file path.</value>
string AssemblyFilePath { get; } string AssemblyFilePath { get; }
/// <summary> /// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed /// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed.
/// </summary> /// </summary>
/// <value>The data folder path.</value> /// <value>The data folder path.</value>
string DataFolderPath { get; } string DataFolderPath { get; }
@ -61,25 +62,25 @@ namespace MediaBrowser.Common.Plugins
public interface IHasPluginConfiguration public interface IHasPluginConfiguration
{ {
/// <summary> /// <summary>
/// Gets the type of configuration this plugin uses /// Gets the type of configuration this plugin uses.
/// </summary> /// </summary>
/// <value>The type of the configuration.</value> /// <value>The type of the configuration.</value>
Type ConfigurationType { get; } Type ConfigurationType { get; }
/// <summary> /// <summary>
/// Completely overwrites the current configuration with a new copy /// Gets the plugin's configuration.
/// Returns true or false indicating success or failure
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <exception cref="ArgumentNullException">configuration</exception>
void UpdateConfiguration(BasePluginConfiguration configuration);
/// <summary>
/// Gets the plugin's configuration
/// </summary> /// </summary>
/// <value>The configuration.</value> /// <value>The configuration.</value>
BasePluginConfiguration Configuration { get; } BasePluginConfiguration Configuration { get; }
/// <summary>
/// Completely overwrites the current configuration with a new copy
/// Returns true or false indicating success or failure.
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <exception cref="ArgumentNullException"><c>configuration</c> is <c>null</c>.</exception>
void UpdateConfiguration(BasePluginConfiguration configuration);
void SetStartupInfo(Action<string> directoryCreateFn); void SetStartupInfo(Action<string> directoryCreateFn);
} }
} }

View File

@ -0,0 +1,14 @@
#pragma warning disable CS1591
#pragma warning disable SA1600
using System;
namespace MediaBrowser.Common.Plugins
{
public interface IPluginAssembly
{
void SetAttributes(string assemblyFilePath, string dataFolderPath, Version assemblyVersion);
void SetId(Guid assemblyId);
}
}

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System.Collections.Generic; using System.Collections.Generic;
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -103,17 +104,16 @@ namespace MediaBrowser.Common.Updates
Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken = default); Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Uninstalls a plugin /// Uninstalls a plugin.
/// </summary> /// </summary>
/// <param name="plugin">The plugin.</param> /// <param name="plugin">The plugin.</param>
/// <exception cref="ArgumentException"></exception>
void UninstallPlugin(IPlugin plugin); void UninstallPlugin(IPlugin plugin);
/// <summary> /// <summary>
/// Cancels the installation /// Cancels the installation.
/// </summary> /// </summary>
/// <param name="id">The id of the package that is being installed</param> /// <param name="id">The id of the package that is being installed.</param>
/// <returns>Returns true if the install was cancelled</returns> /// <returns>Returns true if the install was cancelled.</returns>
bool CancelInstallation(Guid id); bool CancelInstallation(Guid id);
} }
} }

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using MediaBrowser.Model.Updates; using MediaBrowser.Model.Updates;

View File

@ -1,4 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable SA1600
using System; using System;

View File

@ -1,14 +1,19 @@
#pragma warning disable CS1591
#pragma warning disable SA1600
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
namespace MediaBrowser.Controller.Authentication namespace MediaBrowser.Controller.Authentication
{ {
public class AuthenticationResult public class AuthenticationResult
{ {
public UserDto User { get; set; } public UserDto User { get; set; }
public SessionInfo SessionInfo { get; set; } public SessionInfo SessionInfo { get; set; }
public string AccessToken { get; set; } public string AccessToken { get; set; }
public string ServerId { get; set; } public string ServerId { get; set; }
} }
} }

View File

@ -19,7 +19,6 @@ using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Library; using MediaBrowser.Model.Library;

View File

@ -31,8 +31,12 @@
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design"> <Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design">
<!-- disable warning CA1031: Do not catch general exception types --> <!-- disable warning CA1031: Do not catch general exception types -->
<Rule Id="CA1031" Action="Info" /> <Rule Id="CA1031" Action="Info" />
<!-- disable warning CA1032: Implement standard exception constructors -->
<Rule Id="CA1032" Action="Info" />
<!-- disable warning CA1062: Validate arguments of public methods --> <!-- disable warning CA1062: Validate arguments of public methods -->
<Rule Id="CA1062" Action="Info" /> <Rule Id="CA1062" Action="Info" />
<!-- disable warning CA1716: Identifiers should not match keywords -->
<Rule Id="CA1716" Action="Info" />
<!-- disable warning CA1720: Identifiers should not contain type names --> <!-- disable warning CA1720: Identifiers should not contain type names -->
<Rule Id="CA1720" Action="Info" /> <Rule Id="CA1720" Action="Info" />
<!-- disable warning CA1812: internal class that is apparently never instantiated. <!-- disable warning CA1812: internal class that is apparently never instantiated.
@ -41,14 +45,18 @@
<Rule Id="CA1812" Action="Info" /> <Rule Id="CA1812" Action="Info" />
<!-- disable warning CA1822: Member does not access instance data and can be marked as static --> <!-- disable warning CA1822: Member does not access instance data and can be marked as static -->
<Rule Id="CA1822" Action="Info" /> <Rule Id="CA1822" Action="Info" />
<!-- disable warning CA2000: Dispose objects before losing scope -->
<Rule Id="CA2000" Action="Info" />
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri --> <!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
<Rule Id="CA1054" Action="None" /> <Rule Id="CA1054" Action="None" />
<!-- disable warning CA1055: URI return values should not be strings -->
<Rule Id="CA1055" Action="None" />
<!-- disable warning CA1056: URI properties should not be strings -->
<Rule Id="CA1056" Action="None" />
<!-- disable warning CA1303: Do not pass literals as localized parameters --> <!-- disable warning CA1303: Do not pass literals as localized parameters -->
<Rule Id="CA1303" Action="None" /> <Rule Id="CA1303" Action="None" />
<!-- disable warning CA1308: Normalize strings to uppercase --> <!-- disable warning CA1308: Normalize strings to uppercase -->
<Rule Id="CA1308" Action="None" /> <Rule Id="CA1308" Action="None" />
<!-- disable warning CA2000: Dispose objects before losing scope -->
<Rule Id="CA2000" Action="None" />
</Rules> </Rules>
</RuleSet> </RuleSet>