소스 검색

Enable `TreatWarningsAsErrors` for MediaBrowser.Common and Emby.Photos

Adds `#pragma warning disable CS1591` to all files in
MediaBrowser.Common containing undocumented members.
Bond_009 5 년 전
부모
커밋
9d4ce82ab9
28개의 변경된 파일99개의 추가작업 그리고 37개의 파일을 삭제
  1. 12 0
      Emby.Photos/Emby.Photos.csproj
  2. 17 13
      Emby.Photos/PhotoProvider.cs
  3. 1 4
      Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
  4. 5 2
      Emby.Server.Implementations/ApplicationHost.cs
  5. 3 0
      MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
  6. 4 1
      MediaBrowser.Common/Configuration/IApplicationPaths.cs
  7. 2 0
      MediaBrowser.Common/Configuration/IConfigurationFactory.cs
  8. 2 0
      MediaBrowser.Common/Configuration/IConfigurationManager.cs
  9. 2 0
      MediaBrowser.Common/Cryptography/PasswordHash.cs
  10. 2 0
      MediaBrowser.Common/Events/EventHelper.cs
  11. 2 0
      MediaBrowser.Common/Extensions/CollectionExtensions.cs
  12. 2 0
      MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
  13. 2 0
      MediaBrowser.Common/HexHelper.cs
  14. 10 3
      MediaBrowser.Common/IApplicationHost.cs
  15. 1 0
      MediaBrowser.Common/MediaBrowser.Common.csproj
  16. 2 0
      MediaBrowser.Common/Net/CustomHeaderNames.cs
  17. 2 0
      MediaBrowser.Common/Net/HttpRequestOptions.cs
  18. 3 0
      MediaBrowser.Common/Net/HttpResponseInfo.cs
  19. 3 1
      MediaBrowser.Common/Net/IHttpClient.cs
  20. 2 0
      MediaBrowser.Common/Net/INetworkManager.cs
  21. 2 0
      MediaBrowser.Common/Plugins/BasePlugin.cs
  22. 2 0
      MediaBrowser.Common/Plugins/IPlugin.cs
  23. 5 13
      MediaBrowser.Common/Progress/ActionableProgress.cs
  24. 3 0
      MediaBrowser.Common/Providers/SubtitleConfigurationFactory.cs
  25. 2 0
      MediaBrowser.Common/System/OperatingSystem.cs
  26. 2 0
      MediaBrowser.Common/Updates/IInstallationManager.cs
  27. 2 0
      MediaBrowser.Common/Updates/InstallationEventArgs.cs
  28. 2 0
      MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs

+ 12 - 0
Emby.Photos/Emby.Photos.csproj

@@ -17,6 +17,18 @@
     <TargetFramework>netstandard2.0</TargetFramework>
     <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
+    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+  </PropertyGroup>
+
+  <!-- Code analysers-->
+  <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
+    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
+    <PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
+  </ItemGroup>
+
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
 
 </Project>

+ 17 - 13
Emby.Photos/PhotoProvider.cs

@@ -17,39 +17,50 @@ using TagLib.IFD.Tags;
 
 namespace Emby.Photos
 {
+    /// <summary>
+    /// Metadata provider for photos.
+    /// </summary>
     public class PhotoProvider : ICustomMetadataProvider<Photo>, IForcedProvider, IHasItemChangeMonitor
     {
         private readonly ILogger _logger;
         private readonly IImageProcessor _imageProcessor;
 
         // These are causing taglib to hang
-        private string[] _includextensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff", ".cr2" };
-
-        public PhotoProvider(ILogger logger, IImageProcessor imageProcessor)
+        private readonly string[] _includeExtensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff", ".cr2" };
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="PhotoProvider" /> class.
+        /// </summary>
+        /// <param name="logger">The logger.</param>
+        /// <param name="imageProcessor">The image processor.</param>
+        public PhotoProvider(ILogger<PhotoProvider> logger, IImageProcessor imageProcessor)
         {
             _logger = logger;
             _imageProcessor = imageProcessor;
         }
 
+        /// <inheritdoc />
         public string Name => "Embedded Information";
 
+        /// <inheritdoc />
         public bool HasChanged(BaseItem item, IDirectoryService directoryService)
         {
             if (item.IsFileProtocol)
             {
                 var file = directoryService.GetFile(item.Path);
-                return (file != null && file.LastWriteTimeUtc != item.DateModified);
+                return file != null && file.LastWriteTimeUtc != item.DateModified;
             }
 
             return false;
         }
 
+        /// <inheritdoc />
         public Task<ItemUpdateType> FetchAsync(Photo item, MetadataRefreshOptions options, CancellationToken cancellationToken)
         {
             item.SetImagePath(ImageType.Primary, item.Path);
 
             // Examples: https://github.com/mono/taglib-sharp/blob/a5f6949a53d09ce63ee7495580d6802921a21f14/tests/fixtures/TagLib.Tests.Images/NullOrientationTest.cs
-            if (_includextensions.Contains(Path.GetExtension(item.Path), StringComparer.OrdinalIgnoreCase))
+            if (_includeExtensions.Contains(Path.GetExtension(item.Path), StringComparer.OrdinalIgnoreCase))
             {
                 try
                 {
@@ -88,14 +99,7 @@ namespace Emby.Photos
                             item.Height = image.Properties.PhotoHeight;
 
                             var rating = image.ImageTag.Rating;
-                            if (rating.HasValue)
-                            {
-                                item.CommunityRating = rating;
-                            }
-                            else
-                            {
-                                item.CommunityRating = null;
-                            }
+                            item.CommunityRating = rating.HasValue ? rating : null;
 
                             item.Overview = image.ImageTag.Comment;
 

+ 1 - 4
Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs

@@ -59,10 +59,7 @@ namespace Emby.Server.Implementations.AppBase
             private set => _dataPath = Directory.CreateDirectory(value).FullName;
         }
 
-        /// <summary>
-        /// Gets the magic string used for virtual path manipulation.
-        /// </summary>
-        /// <value>The magic string used for virtual path manipulation.</value>
+        /// <inheritdoc />
         public string VirtualDataPath { get; } = "%AppDataPath%";
 
         /// <summary>

+ 5 - 2
Emby.Server.Implementations/ApplicationHost.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -49,7 +51,6 @@ using MediaBrowser.Api;
 using MediaBrowser.Common;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Events;
-using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Common.Updates;
@@ -117,7 +118,7 @@ using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
 namespace Emby.Server.Implementations
 {
     /// <summary>
-    /// Class CompositionRoot
+    /// Class CompositionRoot.
     /// </summary>
     public abstract class ApplicationHost : IServerApplicationHost, IDisposable
     {
@@ -166,6 +167,7 @@ namespace Emby.Server.Implementations
         /// <value><c>true</c> if this instance has pending application restart; otherwise, <c>false</c>.</value>
         public bool HasPendingRestart { get; private set; }
 
+        /// <inheritdoc />
         public bool IsShuttingDown { get; private set; }
 
         /// <summary>
@@ -217,6 +219,7 @@ namespace Emby.Server.Implementations
 
         public IFileSystem FileSystemManager { get; set; }
 
+        /// <inheritdoc />
         public PackageVersionClass SystemUpdateLevel
         {
             get

+ 3 - 0
MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 
 namespace MediaBrowser.Common.Configuration
@@ -9,6 +11,7 @@ namespace MediaBrowser.Common.Configuration
         /// </summary>
         /// <value>The key.</value>
         public string Key { get; set; }
+
         /// <summary>
         /// Gets or sets the new configuration.
         /// </summary>

+ 4 - 1
MediaBrowser.Common/Configuration/IApplicationPaths.cs

@@ -77,7 +77,10 @@ namespace MediaBrowser.Common.Configuration
         /// <value>The temp directory.</value>
         string TempDirectory { get; }
 
+        /// <summary>
+        /// Gets the magic string used for virtual path manipulation.
+        /// </summary>
+        /// <value>The magic string used for virtual path manipulation.</value>
         string VirtualDataPath { get; }
     }
-
 }

+ 2 - 0
MediaBrowser.Common/Configuration/IConfigurationFactory.cs

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

+ 2 - 0
MediaBrowser.Common/Configuration/IConfigurationManager.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 using System.Collections.Generic;
 using MediaBrowser.Model.Configuration;

+ 2 - 0
MediaBrowser.Common/Cryptography/PasswordHash.cs

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

+ 2 - 0
MediaBrowser.Common/Events/EventHelper.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 using System.Threading.Tasks;
 using Microsoft.Extensions.Logging;

+ 2 - 0
MediaBrowser.Common/Extensions/CollectionExtensions.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System.Collections.Generic;
 
 namespace MediaBrowser.Common.Extensions

+ 2 - 0
MediaBrowser.Common/Extensions/ResourceNotFoundException.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 
 namespace MediaBrowser.Common.Extensions

+ 2 - 0
MediaBrowser.Common/HexHelper.cs

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

+ 10 - 3
MediaBrowser.Common/IApplicationHost.cs

@@ -2,7 +2,6 @@ using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
 using MediaBrowser.Common.Plugins;
-using MediaBrowser.Model.Events;
 using MediaBrowser.Model.Updates;
 using Microsoft.Extensions.DependencyInjection;
 
@@ -31,6 +30,10 @@ namespace MediaBrowser.Common
         /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
         bool HasPendingRestart { get; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether this instance is currently shutting down.
+        /// </summary>
+        /// <value><c>true</c> if this instance is shutting down; otherwise, <c>false</c>.</value>
         bool IsShuttingDown { get; }
 
         /// <summary>
@@ -39,6 +42,12 @@ namespace MediaBrowser.Common
         /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
         bool CanSelfRestart { get; }
 
+        /// <summary>
+        /// Get the version class of the system.
+        /// </summary>
+        /// <value><see cref="PackageVersionClass.Release" /> or <see cref="PackageVersionClass.Beta" />.</value>
+        PackageVersionClass SystemUpdateLevel { get; }
+
         /// <summary>
         /// Occurs when [has pending restart changed].
         /// </summary>
@@ -115,7 +124,5 @@ namespace MediaBrowser.Common
         /// <param name="type">The type.</param>
         /// <returns>System.Object.</returns>
         object CreateInstance(Type type);
-
-        PackageVersionClass SystemUpdateLevel { get; }
     }
 }

+ 1 - 0
MediaBrowser.Common/MediaBrowser.Common.csproj

@@ -24,6 +24,7 @@
     <TargetFramework>netstandard2.0</TargetFramework>
     <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
+    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
   </PropertyGroup>
 
   <PropertyGroup>

+ 2 - 0
MediaBrowser.Common/Net/CustomHeaderNames.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 namespace MediaBrowser.Common.Net
 {
     public static class CustomHeaderNames

+ 2 - 0
MediaBrowser.Common/Net/HttpRequestOptions.cs

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

+ 3 - 0
MediaBrowser.Common/Net/HttpResponseInfo.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 using System.IO;
 using System.Net;
@@ -69,6 +71,7 @@ namespace MediaBrowser.Common.Net
             ContentHeaders = contentHeader;
         }
 
+        /// <inheritdoc />
         public void Dispose()
         {
             // Only IDisposable for backwards compatibility

+ 3 - 1
MediaBrowser.Common/Net/IHttpClient.cs

@@ -1,3 +1,4 @@
+using System;
 using System.IO;
 using System.Threading.Tasks;
 using System.Net.Http;
@@ -25,12 +26,13 @@ namespace MediaBrowser.Common.Net
 
         /// <summary>
         /// Warning: Deprecated function,
-        /// use 'Task<HttpResponseInfo> SendAsync(HttpRequestOptions options, HttpMethod httpMethod);' instead
+        /// use 'Task{HttpResponseInfo} SendAsync(HttpRequestOptions options, HttpMethod httpMethod);' instead
         /// Sends the asynchronous.
         /// </summary>
         /// <param name="options">The options.</param>
         /// <param name="httpMethod">The HTTP method.</param>
         /// <returns>Task{HttpResponseInfo}.</returns>
+        [Obsolete("Use 'Task{HttpResponseInfo} SendAsync(HttpRequestOptions options, HttpMethod httpMethod);' instead")]
         Task<HttpResponseInfo> SendAsync(HttpRequestOptions options, string httpMethod);
 
         /// <summary>

+ 2 - 0
MediaBrowser.Common/Net/INetworkManager.cs

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

+ 2 - 0
MediaBrowser.Common/Plugins/BasePlugin.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 using System.IO;
 using MediaBrowser.Common.Configuration;

+ 2 - 0
MediaBrowser.Common/Plugins/IPlugin.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 using MediaBrowser.Model.Plugins;
 

+ 5 - 13
MediaBrowser.Common/Progress/ActionableProgress.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 
 namespace MediaBrowser.Common.Progress
@@ -25,16 +27,9 @@ namespace MediaBrowser.Common.Progress
 
         public void Report(T value)
         {
-            if (ProgressChanged != null)
-            {
-                ProgressChanged(this, value);
-            }
+            ProgressChanged?.Invoke(this, value);
 
-            var action = _action;
-            if (action != null)
-            {
-                action(value);
-            }
+            _action?.Invoke(value);
         }
     }
 
@@ -44,10 +39,7 @@ namespace MediaBrowser.Common.Progress
 
         public void Report(T value)
         {
-            if (ProgressChanged != null)
-            {
-                ProgressChanged(this, value);
-            }
+            ProgressChanged?.Invoke(this, value);
         }
     }
 }

+ 3 - 0
MediaBrowser.Common/Providers/SubtitleConfigurationFactory.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System.Collections.Generic;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Model.Providers;
@@ -6,6 +8,7 @@ namespace MediaBrowser.Common.Providers
 {
     public class SubtitleConfigurationFactory : IConfigurationFactory
     {
+        /// <inheritdoc />
         public IEnumerable<ConfigurationStore> GetConfigurations()
         {
             yield return new ConfigurationStore()

+ 2 - 0
MediaBrowser.Common/System/OperatingSystem.cs

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

+ 2 - 0
MediaBrowser.Common/Updates/IInstallationManager.cs

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

+ 2 - 0
MediaBrowser.Common/Updates/InstallationEventArgs.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using MediaBrowser.Model.Updates;
 
 namespace MediaBrowser.Common.Updates

+ 2 - 0
MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
 using System;
 
 namespace MediaBrowser.Common.Updates