Browse Source

Warnings cleanup

Patrick Barron 5 years ago
parent
commit
56212e8101

+ 31 - 17
Jellyfin.Data/Entities/AccessSchedule.cs

@@ -6,22 +6,18 @@ using Jellyfin.Data.Enums;
 
 namespace Jellyfin.Data.Entities
 {
+    /// <summary>
+    /// An entity representing a user's access schedule.
+    /// </summary>
     public class AccessSchedule
     {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="AccessSchedule"/> class.
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </summary>
-        protected AccessSchedule()
-        {
-        }
-
         /// <summary>
         /// Initializes a new instance of the <see cref="AccessSchedule"/> class.
         /// </summary>
         /// <param name="dayOfWeek">The day of the week.</param>
         /// <param name="startHour">The start hour.</param>
         /// <param name="endHour">The end hour.</param>
+        /// <param name="userId">The associated user's id.</param>
         public AccessSchedule(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
         {
             UserId = userId;
@@ -31,26 +27,31 @@ namespace Jellyfin.Data.Entities
         }
 
         /// <summary>
-        /// Factory method
+        /// Initializes a new instance of the <see cref="AccessSchedule"/> class.
+        /// Default constructor. Protected due to required properties, but present because EF needs it.
         /// </summary>
-        /// <param name="dayOfWeek">The day of the week.</param>
-        /// <param name="startHour">The start hour.</param>
-        /// <param name="endHour">The end hour.</param>
-        /// <returns>The newly created instance.</returns>
-        public static AccessSchedule CreateInstance(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
+        protected AccessSchedule()
         {
-            return new AccessSchedule(dayOfWeek, startHour, endHour, userId);
         }
 
+        /// <summary>
+        /// Gets or sets the id of this instance.
+        /// </summary>
+        /// <remarks>
+        /// Identity, Indexed, Required.
+        /// </remarks>
         [JsonIgnore]
         [Key]
         [Required]
         [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
-        public int Id { get; set; }
+        public int Id { get; protected set; }
 
+        /// <summary>
+        /// Gets or sets the id of the associated user.
+        /// </summary>
         [Required]
         [ForeignKey("Id")]
-        public Guid UserId { get; set; }
+        public Guid UserId { get; protected set; }
 
         /// <summary>
         /// Gets or sets the day of week.
@@ -72,5 +73,18 @@ namespace Jellyfin.Data.Entities
         /// <value>The end hour.</value>
         [Required]
         public double EndHour { get; set; }
+
+        /// <summary>
+        /// Static create function (for use in LINQ queries, etc.)
+        /// </summary>
+        /// <param name="dayOfWeek">The day of the week.</param>
+        /// <param name="startHour">The start hour.</param>
+        /// <param name="endHour">The end hour.</param>
+        /// <param name="userId">The associated user's id.</param>
+        /// <returns>The newly created instance.</returns>
+        public static AccessSchedule Create(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
+        {
+            return new AccessSchedule(dayOfWeek, startHour, endHour, userId);
+        }
     }
 }

+ 36 - 68
Jellyfin.Data/Entities/Permission.cs

@@ -1,23 +1,20 @@
-using System;
-using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using System.Runtime.CompilerServices;
 using Jellyfin.Data.Enums;
 
 namespace Jellyfin.Data.Entities
 {
+    /// <summary>
+    /// An entity representing whether the associated user has a specific permission.
+    /// </summary>
     public partial class Permission : ISavingChanges
     {
-        partial void Init();
-
         /// <summary>
         /// Initializes a new instance of the <see cref="Permission"/> class.
-        /// Public constructor with required data
+        /// Public constructor with required data.
         /// </summary>
-        /// <param name="kind"></param>
-        /// <param name="value"></param>
-        /// <param name="holderId"></param>
+        /// <param name="kind">The permission kind.</param>
+        /// <param name="value">The value of this permission.</param>
         public Permission(PermissionKind kind, bool value)
         {
             Kind = kind;
@@ -35,95 +32,66 @@ namespace Jellyfin.Data.Entities
             Init();
         }
 
-        /// <summary>
-        /// Static create function (for use in LINQ queries, etc.)
-        /// </summary>
-        /// <param name="kind"></param>
-        /// <param name="value"></param>
-        /// <param name="holderId"></param>
-        public static Permission Create(PermissionKind kind, bool value)
-        {
-            return new Permission(kind, value);
-        }
-
         /*************************************************************************
          * Properties
          *************************************************************************/
 
         /// <summary>
-        /// Identity, Indexed, Required
+        /// Gets or sets the id of this permission.
         /// </summary>
+        /// <remarks>
+        /// Identity, Indexed, Required.
+        /// </remarks>
         [Key]
         [Required]
         [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
         public int Id { get; protected set; }
 
         /// <summary>
-        /// Backing field for Kind
-        /// </summary>
-        protected PermissionKind _Kind;
-        /// <summary>
-        /// When provided in a partial class, allows value of Kind to be changed before setting.
-        /// </summary>
-        partial void SetKind(PermissionKind oldValue, ref PermissionKind newValue);
-        /// <summary>
-        /// When provided in a partial class, allows value of Kind to be changed before returning.
-        /// </summary>
-        partial void GetKind(ref PermissionKind result);
-
-        /// <summary>
-        /// Required
+        /// Gets or sets the type of this permission.
         /// </summary>
+        /// <remarks>
+        /// Required.
+        /// </remarks>
         [Required]
-        public PermissionKind Kind
-        {
-            get
-            {
-                PermissionKind value = _Kind;
-                GetKind(ref value);
-                return _Kind = value;
-            }
-
-            set
-            {
-                PermissionKind oldValue = _Kind;
-                SetKind(oldValue, ref value);
-                if (oldValue != value)
-                {
-                    _Kind = value;
-                    OnPropertyChanged();
-                }
-            }
-        }
+        public PermissionKind Kind { get; protected set; }
 
         /// <summary>
-        /// Required
+        /// Gets or sets a value indicating whether the associated user has this permission.
         /// </summary>
+        /// <remarks>
+        /// Required.
+        /// </remarks>
         [Required]
         public bool Value { get; set; }
 
         /// <summary>
-        /// Required, ConcurrencyToken.
+        /// Gets or sets the row version.
         /// </summary>
+        /// <remarks>
+        /// Required, ConcurrencyToken.
+        /// </remarks>
         [ConcurrencyCheck]
         [Required]
         public uint RowVersion { get; set; }
 
-        public void OnSavingChanges()
+        /// <summary>
+        /// Static create function (for use in LINQ queries, etc.)
+        /// </summary>
+        /// <param name="kind">The permission kind.</param>
+        /// <param name="value">The value of this permission.</param>
+        /// <returns>The newly created instance.</returns>
+        public static Permission Create(PermissionKind kind, bool value)
         {
-            RowVersion++;
+            return new Permission(kind, value);
         }
 
-        /*************************************************************************
-         * Navigation properties
-         *************************************************************************/
-
-        public virtual event PropertyChangedEventHandler PropertyChanged;
-
-        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        /// <inheritdoc/>
+        public void OnSavingChanges()
         {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+            RowVersion++;
         }
+
+        partial void Init();
     }
 }
-

+ 27 - 27
Jellyfin.Server.Implementations/JellyfinDb.cs

@@ -1,9 +1,4 @@
 #pragma warning disable CS1591
-#pragma warning disable SA1201 // Constuctors should not follow properties
-#pragma warning disable SA1516 // Elements should be followed by a blank line
-#pragma warning disable SA1623 // Property's documentation should begin with gets or sets
-#pragma warning disable SA1629 // Documentation should end with a period
-#pragma warning disable SA1648 // Inheritdoc should be used with inheriting class
 
 using System.Linq;
 using Jellyfin.Data;
@@ -15,6 +10,19 @@ namespace Jellyfin.Server.Implementations
     /// <inheritdoc/>
     public partial class JellyfinDb : DbContext
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="JellyfinDb"/> class.
+        /// </summary>
+        /// <param name="options">The database context options.</param>
+        public JellyfinDb(DbContextOptions<JellyfinDb> options) : base(options)
+        {
+        }
+
+        /// <summary>
+        /// Gets or sets the default connection string.
+        /// </summary>
+        public static string ConnectionString { get; set; } = @"Data Source=jellyfin.db";
+
         public virtual DbSet<ActivityLog> ActivityLogs { get; set; }
 
         public virtual DbSet<Group> Groups { get; set; }
@@ -69,17 +77,18 @@ namespace Jellyfin.Server.Implementations
         public virtual DbSet<Track> Tracks { get; set; }
         public virtual DbSet<TrackMetadata> TrackMetadata { get; set; }*/
 
-        /// <summary>
-        /// Gets or sets the default connection string.
-        /// </summary>
-        public static string ConnectionString { get; set; } = @"Data Source=jellyfin.db";
-
-        /// <inheritdoc />
-        public JellyfinDb(DbContextOptions<JellyfinDb> options) : base(options)
+        /// <inheritdoc/>
+        public override int SaveChanges()
         {
-        }
+            foreach (var saveEntity in ChangeTracker.Entries()
+                .Where(e => e.State == EntityState.Modified)
+                .OfType<ISavingChanges>())
+            {
+                saveEntity.OnSavingChanges();
+            }
 
-        partial void CustomInit(DbContextOptionsBuilder optionsBuilder);
+            return base.SaveChanges();
+        }
 
         /// <inheritdoc />
         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
@@ -87,9 +96,6 @@ namespace Jellyfin.Server.Implementations
             CustomInit(optionsBuilder);
         }
 
-        partial void OnModelCreatingImpl(ModelBuilder modelBuilder);
-        partial void OnModelCreatedImpl(ModelBuilder modelBuilder);
-
         /// <inheritdoc />
         protected override void OnModelCreating(ModelBuilder modelBuilder)
         {
@@ -109,16 +115,10 @@ namespace Jellyfin.Server.Implementations
             OnModelCreatedImpl(modelBuilder);
         }
 
-        public override int SaveChanges()
-        {
-            foreach (var saveEntity in ChangeTracker.Entries()
-                .Where(e => e.State == EntityState.Modified)
-                .OfType<ISavingChanges>())
-            {
-                saveEntity.OnSavingChanges();
-            }
+        partial void CustomInit(DbContextOptionsBuilder optionsBuilder);
 
-            return base.SaveChanges();
-        }
+        partial void OnModelCreatingImpl(ModelBuilder modelBuilder);
+
+        partial void OnModelCreatedImpl(ModelBuilder modelBuilder);
     }
 }

+ 0 - 1
MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs

@@ -1,6 +1,5 @@
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Model.Entities;
-using User = Jellyfin.Data.Entities.User;
 
 namespace MediaBrowser.Controller.Drawing
 {