The Free Software Media System - Server Backend & API
fix SA1503 for one line if statements
telans98db8f72e01b
diff --git a/DvdLib/Ifo/Dvd.cs b/DvdLib/Ifo/Dvd.csindex ca20baa73f..361319625c 100644--- a/DvdLib/Ifo/Dvd.cs+++ b/DvdLib/Ifo/Dvd.cs@@ -117,12 +117,19 @@ namespace DvdLib.Ifouint chapNum = 1;vtsFs.Seek(baseAddr + offsets[titleNum], SeekOrigin.Begin);var t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum + 1));- if (t == null) continue;+ if (t == null)+ {+ continue;+ }do{t.Chapters.Add(new Chapter(vtsRead.ReadUInt16(), vtsRead.ReadUInt16(), chapNum));- if (titleNum + 1 < numTitles && vtsFs.Position == (baseAddr + offsets[titleNum + 1])) break;+ if (titleNum + 1 < numTitles && vtsFs.Position == (baseAddr + offsets[titleNum + 1]))+ {+ break;+ }+chapNum++;}while (vtsFs.Position < (baseAddr + endaddr));@@ -147,7 +154,10 @@ namespace DvdLib.Ifouint vtsPgcOffset = vtsRead.ReadUInt32();var t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum));- if (t != null) t.AddPgc(vtsRead, startByte + vtsPgcOffset, entryPgc, pgcNum);+ if (t != null)+ {+ t.AddPgc(vtsRead, startByte + vtsPgcOffset, entryPgc, pgcNum);+ }}}}diff --git a/DvdLib/Ifo/DvdTime.cs b/DvdLib/Ifo/DvdTime.csindex 978af90c2e..d231406106 100644--- a/DvdLib/Ifo/DvdTime.cs+++ b/DvdLib/Ifo/DvdTime.cs@@ -15,8 +15,14 @@ namespace DvdLib.IfoSecond = GetBCDValue(data[2]);Frames = GetBCDValue((byte)(data[3] & 0x3F));- if ((data[3] & 0x80) != 0) FrameRate = 30;- else if ((data[3] & 0x40) != 0) FrameRate = 25;+ if ((data[3] & 0x80) != 0)+ {+ FrameRate = 30;+ }+ else if ((data[3] & 0x40) != 0)+ {+ FrameRate = 25;+ }}private static byte GetBCDValue(byte data)diff --git a/DvdLib/Ifo/ProgramChain.cs b/DvdLib/Ifo/ProgramChain.csindex 8048f4bbd6..83c0051b90 100644--- a/DvdLib/Ifo/ProgramChain.cs+++ b/DvdLib/Ifo/ProgramChain.cs@@ -75,8 +75,15 @@ namespace DvdLib.IfoStillTime = br.ReadByte();byte pbMode = br.ReadByte();- if (pbMode == 0) PlaybackMode = ProgramPlaybackMode.Sequential;- else PlaybackMode = ((pbMode & 0x80) == 0) ? ProgramPlaybackMode.Random : ProgramPlaybackMode.Shuffle;+ if (pbMode == 0)+ {+ PlaybackMode = ProgramPlaybackMode.Sequential;+ }+ else+ {+ PlaybackMode = ((pbMode & 0x80) == 0) ? ProgramPlaybackMode.Random : ProgramPlaybackMode.Shuffle;+ }+ProgramCount = (uint)(pbMode & 0x7F);Palette = br.ReadBytes(64);diff --git a/DvdLib/Ifo/Title.cs b/DvdLib/Ifo/Title.csindex 4af3af754a..29a0b95c72 100644--- a/DvdLib/Ifo/Title.cs+++ b/DvdLib/Ifo/Title.cs@@ -59,7 +59,10 @@ namespace DvdLib.Ifovar pgc = new ProgramChain(pgcNum);pgc.ParseHeader(br);ProgramChains.Add(pgc);- if (entryPgc) EntryProgramChain = pgc;+ if (entryPgc)+ {+ EntryProgramChain = pgc;+ }br.BaseStream.Seek(curPos, SeekOrigin.Begin);}diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.csindex 240c8a7d98..512589e4d7 100644--- a/Emby.Dlna/PlayTo/PlayToManager.cs+++ b/Emby.Dlna/PlayTo/PlayToManager.cs@@ -78,9 +78,15 @@ namespace Emby.Dlna.PlayTovar info = e.Argument;- if (!info.Headers.TryGetValue("USN", out string usn)) usn = string.Empty;+ if (!info.Headers.TryGetValue("USN", out string usn))+ {+ usn = string.Empty;+ }- if (!info.Headers.TryGetValue("NT", out string nt)) nt = string.Empty;+ if (!info.Headers.TryGetValue("NT", out string nt))+ {+ nt = string.Empty;+ }string location = info.Location.ToString();diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.csindex 6e5389ad4f..a6390b1ef2 100644--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs@@ -2775,22 +2775,85 @@ namespace Emby.Server.Implementations.Dataprivate string FixUnicodeChars(string buffer){- if (buffer.IndexOf('\u2013') > -1) buffer = buffer.Replace('\u2013', '-'); // en dash- if (buffer.IndexOf('\u2014') > -1) buffer = buffer.Replace('\u2014', '-'); // em dash- if (buffer.IndexOf('\u2015') > -1) buffer = buffer.Replace('\u2015', '-'); // horizontal bar- if (buffer.IndexOf('\u2017') > -1) buffer = buffer.Replace('\u2017', '_'); // double low line- if (buffer.IndexOf('\u2018') > -1) buffer = buffer.Replace('\u2018', '\''); // left single quotation mark- if (buffer.IndexOf('\u2019') > -1) buffer = buffer.Replace('\u2019', '\''); // right single quotation mark- if (buffer.IndexOf('\u201a') > -1) buffer = buffer.Replace('\u201a', ','); // single low-9 quotation mark- if (buffer.IndexOf('\u201b') > -1) buffer = buffer.Replace('\u201b', '\''); // single high-reversed-9 quotation mark- if (buffer.IndexOf('\u201c') > -1) buffer = buffer.Replace('\u201c', '\"'); // left double quotation mark- if (buffer.IndexOf('\u201d') > -1) buffer = buffer.Replace('\u201d', '\"'); // right double quotation mark- if (buffer.IndexOf('\u201e') > -1) buffer = buffer.Replace('\u201e', '\"'); // double low-9 quotation mark- if (buffer.IndexOf('\u2026') > -1) buffer = buffer.Replace("\u2026", "..."); // horizontal ellipsis- if (buffer.IndexOf('\u2032') > -1) buffer = buffer.Replace('\u2032', '\''); // prime- if (buffer.IndexOf('\u2033') > -1) buffer = buffer.Replace('\u2033', '\"'); // double prime- if (buffer.IndexOf('\u0060') > -1) buffer = buffer.Replace('\u0060', '\''); // grave accent- if (buffer.IndexOf('\u00B4') > -1) buffer = buffer.Replace('\u00B4', '\''); // acute accent+ if (buffer.IndexOf('\u2013') > -1)+ {+ buffer = buffer.Replace('\u2013', '-'); // en dash+ }++ if (buffer.IndexOf('\u2014') > -1)+ {+ buffer = buffer.Replace('\u2014', '-'); // em dash+ }++ if (buffer.IndexOf('\u2015') > -1)+ {+ buffer = buffer.Replace('\u2015', '-'); // horizontal bar+ }++ if (buffer.IndexOf('\u2017') > -1)+ {+ buffer = buffer.Replace('\u2017', '_'); // double low line+ }++ if (buffer.IndexOf('\u2018') > -1)+ {+ buffer = buffer.Replace('\u2018', '\''); // left single quotation mark+ }++ if (buffer.IndexOf('\u2019') > -1)+ {+ buffer = buffer.Replace('\u2019', '\''); // right single quotation mark+ }++ if (buffer.IndexOf('\u201a') > -1)+ {+ buffer = buffer.Replace('\u201a', ','); // single low-9 quotation mark+ }++ if (buffer.IndexOf('\u201b') > -1)+ {+ buffer = buffer.Replace('\u201b', '\''); // single high-reversed-9 quotation mark+ }++ if (buffer.IndexOf('\u201c') > -1)+ {+ buffer = buffer.Replace('\u201c', '\"'); // left double quotation mark+ }++ if (buffer.IndexOf('\u201d') > -1)+ {+ buffer = buffer.Replace('\u201d', '\"'); // right double quotation mark+ }++ if (buffer.IndexOf('\u201e') > -1)+ {+ buffer = buffer.Replace('\u201e', '\"'); // double low-9 quotation mark+ }++ if (buffer.IndexOf('\u2026') > -1)+ {+ buffer = buffer.Replace("\u2026", "..."); // horizontal ellipsis+ }++ if (buffer.IndexOf('\u2032') > -1)+ {+ buffer = buffer.Replace('\u2032', '\''); // prime+ }++ if (buffer.IndexOf('\u2033') > -1)+ {+ buffer = buffer.Replace('\u2033', '\"'); // double prime+ }++ if (buffer.IndexOf('\u0060') > -1)+ {+ buffer = buffer.Replace('\u0060', '\''); // grave accent+ }++ if (buffer.IndexOf('\u00B4') > -1)+ {+ buffer = buffer.Replace('\u00B4', '\''); // acute accent+ }return buffer;}diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.csindex db9d240281..2e2488e6ec 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs@@ -201,7 +201,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerunvar index = line.IndexOf("Channel", StringComparison.OrdinalIgnoreCase);var name = line.Substring(0, index - 1);var currentChannel = line.Substring(index + 7);- if (currentChannel != "none") { status = LiveTvTunerStatus.LiveTv; } else { status = LiveTvTunerStatus.Available; }+ if (currentChannel != "none")+ {+ status = LiveTvTunerStatus.LiveTv;+ }+ else+ {+ status = LiveTvTunerStatus.Available;+ }tuners.Add(new LiveTvTunerInfo{diff --git a/Emby.Server.Implementations/Net/UdpSocket.cs b/Emby.Server.Implementations/Net/UdpSocket.csindex 848f82d855..b51c034460 100644--- a/Emby.Server.Implementations/Net/UdpSocket.cs+++ b/Emby.Server.Implementations/Net/UdpSocket.cs@@ -37,7 +37,10 @@ namespace Emby.Server.Implementations.Netpublic UdpSocket(Socket socket, int localPort, IPAddress ip){- if (socket == null) throw new ArgumentNullException(nameof(socket));+ if (socket == null)+ {+ throw new ArgumentNullException(nameof(socket));+ }_socket = socket;_localPort = localPort;@@ -103,7 +106,10 @@ namespace Emby.Server.Implementations.Netpublic UdpSocket(Socket socket, IPEndPoint endPoint){- if (socket == null) throw new ArgumentNullException(nameof(socket));+ if (socket == null)+ {+ throw new ArgumentNullException(nameof(socket));+ }_socket = socket;_socket.Connect(endPoint);diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.csindex ac816ccd93..5dd1af4b87 100644--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs@@ -539,13 +539,21 @@ namespace Emby.Server.Implementations.Playlistsprivate static string UnEscape(string content){- if (content == null) return content;+ if (content == null)+ {+ return content;+ }+return content.Replace("&", "&").Replace("'", "'").Replace(""", "\"").Replace(">", ">").Replace("<", "<");}private static string Escape(string content){- if (content == null) return null;+ if (content == null)+ {+ return null;+ }+return content.Replace("&", "&").Replace("'", "'").Replace("\"", """).Replace(">", ">").Replace("<", "<");}diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.csindex b84e471401..857df591a1 100644--- a/Emby.Server.Implementations/Services/ServiceController.cs+++ b/Emby.Server.Implementations/Services/ServiceController.cs@@ -144,7 +144,10 @@ namespace Emby.Server.Implementations.Servicesvar yieldedWildcardMatches = RestPath.GetFirstMatchWildCardHashKeys(matchUsingPathParts);foreach (var potentialHashMatch in yieldedWildcardMatches){- if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches)) continue;+ if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))+ {+ continue;+ }var bestScore = -1;RestPath bestMatch = null;diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.csindex 606f2a2405..18d7ab46e7 100644--- a/Emby.Server.Implementations/Services/ServiceExec.cs+++ b/Emby.Server.Implementations/Services/ServiceExec.cs@@ -63,7 +63,10 @@ namespace Emby.Server.Implementations.Services{foreach (var actionCtx in actions){- if (execMap.ContainsKey(actionCtx.Id)) continue;+ if (execMap.ContainsKey(actionCtx.Id))+ {+ continue;+ }execMap[actionCtx.Id] = actionCtx;}diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.csindex 14ae126a33..eb07441893 100644--- a/Emby.Server.Implementations/Services/ServicePath.cs+++ b/Emby.Server.Implementations/Services/ServicePath.cs@@ -124,7 +124,10 @@ namespace Emby.Server.Implementations.Servicesvar hasSeparators = new List<bool>();foreach (var component in this.restPath.Split(PathSeperatorChar)){- if (string.IsNullOrEmpty(component)) continue;+ if (string.IsNullOrEmpty(component))+ {+ continue;+ }if (component.IndexOf(VariablePrefix, StringComparison.OrdinalIgnoreCase) != -1&& component.IndexOf(ComponentSeperator) != -1)diff --git a/Jellyfin.Data/Entities/Artwork.cs b/Jellyfin.Data/Entities/Artwork.csindex df071e477b..6ed32eac33 100644--- a/Jellyfin.Data/Entities/Artwork.cs+++ b/Jellyfin.Data/Entities/Artwork.cs@@ -32,17 +32,28 @@ namespace Jellyfin.Data.Entities/// <param name="_personrole1"></param>public Artwork(string path, Enums.ArtKind kind, Metadata _metadata0, PersonRole _personrole1){- if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));+ if (string.IsNullOrEmpty(path))+ {+ throw new ArgumentNullException(nameof(path));+ }+this.Path = path;this.Kind = kind;- if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));+ if (_metadata0 == null)+ {+ throw new ArgumentNullException(nameof(_metadata0));+ }+_metadata0.Artwork.Add(this);- if (_personrole1 == null) throw new ArgumentNullException(nameof(_personrole1));- _personrole1.Artwork = this;+ if (_personrole1 == null)+ {+ throw new ArgumentNullException(nameof(_personrole1));+ }+ _personrole1.Artwork = this;Init();}diff --git a/Jellyfin.Data/Entities/BookMetadata.cs b/Jellyfin.Data/Entities/BookMetadata.csindex dc71463719..df43090d3d 100644--- a/Jellyfin.Data/Entities/BookMetadata.cs+++ b/Jellyfin.Data/Entities/BookMetadata.cs@@ -34,13 +34,25 @@ namespace Jellyfin.Data.Entities/// <param name="_book0"></param>public BookMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Book _book0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_book0 == null) throw new ArgumentNullException(nameof(_book0));+ if (_book0 == null)+ {+ throw new ArgumentNullException(nameof(_book0));+ }+_book0.BookMetadata.Add(this);this.Publishers = new HashSet<Company>();diff --git a/Jellyfin.Data/Entities/Chapter.cs b/Jellyfin.Data/Entities/Chapter.csindex 960853e151..4575cdb4d7 100644--- a/Jellyfin.Data/Entities/Chapter.cs+++ b/Jellyfin.Data/Entities/Chapter.cs@@ -32,12 +32,20 @@ namespace Jellyfin.Data.Entities/// <param name="_release0"></param>public Chapter(string language, long timestart, Release _release0){- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;this.TimeStart = timestart;- if (_release0 == null) throw new ArgumentNullException(nameof(_release0));+ if (_release0 == null)+ {+ throw new ArgumentNullException(nameof(_release0));+ }+_release0.Chapters.Add(this);diff --git a/Jellyfin.Data/Entities/CollectionItem.cs b/Jellyfin.Data/Entities/CollectionItem.csindex 08b0e99f41..d879806ee6 100644--- a/Jellyfin.Data/Entities/CollectionItem.cs+++ b/Jellyfin.Data/Entities/CollectionItem.cs@@ -38,15 +38,26 @@ namespace Jellyfin.Data.Entities// NOTE: This class has one-to-one associations with CollectionItem.// One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.- if (_collection0 == null) throw new ArgumentNullException(nameof(_collection0));+ if (_collection0 == null)+ {+ throw new ArgumentNullException(nameof(_collection0));+ }+_collection0.CollectionItem.Add(this);- if (_collectionitem1 == null) throw new ArgumentNullException(nameof(_collectionitem1));+ if (_collectionitem1 == null)+ {+ throw new ArgumentNullException(nameof(_collectionitem1));+ }+_collectionitem1.Next = this;- if (_collectionitem2 == null) throw new ArgumentNullException(nameof(_collectionitem2));- _collectionitem2.Previous = this;+ if (_collectionitem2 == null)+ {+ throw new ArgumentNullException(nameof(_collectionitem2));+ }+ _collectionitem2.Previous = this;Init();}diff --git a/Jellyfin.Data/Entities/Company.cs b/Jellyfin.Data/Entities/Company.csindex 2ac7bcfe5f..e905a17daf 100644--- a/Jellyfin.Data/Entities/Company.cs+++ b/Jellyfin.Data/Entities/Company.cs@@ -37,19 +37,39 @@ namespace Jellyfin.Data.Entities/// <param name="_company4"></param>public Company(MovieMetadata _moviemetadata0, SeriesMetadata _seriesmetadata1, MusicAlbumMetadata _musicalbummetadata2, BookMetadata _bookmetadata3, Company _company4){- if (_moviemetadata0 == null) throw new ArgumentNullException(nameof(_moviemetadata0));+ if (_moviemetadata0 == null)+ {+ throw new ArgumentNullException(nameof(_moviemetadata0));+ }+_moviemetadata0.Studios.Add(this);- if (_seriesmetadata1 == null) throw new ArgumentNullException(nameof(_seriesmetadata1));+ if (_seriesmetadata1 == null)+ {+ throw new ArgumentNullException(nameof(_seriesmetadata1));+ }+_seriesmetadata1.Networks.Add(this);- if (_musicalbummetadata2 == null) throw new ArgumentNullException(nameof(_musicalbummetadata2));+ if (_musicalbummetadata2 == null)+ {+ throw new ArgumentNullException(nameof(_musicalbummetadata2));+ }+_musicalbummetadata2.Labels.Add(this);- if (_bookmetadata3 == null) throw new ArgumentNullException(nameof(_bookmetadata3));+ if (_bookmetadata3 == null)+ {+ throw new ArgumentNullException(nameof(_bookmetadata3));+ }+_bookmetadata3.Publishers.Add(this);- if (_company4 == null) throw new ArgumentNullException(nameof(_company4));+ if (_company4 == null)+ {+ throw new ArgumentNullException(nameof(_company4));+ }+_company4.Parent = this;this.CompanyMetadata = new HashSet<CompanyMetadata>();diff --git a/Jellyfin.Data/Entities/CompanyMetadata.cs b/Jellyfin.Data/Entities/CompanyMetadata.csindex 12f2133104..e75349cf2a 100644--- a/Jellyfin.Data/Entities/CompanyMetadata.cs+++ b/Jellyfin.Data/Entities/CompanyMetadata.cs@@ -31,15 +31,26 @@ namespace Jellyfin.Data.Entities/// <param name="_company0"></param>public CompanyMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Company _company0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_company0 == null) throw new ArgumentNullException(nameof(_company0));- _company0.CompanyMetadata.Add(this);+ if (_company0 == null)+ {+ throw new ArgumentNullException(nameof(_company0));+ }+ _company0.CompanyMetadata.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/CustomItemMetadata.cs b/Jellyfin.Data/Entities/CustomItemMetadata.csindex dd66c8f832..965ed731f9 100644--- a/Jellyfin.Data/Entities/CustomItemMetadata.cs+++ b/Jellyfin.Data/Entities/CustomItemMetadata.cs@@ -30,15 +30,26 @@ namespace Jellyfin.Data.Entities/// <param name="_customitem0"></param>public CustomItemMetadata(string title, string language, DateTime dateadded, DateTime datemodified, CustomItem _customitem0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_customitem0 == null) throw new ArgumentNullException(nameof(_customitem0));- _customitem0.CustomItemMetadata.Add(this);+ if (_customitem0 == null)+ {+ throw new ArgumentNullException(nameof(_customitem0));+ }+ _customitem0.CustomItemMetadata.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/Episode.cs b/Jellyfin.Data/Entities/Episode.csindex 69106ab79d..57fbf894bf 100644--- a/Jellyfin.Data/Entities/Episode.cs+++ b/Jellyfin.Data/Entities/Episode.cs@@ -42,7 +42,11 @@ namespace Jellyfin.Data.Entitiesthis.UrlId = urlid;- if (_season0 == null) throw new ArgumentNullException(nameof(_season0));+ if (_season0 == null)+ {+ throw new ArgumentNullException(nameof(_season0));+ }+_season0.Episodes.Add(this);this.Releases = new HashSet<Release>();diff --git a/Jellyfin.Data/Entities/EpisodeMetadata.cs b/Jellyfin.Data/Entities/EpisodeMetadata.csindex b17e4aa19f..9a21fd50f0 100644--- a/Jellyfin.Data/Entities/EpisodeMetadata.cs+++ b/Jellyfin.Data/Entities/EpisodeMetadata.cs@@ -31,15 +31,26 @@ namespace Jellyfin.Data.Entities/// <param name="_episode0"></param>public EpisodeMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Episode _episode0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_episode0 == null) throw new ArgumentNullException(nameof(_episode0));- _episode0.EpisodeMetadata.Add(this);+ if (_episode0 == null)+ {+ throw new ArgumentNullException(nameof(_episode0));+ }+ _episode0.EpisodeMetadata.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/Genre.cs b/Jellyfin.Data/Entities/Genre.csindex 9b2264921c..24e6815d80 100644--- a/Jellyfin.Data/Entities/Genre.cs+++ b/Jellyfin.Data/Entities/Genre.cs@@ -31,12 +31,19 @@ namespace Jellyfin.Data.Entities/// <param name="_metadata0"></param>public Genre(string name, Metadata _metadata0){- if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));+ if (string.IsNullOrEmpty(name))+ {+ throw new ArgumentNullException(nameof(name));+ }+this.Name = name;- if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));- _metadata0.Genres.Add(this);+ if (_metadata0 == null)+ {+ throw new ArgumentNullException(nameof(_metadata0));+ }+ _metadata0.Genres.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/Library.cs b/Jellyfin.Data/Entities/Library.csindex ff94b93f04..d935e43b14 100644--- a/Jellyfin.Data/Entities/Library.cs+++ b/Jellyfin.Data/Entities/Library.cs@@ -30,9 +30,12 @@ namespace Jellyfin.Data.Entities/// <param name="name"></param>public Library(string name){- if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));- this.Name = name;+ if (string.IsNullOrEmpty(name))+ {+ throw new ArgumentNullException(nameof(name));+ }+ this.Name = name;Init();}diff --git a/Jellyfin.Data/Entities/LibraryRoot.cs b/Jellyfin.Data/Entities/LibraryRoot.csindex a6f3e49c9d..9695ed638d 100644--- a/Jellyfin.Data/Entities/LibraryRoot.cs+++ b/Jellyfin.Data/Entities/LibraryRoot.cs@@ -30,9 +30,12 @@ namespace Jellyfin.Data.Entities/// <param name="path">Absolute Path.</param>public LibraryRoot(string path){- if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));- this.Path = path;+ if (string.IsNullOrEmpty(path))+ {+ throw new ArgumentNullException(nameof(path));+ }+ this.Path = path;Init();}diff --git a/Jellyfin.Data/Entities/MediaFile.cs b/Jellyfin.Data/Entities/MediaFile.csindex 5d9448d41e..7382cda95b 100644--- a/Jellyfin.Data/Entities/MediaFile.cs+++ b/Jellyfin.Data/Entities/MediaFile.cs@@ -35,12 +35,20 @@ namespace Jellyfin.Data.Entities/// <param name="_release0"></param>public MediaFile(string path, Enums.MediaFileKind kind, Release _release0){- if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));+ if (string.IsNullOrEmpty(path))+ {+ throw new ArgumentNullException(nameof(path));+ }+this.Path = path;this.Kind = kind;- if (_release0 == null) throw new ArgumentNullException(nameof(_release0));+ if (_release0 == null)+ {+ throw new ArgumentNullException(nameof(_release0));+ }+_release0.MediaFiles.Add(this);this.MediaFileStreams = new HashSet<MediaFileStream>();diff --git a/Jellyfin.Data/Entities/MediaFileStream.cs b/Jellyfin.Data/Entities/MediaFileStream.csindex c018c0cbf9..977fd54e19 100644--- a/Jellyfin.Data/Entities/MediaFileStream.cs+++ b/Jellyfin.Data/Entities/MediaFileStream.cs@@ -33,9 +33,12 @@ namespace Jellyfin.Data.Entities{this.StreamNumber = streamnumber;- if (_mediafile0 == null) throw new ArgumentNullException(nameof(_mediafile0));- _mediafile0.MediaFileStreams.Add(this);+ if (_mediafile0 == null)+ {+ throw new ArgumentNullException(nameof(_mediafile0));+ }+ _mediafile0.MediaFileStreams.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/Metadata.cs b/Jellyfin.Data/Entities/Metadata.csindex 8446c30b2f..a4ac6dc540 100644--- a/Jellyfin.Data/Entities/Metadata.cs+++ b/Jellyfin.Data/Entities/Metadata.cs@@ -30,10 +30,18 @@ namespace Jellyfin.Data.Entities/// <param name="language">ISO-639-3 3-character language codes.</param>protected Metadata(string title, string language, DateTime dateadded, DateTime datemodified){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;this.PersonRoles = new HashSet<PersonRole>();diff --git a/Jellyfin.Data/Entities/MetadataProvider.cs b/Jellyfin.Data/Entities/MetadataProvider.csindex ae22ccfeb1..e93ea97d62 100644--- a/Jellyfin.Data/Entities/MetadataProvider.cs+++ b/Jellyfin.Data/Entities/MetadataProvider.cs@@ -30,9 +30,12 @@ namespace Jellyfin.Data.Entities/// <param name="name"></param>public MetadataProvider(string name){- if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));- this.Name = name;+ if (string.IsNullOrEmpty(name))+ {+ throw new ArgumentNullException(nameof(name));+ }+ this.Name = name;Init();}diff --git a/Jellyfin.Data/Entities/MetadataProviderId.cs b/Jellyfin.Data/Entities/MetadataProviderId.csindex 30683ced3b..68f139436a 100644--- a/Jellyfin.Data/Entities/MetadataProviderId.cs+++ b/Jellyfin.Data/Entities/MetadataProviderId.cs@@ -40,21 +40,40 @@ namespace Jellyfin.Data.Entities// NOTE: This class has one-to-one associations with MetadataProviderId.// One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.- if (string.IsNullOrEmpty(providerid)) throw new ArgumentNullException(nameof(providerid));+ if (string.IsNullOrEmpty(providerid))+ {+ throw new ArgumentNullException(nameof(providerid));+ }+this.ProviderId = providerid;- if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));+ if (_metadata0 == null)+ {+ throw new ArgumentNullException(nameof(_metadata0));+ }+_metadata0.Sources.Add(this);- if (_person1 == null) throw new ArgumentNullException(nameof(_person1));+ if (_person1 == null)+ {+ throw new ArgumentNullException(nameof(_person1));+ }+_person1.Sources.Add(this);- if (_personrole2 == null) throw new ArgumentNullException(nameof(_personrole2));+ if (_personrole2 == null)+ {+ throw new ArgumentNullException(nameof(_personrole2));+ }+_personrole2.Sources.Add(this);- if (_ratingsource3 == null) throw new ArgumentNullException(nameof(_ratingsource3));- _ratingsource3.Source = this;+ if (_ratingsource3 == null)+ {+ throw new ArgumentNullException(nameof(_ratingsource3));+ }+ _ratingsource3.Source = this;Init();}diff --git a/Jellyfin.Data/Entities/MovieMetadata.cs b/Jellyfin.Data/Entities/MovieMetadata.csindex 4fda88e8e2..cbcb78e374 100644--- a/Jellyfin.Data/Entities/MovieMetadata.cs+++ b/Jellyfin.Data/Entities/MovieMetadata.cs@@ -35,13 +35,25 @@ namespace Jellyfin.Data.Entities/// <param name="_movie0"></param>public MovieMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Movie _movie0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_movie0 == null) throw new ArgumentNullException(nameof(_movie0));+ if (_movie0 == null)+ {+ throw new ArgumentNullException(nameof(_movie0));+ }+_movie0.MovieMetadata.Add(this);this.Studios = new HashSet<Company>();diff --git a/Jellyfin.Data/Entities/MusicAlbumMetadata.cs b/Jellyfin.Data/Entities/MusicAlbumMetadata.csindex a5056adc01..bfcbebbe8a 100644--- a/Jellyfin.Data/Entities/MusicAlbumMetadata.cs+++ b/Jellyfin.Data/Entities/MusicAlbumMetadata.cs@@ -35,13 +35,25 @@ namespace Jellyfin.Data.Entities/// <param name="_musicalbum0"></param>public MusicAlbumMetadata(string title, string language, DateTime dateadded, DateTime datemodified, MusicAlbum _musicalbum0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_musicalbum0 == null) throw new ArgumentNullException(nameof(_musicalbum0));+ if (_musicalbum0 == null)+ {+ throw new ArgumentNullException(nameof(_musicalbum0));+ }+_musicalbum0.MusicAlbumMetadata.Add(this);this.Labels = new HashSet<Company>();diff --git a/Jellyfin.Data/Entities/Person.cs b/Jellyfin.Data/Entities/Person.csindex 206fe77097..b6d91ea869 100644--- a/Jellyfin.Data/Entities/Person.cs+++ b/Jellyfin.Data/Entities/Person.cs@@ -36,7 +36,11 @@ namespace Jellyfin.Data.Entities{this.UrlId = urlid;- if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));+ if (string.IsNullOrEmpty(name))+ {+ throw new ArgumentNullException(nameof(name));+ }+this.Name = name;this.Sources = new HashSet<MetadataProviderId>();diff --git a/Jellyfin.Data/Entities/PersonRole.cs b/Jellyfin.Data/Entities/PersonRole.csindex 928eb74aee..2dd5f116fc 100644--- a/Jellyfin.Data/Entities/PersonRole.cs+++ b/Jellyfin.Data/Entities/PersonRole.cs@@ -42,7 +42,11 @@ namespace Jellyfin.Data.Entitiesthis.Type = type;- if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));+ if (_metadata0 == null)+ {+ throw new ArgumentNullException(nameof(_metadata0));+ }+_metadata0.PersonRoles.Add(this);this.Sources = new HashSet<MetadataProviderId>();diff --git a/Jellyfin.Data/Entities/PhotoMetadata.cs b/Jellyfin.Data/Entities/PhotoMetadata.csindex 4a0b07ff83..b5aec7229e 100644--- a/Jellyfin.Data/Entities/PhotoMetadata.cs+++ b/Jellyfin.Data/Entities/PhotoMetadata.cs@@ -31,15 +31,26 @@ namespace Jellyfin.Data.Entities/// <param name="_photo0"></param>public PhotoMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Photo _photo0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_photo0 == null) throw new ArgumentNullException(nameof(_photo0));- _photo0.PhotoMetadata.Add(this);+ if (_photo0 == null)+ {+ throw new ArgumentNullException(nameof(_photo0));+ }+ _photo0.PhotoMetadata.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/ProviderMapping.cs b/Jellyfin.Data/Entities/ProviderMapping.csindex 4125eabcd6..c53e3bf408 100644--- a/Jellyfin.Data/Entities/ProviderMapping.cs+++ b/Jellyfin.Data/Entities/ProviderMapping.cs@@ -34,15 +34,26 @@ namespace Jellyfin.Data.Entities/// <param name="_group1"></param>public ProviderMapping(string providername, string providersecrets, string providerdata, User _user0, Group _group1){- if (string.IsNullOrEmpty(providername)) throw new ArgumentNullException(nameof(providername));+ if (string.IsNullOrEmpty(providername))+ {+ throw new ArgumentNullException(nameof(providername));+ }+this.ProviderName = providername;- if (string.IsNullOrEmpty(providersecrets)) throw new ArgumentNullException(nameof(providersecrets));+ if (string.IsNullOrEmpty(providersecrets))+ {+ throw new ArgumentNullException(nameof(providersecrets));+ }+this.ProviderSecrets = providersecrets;- if (string.IsNullOrEmpty(providerdata)) throw new ArgumentNullException(nameof(providerdata));- this.ProviderData = providerdata;+ if (string.IsNullOrEmpty(providerdata))+ {+ throw new ArgumentNullException(nameof(providerdata));+ }+ this.ProviderData = providerdata;Init();}diff --git a/Jellyfin.Data/Entities/Rating.cs b/Jellyfin.Data/Entities/Rating.csindex e00d5297db..49a0d502d2 100644--- a/Jellyfin.Data/Entities/Rating.cs+++ b/Jellyfin.Data/Entities/Rating.cs@@ -33,9 +33,12 @@ namespace Jellyfin.Data.Entities{this.Value = value;- if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));- _metadata0.Ratings.Add(this);+ if (_metadata0 == null)+ {+ throw new ArgumentNullException(nameof(_metadata0));+ }+ _metadata0.Ratings.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/RatingSource.cs b/Jellyfin.Data/Entities/RatingSource.csindex 941f53e52a..b62d8b4443 100644--- a/Jellyfin.Data/Entities/RatingSource.cs+++ b/Jellyfin.Data/Entities/RatingSource.cs@@ -39,9 +39,12 @@ namespace Jellyfin.Data.Entitiesthis.MinimumValue = minimumvalue;- if (_rating0 == null) throw new ArgumentNullException(nameof(_rating0));- _rating0.RatingType = this;+ if (_rating0 == null)+ {+ throw new ArgumentNullException(nameof(_rating0));+ }+ _rating0.RatingType = this;Init();}diff --git a/Jellyfin.Data/Entities/Release.cs b/Jellyfin.Data/Entities/Release.csindex e08c04545c..1e9faa5a1d 100644--- a/Jellyfin.Data/Entities/Release.cs+++ b/Jellyfin.Data/Entities/Release.cs@@ -40,25 +40,53 @@ namespace Jellyfin.Data.Entities/// <param name="_photo5"></param>public Release(string name, Movie _movie0, Episode _episode1, Track _track2, CustomItem _customitem3, Book _book4, Photo _photo5){- if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));+ if (string.IsNullOrEmpty(name))+ {+ throw new ArgumentNullException(nameof(name));+ }+this.Name = name;- if (_movie0 == null) throw new ArgumentNullException(nameof(_movie0));+ if (_movie0 == null)+ {+ throw new ArgumentNullException(nameof(_movie0));+ }+_movie0.Releases.Add(this);- if (_episode1 == null) throw new ArgumentNullException(nameof(_episode1));+ if (_episode1 == null)+ {+ throw new ArgumentNullException(nameof(_episode1));+ }+_episode1.Releases.Add(this);- if (_track2 == null) throw new ArgumentNullException(nameof(_track2));+ if (_track2 == null)+ {+ throw new ArgumentNullException(nameof(_track2));+ }+_track2.Releases.Add(this);- if (_customitem3 == null) throw new ArgumentNullException(nameof(_customitem3));+ if (_customitem3 == null)+ {+ throw new ArgumentNullException(nameof(_customitem3));+ }+_customitem3.Releases.Add(this);- if (_book4 == null) throw new ArgumentNullException(nameof(_book4));+ if (_book4 == null)+ {+ throw new ArgumentNullException(nameof(_book4));+ }+_book4.Releases.Add(this);- if (_photo5 == null) throw new ArgumentNullException(nameof(_photo5));+ if (_photo5 == null)+ {+ throw new ArgumentNullException(nameof(_photo5));+ }+_photo5.Releases.Add(this);this.MediaFiles = new HashSet<MediaFile>();diff --git a/Jellyfin.Data/Entities/Season.cs b/Jellyfin.Data/Entities/Season.csindex d71f4b522b..4b1e785758 100644--- a/Jellyfin.Data/Entities/Season.cs+++ b/Jellyfin.Data/Entities/Season.cs@@ -42,7 +42,11 @@ namespace Jellyfin.Data.Entitiesthis.UrlId = urlid;- if (_series0 == null) throw new ArgumentNullException(nameof(_series0));+ if (_series0 == null)+ {+ throw new ArgumentNullException(nameof(_series0));+ }+_series0.Seasons.Add(this);this.SeasonMetadata = new HashSet<SeasonMetadata>();diff --git a/Jellyfin.Data/Entities/SeasonMetadata.cs b/Jellyfin.Data/Entities/SeasonMetadata.csindex 8c72d99528..10d19875e6 100644--- a/Jellyfin.Data/Entities/SeasonMetadata.cs+++ b/Jellyfin.Data/Entities/SeasonMetadata.cs@@ -32,15 +32,26 @@ namespace Jellyfin.Data.Entities/// <param name="_season0"></param>public SeasonMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Season _season0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_season0 == null) throw new ArgumentNullException(nameof(_season0));- _season0.SeasonMetadata.Add(this);+ if (_season0 == null)+ {+ throw new ArgumentNullException(nameof(_season0));+ }+ _season0.SeasonMetadata.Add(this);Init();}diff --git a/Jellyfin.Data/Entities/SeriesMetadata.cs b/Jellyfin.Data/Entities/SeriesMetadata.csindex 2c04ef12fd..16eb59315e 100644--- a/Jellyfin.Data/Entities/SeriesMetadata.cs+++ b/Jellyfin.Data/Entities/SeriesMetadata.cs@@ -35,13 +35,25 @@ namespace Jellyfin.Data.Entities/// <param name="_series0"></param>public SeriesMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Series _series0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_series0 == null) throw new ArgumentNullException(nameof(_series0));+ if (_series0 == null)+ {+ throw new ArgumentNullException(nameof(_series0));+ }+_series0.SeriesMetadata.Add(this);this.Networks = new HashSet<Company>();diff --git a/Jellyfin.Data/Entities/Track.cs b/Jellyfin.Data/Entities/Track.csindex e13a53d382..b7d7b5873b 100644--- a/Jellyfin.Data/Entities/Track.cs+++ b/Jellyfin.Data/Entities/Track.cs@@ -42,7 +42,11 @@ namespace Jellyfin.Data.Entitiesthis.UrlId = urlid;- if (_musicalbum0 == null) throw new ArgumentNullException(nameof(_musicalbum0));+ if (_musicalbum0 == null)+ {+ throw new ArgumentNullException(nameof(_musicalbum0));+ }+_musicalbum0.Tracks.Add(this);this.Releases = new HashSet<Release>();diff --git a/Jellyfin.Data/Entities/TrackMetadata.cs b/Jellyfin.Data/Entities/TrackMetadata.csindex 55f4a38e01..23e1219aaf 100644--- a/Jellyfin.Data/Entities/TrackMetadata.cs+++ b/Jellyfin.Data/Entities/TrackMetadata.cs@@ -31,15 +31,26 @@ namespace Jellyfin.Data.Entities/// <param name="_track0"></param>public TrackMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Track _track0){- if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));+ if (string.IsNullOrEmpty(title))+ {+ throw new ArgumentNullException(nameof(title));+ }+this.Title = title;- if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));+ if (string.IsNullOrEmpty(language))+ {+ throw new ArgumentNullException(nameof(language));+ }+this.Language = language;- if (_track0 == null) throw new ArgumentNullException(nameof(_track0));- _track0.TrackMetadata.Add(this);+ if (_track0 == null)+ {+ throw new ArgumentNullException(nameof(_track0));+ }+ _track0.TrackMetadata.Add(this);Init();}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex 7b833c36b0..2ad1c717cf 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -690,7 +690,10 @@ namespace MediaBrowser.Controller.Entities/// <returns>System.String.</returns>protected virtual string CreateSortName(){- if (Name == null) return null; // some items may not have name filled in properly+ if (Name == null)+ {+ return null; // some items may not have name filled in properly+ }if (!EnableAlphaNumericSorting){diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.csindex 731c6d6674..2e5dcc4c53 100644--- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs+++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs@@ -252,7 +252,11 @@ namespace MediaBrowser.Controller.Library{if (args != null){- if (args.Path == null && Path == null) return true;+ if (args.Path == null && Path == null)+ {+ return true;+ }+return args.Path != null && BaseItem.FileSystem.AreEqual(args.Path, Path);}diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.csindex ba807ab85b..190abaa058 100644--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs@@ -1065,23 +1065,43 @@ namespace MediaBrowser.MediaEncoding.Probing// These support mulitple values, but for now we only store the first.var mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id"));- if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMARTISTID"));+ if (mb == null)+ {+ mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMARTISTID"));+ }+audio.SetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id"));- if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ARTISTID"));+ if (mb == null)+ {+ mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ARTISTID"));+ }+audio.SetProviderId(MetadataProvider.MusicBrainzArtist, mb);mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Id"));- if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMID"));+ if (mb == null)+ {+ mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMID"));+ }+audio.SetProviderId(MetadataProvider.MusicBrainzAlbum, mb);mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id"));- if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASEGROUPID"));+ if (mb == null)+ {+ mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASEGROUPID"));+ }+audio.SetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Track Id"));- if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASETRACKID"));+ if (mb == null)+ {+ mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASETRACKID"));+ }+audio.SetProviderId(MetadataProvider.MusicBrainzTrack, mb);}diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.csindex 06bd244763..cfe862f5a9 100644--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs@@ -384,7 +384,10 @@ namespace MediaBrowser.Model.DlnaaudioCodecProfiles.Add(i);}- if (audioCodecProfiles.Count >= 1) break;+ if (audioCodecProfiles.Count >= 1)+ {+ break;+ }}var audioTranscodingConditions = new List<ProfileCondition>();diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.csindex d8ee79d0d0..7a488005ea 100644--- a/MediaBrowser.Model/Entities/MediaStream.cs+++ b/MediaBrowser.Model/Entities/MediaStream.cs@@ -421,7 +421,10 @@ namespace MediaBrowser.Model.Entities{get{- if (Type != MediaStreamType.Subtitle) return false;+ if (Type != MediaStreamType.Subtitle)+ {+ return false;+ }if (string.IsNullOrEmpty(Codec) && !IsExternal){diff --git a/MediaBrowser.Model/Services/RouteAttribute.cs b/MediaBrowser.Model/Services/RouteAttribute.csindex 162576aa7e..f8bf511124 100644--- a/MediaBrowser.Model/Services/RouteAttribute.cs+++ b/MediaBrowser.Model/Services/RouteAttribute.cs@@ -128,9 +128,21 @@ namespace MediaBrowser.Model.Servicespublic override bool Equals(object obj){- if (ReferenceEquals(null, obj)) return false;- if (ReferenceEquals(this, obj)) return true;- if (obj.GetType() != this.GetType()) return false;+ if (ReferenceEquals(null, obj))+ {+ return false;+ }++ if (ReferenceEquals(this, obj))+ {+ return true;+ }++ if (obj.GetType() != this.GetType())+ {+ return false;+ }+return Equals((RouteAttribute)obj);}diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.csindex cf55466023..82ed65ebb6 100644--- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs+++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs@@ -113,7 +113,10 @@ namespace MediaBrowser.Providers.Managerforeach (var imageType in images){- if (!IsEnabled(savedOptions, imageType, item)) continue;+ if (!IsEnabled(savedOptions, imageType, item))+ {+ continue;+ }if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType))){diff --git a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.csindex 15f0a9004b..71799efa46 100644--- a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs+++ b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs@@ -159,7 +159,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets{var mainResult = await FetchMainResult(tmdbId, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);- if (mainResult == null) return;+ if (mainResult == null)+ {+ return;+ }var dataFilePath = GetDataFilePath(_config.ApplicationPaths, tmdbId, preferredMetadataLanguage);diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.csindex 1961e8bff9..1c4cf1da13 100644--- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs+++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs@@ -194,7 +194,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies{var mainResult = await FetchMainResult(id, true, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);- if (mainResult == null) return;+ if (mainResult == null)+ {+ return;+ }var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage);diff --git a/RSSDP/DeviceAvailableEventArgs.cs b/RSSDP/DeviceAvailableEventArgs.csindex 9c57471ca0..b7d22a7df5 100644--- a/RSSDP/DeviceAvailableEventArgs.cs+++ b/RSSDP/DeviceAvailableEventArgs.cs@@ -22,7 +22,10 @@ namespace Rssdp/// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered){- if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));+ if (discoveredDevice == null)+ {+ throw new ArgumentNullException(nameof(discoveredDevice));+ }_DiscoveredDevice = discoveredDevice;_IsNewlyDiscovered = isNewlyDiscovered;diff --git a/RSSDP/DeviceEventArgs.cs b/RSSDP/DeviceEventArgs.csindex b124527ca9..2455ccbfad 100644--- a/RSSDP/DeviceEventArgs.cs+++ b/RSSDP/DeviceEventArgs.cs@@ -16,7 +16,10 @@ namespace Rssdp/// <exception cref="ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>public DeviceEventArgs(SsdpDevice device){- if (device == null) throw new ArgumentNullException(nameof(device));+ if (device == null)+ {+ throw new ArgumentNullException(nameof(device));+ }_Device = device;}diff --git a/RSSDP/DeviceUnavailableEventArgs.cs b/RSSDP/DeviceUnavailableEventArgs.csindex cee59268dc..94248f39f2 100644--- a/RSSDP/DeviceUnavailableEventArgs.cs+++ b/RSSDP/DeviceUnavailableEventArgs.cs@@ -19,7 +19,10 @@ namespace Rssdp/// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired){- if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));+ if (discoveredDevice == null)+ {+ throw new ArgumentNullException(nameof(discoveredDevice));+ }_DiscoveredDevice = discoveredDevice;_Expired = expired;diff --git a/RSSDP/DisposableManagedObjectBase.cs b/RSSDP/DisposableManagedObjectBase.csindex befa4ccffb..628572b17a 100644--- a/RSSDP/DisposableManagedObjectBase.cs+++ b/RSSDP/DisposableManagedObjectBase.cs@@ -23,7 +23,10 @@ namespace Rssdp.Infrastructure/// <seealso cref="Dispose()"/>protected virtual void ThrowIfDisposed(){- if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().FullName);+ if (this.IsDisposed)+ {+ throw new ObjectDisposedException(this.GetType().FullName);+ }}/// <summary>diff --git a/RSSDP/HttpParserBase.cs b/RSSDP/HttpParserBase.csindex ff97b6db84..058bfbf555 100644--- a/RSSDP/HttpParserBase.cs+++ b/RSSDP/HttpParserBase.cs@@ -31,9 +31,20 @@ namespace Rssdp.Infrastructure[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Honestly, it's fine. MemoryStream doesn't mind.")]protected virtual void Parse(T message, System.Net.Http.Headers.HttpHeaders headers, string data){- if (data == null) throw new ArgumentNullException(nameof(data));- if (data.Length == 0) throw new ArgumentException("data cannot be an empty string.", nameof(data));- if (!LineTerminators.Any(data.Contains)) throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data));+ if (data == null)+ {+ throw new ArgumentNullException(nameof(data));+ }++ if (data.Length == 0)+ {+ throw new ArgumentException("data cannot be an empty string.", nameof(data));+ }++ if (!LineTerminators.Any(data.Contains))+ {+ throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data));+ }using (var retVal = new ByteArrayContent(Array.Empty<byte>())){@@ -66,10 +77,16 @@ namespace Rssdp.Infrastructure/// <returns>A <see cref="Version"/> object containing the parsed version data.</returns>protected Version ParseHttpVersion(string versionData){- if (versionData == null) throw new ArgumentNullException(nameof(versionData));+ if (versionData == null)+ {+ throw new ArgumentNullException(nameof(versionData));+ }var versionSeparatorIndex = versionData.IndexOf('/');- if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length) throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData));+ if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length)+ {+ throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData));+ }return Version.Parse(versionData.Substring(versionSeparatorIndex + 1));}diff --git a/RSSDP/HttpRequestParser.cs b/RSSDP/HttpRequestParser.csindex 31f042791d..6b27fc4df4 100644--- a/RSSDP/HttpRequestParser.cs+++ b/RSSDP/HttpRequestParser.cs@@ -45,11 +45,21 @@ namespace Rssdp.Infrastructure/// <param name="message">Either a <see cref="HttpResponseMessage"/> or <see cref="HttpRequestMessage"/> to assign the parsed values to.</param>protected override void ParseStatusLine(string data, HttpRequestMessage message){- if (data == null) throw new ArgumentNullException(nameof(data));- if (message == null) throw new ArgumentNullException(nameof(message));+ if (data == null)+ {+ throw new ArgumentNullException(nameof(data));+ }++ if (message == null)+ {+ throw new ArgumentNullException(nameof(message));+ }var parts = data.Split(' ');- if (parts.Length < 2) throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));+ if (parts.Length < 2)+ {+ throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));+ }message.Method = new HttpMethod(parts[0].Trim());Uri requestUri;diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.csindex 02c548d724..0337b3e360 100644--- a/RSSDP/HttpResponseParser.cs+++ b/RSSDP/HttpResponseParser.cs@@ -57,11 +57,21 @@ namespace Rssdp.Infrastructure/// <param name="message">Either a <see cref="HttpResponseMessage"/> or <see cref="HttpRequestMessage"/> to assign the parsed values to.</param>protected override void ParseStatusLine(string data, HttpResponseMessage message){- if (data == null) throw new ArgumentNullException(nameof(data));- if (message == null) throw new ArgumentNullException(nameof(message));+ if (data == null)+ {+ throw new ArgumentNullException(nameof(data));+ }++ if (message == null)+ {+ throw new ArgumentNullException(nameof(message));+ }var parts = data.Split(' ');- if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));+ if (parts.Length < 2)+ {+ throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));+ }message.Version = ParseHttpVersion(parts[0].Trim());diff --git a/RSSDP/IEnumerableExtensions.cs b/RSSDP/IEnumerableExtensions.csindex 371454893d..1f0daad3e1 100644--- a/RSSDP/IEnumerableExtensions.cs+++ b/RSSDP/IEnumerableExtensions.cs@@ -8,8 +8,15 @@ namespace Rssdp.Infrastructure{public static IEnumerable<T> SelectManyRecursive<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector){- if (source == null) throw new ArgumentNullException(nameof(source));- if (selector == null) throw new ArgumentNullException(nameof(selector));+ if (source == null)+ {+ throw new ArgumentNullException(nameof(source));+ }++ if (selector == null)+ {+ throw new ArgumentNullException(nameof(selector));+ }return !source.Any() ? source :source.Concat(diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.csindex 12ecf24f3b..31ca90424f 100644--- a/RSSDP/SsdpCommunicationsServer.cs+++ b/RSSDP/SsdpCommunicationsServer.cs@@ -80,8 +80,15 @@ namespace Rssdp.Infrastructure/// <exception cref="ArgumentOutOfRangeException">The <paramref name="multicastTimeToLive"/> argument is less than or equal to zero.</exception>public SsdpCommunicationsServer(ISocketFactory socketFactory, int localPort, int multicastTimeToLive, INetworkManager networkManager, ILogger logger, bool enableMultiSocketBinding){- if (socketFactory == null) throw new ArgumentNullException(nameof(socketFactory));- if (multicastTimeToLive <= 0) throw new ArgumentOutOfRangeException(nameof(multicastTimeToLive), "multicastTimeToLive must be greater than zero.");+ if (socketFactory == null)+ {+ throw new ArgumentNullException(nameof(socketFactory));+ }++ if (multicastTimeToLive <= 0)+ {+ throw new ArgumentOutOfRangeException(nameof(multicastTimeToLive), "multicastTimeToLive must be greater than zero.");+ }_BroadcastListenSocketSynchroniser = new object();_SendSocketSynchroniser = new object();@@ -151,7 +158,10 @@ namespace Rssdp.Infrastructure/// </summary>public async Task SendMessage(byte[] messageData, IPEndPoint destination, IPAddress fromLocalIpAddress, CancellationToken cancellationToken){- if (messageData == null) throw new ArgumentNullException(nameof(messageData));+ if (messageData == null)+ {+ throw new ArgumentNullException(nameof(messageData));+ }ThrowIfDisposed();@@ -234,7 +244,10 @@ namespace Rssdp.Infrastructure/// </summary>public async Task SendMulticastMessage(string message, int sendCount, IPAddress fromLocalIpAddress, CancellationToken cancellationToken){- if (message == null) throw new ArgumentNullException(nameof(message));+ if (message == null)+ {+ throw new ArgumentNullException(nameof(message));+ }byte[] messageData = Encoding.UTF8.GetBytes(message);diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.csindex 5b7d782b52..42f95862c5 100644--- a/RSSDP/SsdpDevice.cs+++ b/RSSDP/SsdpDevice.cs@@ -259,9 +259,20 @@ namespace Rssdp/// <seealso cref="DeviceAdded"/>public void AddDevice(SsdpEmbeddedDevice device){- if (device == null) throw new ArgumentNullException(nameof(device));- if (device.RootDevice != null && device.RootDevice != this.ToRootDevice()) throw new InvalidOperationException("This device is already associated with a different root device (has been added as a child in another branch).");- if (device == this) throw new InvalidOperationException("Can't add device to itself.");+ if (device == null)+ {+ throw new ArgumentNullException(nameof(device));+ }++ if (device.RootDevice != null && device.RootDevice != this.ToRootDevice())+ {+ throw new InvalidOperationException("This device is already associated with a different root device (has been added as a child in another branch).");+ }++ if (device == this)+ {+ throw new InvalidOperationException("Can't add device to itself.");+ }bool wasAdded = false;lock (_Devices)@@ -287,7 +298,10 @@ namespace Rssdp/// <seealso cref="DeviceRemoved"/>public void RemoveDevice(SsdpEmbeddedDevice device){- if (device == null) throw new ArgumentNullException(nameof(device));+ if (device == null)+ {+ throw new ArgumentNullException(nameof(device));+ }bool wasRemoved = false;lock (_Devices)diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.csindex b117c0b1e6..a774ee23c8 100644--- a/RSSDP/SsdpDeviceLocator.cs+++ b/RSSDP/SsdpDeviceLocator.cs@@ -27,7 +27,10 @@ namespace Rssdp.Infrastructure/// </summary>public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer){- if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));+ if (communicationsServer == null)+ {+ throw new ArgumentNullException(nameof(communicationsServer));+ }_CommunicationsServer = communicationsServer;_CommunicationsServer.ResponseReceived += CommsServer_ResponseReceived;@@ -140,10 +143,25 @@ namespace Rssdp.Infrastructureprivate Task SearchAsync(string searchTarget, TimeSpan searchWaitTime, CancellationToken cancellationToken){- if (searchTarget == null) throw new ArgumentNullException(nameof(searchTarget));- if (searchTarget.Length == 0) throw new ArgumentException("searchTarget cannot be an empty string.", nameof(searchTarget));- if (searchWaitTime.TotalSeconds < 0) throw new ArgumentException("searchWaitTime must be a positive time.");- if (searchWaitTime.TotalSeconds > 0 && searchWaitTime.TotalSeconds <= 1) throw new ArgumentException("searchWaitTime must be zero (if you are not using the result and relying entirely in the events), or greater than one second.");+ if (searchTarget == null)+ {+ throw new ArgumentNullException(nameof(searchTarget));+ }++ if (searchTarget.Length == 0)+ {+ throw new ArgumentException("searchTarget cannot be an empty string.", nameof(searchTarget));+ }++ if (searchWaitTime.TotalSeconds < 0)+ {+ throw new ArgumentException("searchWaitTime must be a positive time.");+ }++ if (searchWaitTime.TotalSeconds > 0 && searchWaitTime.TotalSeconds <= 1)+ {+ throw new ArgumentException("searchWaitTime must be zero (if you are not using the result and relying entirely in the events), or greater than one second.");+ }ThrowIfDisposed();@@ -192,7 +210,10 @@ namespace Rssdp.Infrastructure/// <seealso cref="DeviceAvailable"/>protected virtual void OnDeviceAvailable(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress localIpAddress){- if (this.IsDisposed) return;+ if (this.IsDisposed)+ {+ return;+ }var handlers = this.DeviceAvailable;if (handlers != null)@@ -210,11 +231,16 @@ namespace Rssdp.Infrastructure/// <seealso cref="DeviceUnavailable"/>protected virtual void OnDeviceUnavailable(DiscoveredSsdpDevice device, bool expired){- if (this.IsDisposed) return;+ if (this.IsDisposed)+ {+ return;+ }var handlers = this.DeviceUnavailable;if (handlers != null)+ {handlers(this, new DeviceUnavailableEventArgs(device, expired));+ }}/// <summary>@@ -281,7 +307,10 @@ namespace Rssdp.Infrastructureprivate void DeviceFound(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress localIpAddress){- if (!NotificationTypeMatchesFilter(device)) return;+ if (!NotificationTypeMatchesFilter(device))+ {+ return;+ }OnDeviceAvailable(device, isNewDevice, localIpAddress);}@@ -318,7 +347,10 @@ namespace Rssdp.Infrastructureprivate void ProcessSearchResponseMessage(HttpResponseMessage message, IPAddress localIpAddress){- if (!message.IsSuccessStatusCode) return;+ if (!message.IsSuccessStatusCode)+ {+ return;+ }var location = GetFirstHeaderUriValue("Location", message);if (location != null)@@ -339,13 +371,20 @@ namespace Rssdp.Infrastructureprivate void ProcessNotificationMessage(HttpRequestMessage message, IPAddress localIpAddress){- if (String.Compare(message.Method.Method, "Notify", StringComparison.OrdinalIgnoreCase) != 0) return;+ if (String.Compare(message.Method.Method, "Notify", StringComparison.OrdinalIgnoreCase) != 0)+ {+ return;+ }var notificationType = GetFirstHeaderStringValue("NTS", message);if (String.Compare(notificationType, SsdpConstants.SsdpKeepAliveNotification, StringComparison.OrdinalIgnoreCase) == 0)+ {ProcessAliveNotification(message, localIpAddress);+ }else if (String.Compare(notificationType, SsdpConstants.SsdpByeByeNotification, StringComparison.OrdinalIgnoreCase) == 0)+ {ProcessByeByeNotification(message);+ }}private void ProcessAliveNotification(HttpRequestMessage message, IPAddress localIpAddress)@@ -454,14 +493,20 @@ namespace Rssdp.Infrastructureprivate TimeSpan CacheAgeFromHeader(System.Net.Http.Headers.CacheControlHeaderValue headerValue){- if (headerValue == null) return TimeSpan.Zero;+ if (headerValue == null)+ {+ return TimeSpan.Zero;+ }return (TimeSpan)(headerValue.MaxAge ?? headerValue.SharedMaxAge ?? TimeSpan.Zero);}private void RemoveExpiredDevicesFromCache(){- if (this.IsDisposed) return;+ if (this.IsDisposed)+ {+ return;+ }DiscoveredSsdpDevice[] expiredDevices = null;lock (_Devices)@@ -470,7 +515,10 @@ namespace Rssdp.Infrastructureforeach (var device in expiredDevices){- if (this.IsDisposed) return;+ if (this.IsDisposed)+ {+ return;+ }_Devices.Remove(device);}@@ -481,7 +529,10 @@ namespace Rssdp.Infrastructure// problems.foreach (var expiredUsn in (from expiredDevice in expiredDevices select expiredDevice.Usn).Distinct()){- if (this.IsDisposed) return;+ if (this.IsDisposed)+ {+ return;+ }DeviceDied(expiredUsn, true);}@@ -495,7 +546,10 @@ namespace Rssdp.InfrastructureexistingDevices = FindExistingDeviceNotifications(_Devices, deviceUsn);foreach (var existingDevice in existingDevices){- if (this.IsDisposed) return true;+ if (this.IsDisposed)+ {+ return true;+ }_Devices.Remove(existingDevice);}diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.csindex b4cf2fb484..1b64d230dd 100644--- a/RSSDP/SsdpDevicePublisher.cs+++ b/RSSDP/SsdpDevicePublisher.cs@@ -40,12 +40,35 @@ namespace Rssdp.Infrastructurepublic SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, INetworkManager networkManager,string osName, string osVersion, bool sendOnlyMatchedHost){- if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));- if (networkManager == null) throw new ArgumentNullException(nameof(networkManager));- if (osName == null) throw new ArgumentNullException(nameof(osName));- if (osName.Length == 0) throw new ArgumentException("osName cannot be an empty string.", nameof(osName));- if (osVersion == null) throw new ArgumentNullException(nameof(osVersion));- if (osVersion.Length == 0) throw new ArgumentException("osVersion cannot be an empty string.", nameof(osName));+ if (communicationsServer == null)+ {+ throw new ArgumentNullException(nameof(communicationsServer));+ }++ if (networkManager == null)+ {+ throw new ArgumentNullException(nameof(networkManager));+ }++ if (osName == null)+ {+ throw new ArgumentNullException(nameof(osName));+ }++ if (osName.Length == 0)+ {+ throw new ArgumentException("osName cannot be an empty string.", nameof(osName));+ }++ if (osVersion == null)+ {+ throw new ArgumentNullException(nameof(osVersion));+ }++ if (osVersion.Length == 0)+ {+ throw new ArgumentException("osVersion cannot be an empty string.", nameof(osName));+ }_SupportPnpRootDevice = true;_Devices = new List<SsdpRootDevice>();@@ -82,7 +105,10 @@ namespace Rssdp.Infrastructure[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "t", Justification = "Capture task to local variable supresses compiler warning, but task is not really needed.")]public void AddDevice(SsdpRootDevice device){- if (device == null) throw new ArgumentNullException(nameof(device));+ if (device == null)+ {+ throw new ArgumentNullException(nameof(device));+ }ThrowIfDisposed();@@ -115,7 +141,10 @@ namespace Rssdp.Infrastructure/// <exception cref="ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>public async Task RemoveDevice(SsdpRootDevice device){- if (device == null) throw new ArgumentNullException(nameof(device));+ if (device == null)+ {+ throw new ArgumentNullException(nameof(device));+ }bool wasRemoved = false;lock (_Devices)@@ -227,10 +256,15 @@ namespace Rssdp.Infrastructure// return;}- if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0) return;+ if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0)+ {+ return;+ }if (maxWaitInterval > 120)+ {maxWaitInterval = _Random.Next(0, 120);+ }// Do not block synchronously as that may tie up a threadpool thread for several seconds.Task.Delay(_Random.Next(16, (maxWaitInterval * 1000))).ContinueWith((parentTask) =>@@ -240,13 +274,21 @@ namespace Rssdp.Infrastructurelock (_Devices){if (String.Compare(SsdpConstants.SsdpDiscoverAllSTHeader, searchTarget, StringComparison.OrdinalIgnoreCase) == 0)+ {devices = GetAllDevicesAsFlatEnumerable().ToArray();+ }else if (String.Compare(SsdpConstants.UpnpDeviceTypeRootDevice, searchTarget, StringComparison.OrdinalIgnoreCase) == 0 || (this.SupportPnpRootDevice && String.Compare(SsdpConstants.PnpDeviceTypeRootDevice, searchTarget, StringComparison.OrdinalIgnoreCase) == 0))+ {devices = _Devices.ToArray();+ }else if (searchTarget.Trim().StartsWith("uuid:", StringComparison.OrdinalIgnoreCase))+ {devices = (from device in GetAllDevicesAsFlatEnumerable() where String.Compare(device.Uuid, searchTarget.Substring(5), StringComparison.OrdinalIgnoreCase) == 0 select device).ToArray();+ }else if (searchTarget.StartsWith("urn:", StringComparison.OrdinalIgnoreCase))+ {devices = (from device in GetAllDevicesAsFlatEnumerable() where String.Compare(device.FullDeviceType, searchTarget, StringComparison.OrdinalIgnoreCase) == 0 select device).ToArray();+ }}if (devices != null)@@ -382,7 +424,10 @@ namespace Rssdp.Infrastructure{try{- if (IsDisposed) return;+ if (IsDisposed)+ {+ return;+ }// WriteTrace("Begin Sending Alive Notifications For All Devices");@@ -394,7 +439,10 @@ namespace Rssdp.Infrastructureforeach (var device in devices){- if (IsDisposed) return;+ if (IsDisposed)+ {+ return;+ }SendAliveNotifications(device, true, CancellationToken.None);}@@ -547,7 +595,10 @@ namespace Rssdp.Infrastructureprivate void CommsServer_RequestReceived(object sender, RequestReceivedEventArgs e){- if (this.IsDisposed) return;+ if (this.IsDisposed)+ {+ return;+ }if (string.Equals(e.Message.Method.Method, SsdpConstants.MSearchMethod, StringComparison.OrdinalIgnoreCase)){