Enable Microsoft.CodeAnalysis.FxCopAnalyzers for Jellyfin.Common

This commit is contained in:
Bond_009 2020-04-02 17:00:28 +02:00
parent 5a816f0b22
commit 2be394089e
9 changed files with 16 additions and 23 deletions

View file

@ -96,13 +96,13 @@ namespace Emby.Server.Implementations.HttpClientManager
switch (options.DecompressionMethod) switch (options.DecompressionMethod)
{ {
case CompressionMethod.Deflate | CompressionMethod.Gzip: case CompressionMethods.Deflate | CompressionMethods.Gzip:
request.Headers.Add(HeaderNames.AcceptEncoding, new[] { "gzip", "deflate" }); request.Headers.Add(HeaderNames.AcceptEncoding, new[] { "gzip", "deflate" });
break; break;
case CompressionMethod.Deflate: case CompressionMethods.Deflate:
request.Headers.Add(HeaderNames.AcceptEncoding, "deflate"); request.Headers.Add(HeaderNames.AcceptEncoding, "deflate");
break; break;
case CompressionMethod.Gzip: case CompressionMethods.Gzip:
request.Headers.Add(HeaderNames.AcceptEncoding, "gzip"); request.Headers.Add(HeaderNames.AcceptEncoding, "gzip");
break; break;
default: default:
@ -239,15 +239,10 @@ namespace Emby.Server.Implementations.HttpClientManager
var httpWebRequest = GetRequestMessage(options, httpMethod); var httpWebRequest = GetRequestMessage(options, httpMethod);
if (options.RequestContentBytes != null if (!string.IsNullOrEmpty(options.RequestContent)
|| !string.IsNullOrEmpty(options.RequestContent)
|| httpMethod == HttpMethod.Post) || httpMethod == HttpMethod.Post)
{ {
if (options.RequestContentBytes != null) if (options.RequestContent != null)
{
httpWebRequest.Content = new ByteArrayContent(options.RequestContentBytes);
}
else if (options.RequestContent != null)
{ {
httpWebRequest.Content = new StringContent( httpWebRequest.Content = new StringContent(
options.RequestContent, options.RequestContent,

View file

@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
UserAgent = "Emby/3.0", UserAgent = "Emby/3.0",
// Shouldn't matter but may cause issues // Shouldn't matter but may cause issues
DecompressionMethod = CompressionMethod.None DecompressionMethod = CompressionMethods.None
}; };
using (var response = await _httpClient.SendAsync(httpRequestOptions, HttpMethod.Get).ConfigureAwait(false)) using (var response = await _httpClient.SendAsync(httpRequestOptions, HttpMethod.Get).ConfigureAwait(false))

View file

@ -635,7 +635,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
ListingsProviderInfo providerInfo) ListingsProviderInfo providerInfo)
{ {
// Schedules direct requires that the client support compression and will return a 400 response without it // Schedules direct requires that the client support compression and will return a 400 response without it
options.DecompressionMethod = CompressionMethod.Deflate; options.DecompressionMethod = CompressionMethods.Deflate;
try try
{ {
@ -665,7 +665,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
ListingsProviderInfo providerInfo) ListingsProviderInfo providerInfo)
{ {
// Schedules direct requires that the client support compression and will return a 400 response without it // Schedules direct requires that the client support compression and will return a 400 response without it
options.DecompressionMethod = CompressionMethod.Deflate; options.DecompressionMethod = CompressionMethods.Deflate;
try try
{ {

View file

@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
Url = path, Url = path,
DecompressionMethod = CompressionMethod.Gzip, DecompressionMethod = CompressionMethods.Gzip,
}, },
HttpMethod.Get).ConfigureAwait(false)) HttpMethod.Get).ConfigureAwait(false))
using (var stream = res.Content) using (var stream = res.Content)

View file

@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
Url = url, Url = url,
CancellationToken = CancellationToken.None, CancellationToken = CancellationToken.None,
BufferContent = false, BufferContent = false,
DecompressionMethod = CompressionMethod.None DecompressionMethod = CompressionMethods.None
}; };
foreach (var header in mediaSource.RequiredHttpHeaders) foreach (var header in mediaSource.RequiredHttpHeaders)

View file

@ -9,7 +9,7 @@ namespace MediaBrowser.Common.Cryptography
/// <summary> /// <summary>
/// Class containing extension methods for working with Jellyfin cryptography objects. /// Class containing extension methods for working with Jellyfin cryptography objects.
/// </summary> /// </summary>
public static class Extensions public static class CryptoExtensions
{ {
/// <summary> /// <summary>
/// Creates a new <see cref="PasswordHash" /> instance. /// Creates a new <see cref="PasswordHash" /> instance.

View file

@ -30,7 +30,7 @@
<!-- Code analyzers--> <!-- Code analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<!-- <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" 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

@ -20,7 +20,7 @@ namespace MediaBrowser.Common.Net
RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
CacheMode = CacheMode.None; CacheMode = CacheMode.None;
DecompressionMethod = CompressionMethod.Deflate; DecompressionMethod = CompressionMethods.Deflate;
} }
/// <summary> /// <summary>
@ -29,7 +29,7 @@ namespace MediaBrowser.Common.Net
/// <value>The URL.</value> /// <value>The URL.</value>
public string Url { get; set; } public string Url { get; set; }
public CompressionMethod DecompressionMethod { get; set; } public CompressionMethods DecompressionMethod { get; set; }
/// <summary> /// <summary>
/// Gets or sets the accept header. /// Gets or sets the accept header.
@ -83,8 +83,6 @@ namespace MediaBrowser.Common.Net
public string RequestContent { get; set; } public string RequestContent { 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; }
@ -112,7 +110,7 @@ namespace MediaBrowser.Common.Net
} }
[Flags] [Flags]
public enum CompressionMethod public enum CompressionMethods
{ {
None = 0b00000001, None = 0b00000001,
Deflate = 0b00000010, Deflate = 0b00000010,

View file

@ -8,7 +8,7 @@ namespace MediaBrowser.Common.Net
/// <summary> /// <summary>
/// Class HttpResponseInfo. /// Class HttpResponseInfo.
/// </summary> /// </summary>
public class HttpResponseInfo : IDisposable public sealed class HttpResponseInfo : IDisposable
{ {
#pragma warning disable CS1591 #pragma warning disable CS1591
public HttpResponseInfo() public HttpResponseInfo()