Use Array.Empty

This commit is contained in:
Patrick Barron 2020-07-04 11:54:25 -04:00
parent 176f25fb98
commit 6d1b00da64
20 changed files with 33 additions and 27 deletions

View File

@ -164,7 +164,7 @@ namespace Emby.Dlna.Profiles
public void AddXmlRootAttribute(string name, string value) public void AddXmlRootAttribute(string name, string value)
{ {
var atts = XmlRootAttributes ?? new XmlAttribute[] { }; var atts = XmlRootAttributes ?? System.Array.Empty<XmlAttribute>();
var list = atts.ToList(); var list = atts.ToList();
list.Add(new XmlAttribute list.Add(new XmlAttribute

View File

@ -28,7 +28,7 @@ namespace Emby.Dlna.Profiles
}, },
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = System.Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -123,7 +123,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = System.Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -72,7 +72,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = System.Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -37,7 +37,7 @@ namespace Emby.Dlna.Profiles
}, },
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = System.Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -1,5 +1,6 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
namespace Emby.Dlna.Profiles namespace Emby.Dlna.Profiles
@ -37,7 +38,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -1,5 +1,6 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
namespace Emby.Dlna.Profiles namespace Emby.Dlna.Profiles
@ -223,7 +224,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -1,5 +1,6 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
namespace Emby.Dlna.Profiles namespace Emby.Dlna.Profiles
@ -223,7 +224,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -1,5 +1,6 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
namespace Emby.Dlna.Profiles namespace Emby.Dlna.Profiles
@ -211,7 +212,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -1,5 +1,6 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
namespace Emby.Dlna.Profiles namespace Emby.Dlna.Profiles
@ -211,7 +212,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new ResponseProfile[] { }; ResponseProfiles = Array.Empty<ResponseProfile>();
} }
} }
} }

View File

@ -125,7 +125,7 @@ namespace MediaBrowser.Api
IncludeItemTypes = request.GetIncludeItemTypes(), IncludeItemTypes = request.GetIncludeItemTypes(),
DtoOptions = new Controller.Dto.DtoOptions DtoOptions = new Controller.Dto.DtoOptions
{ {
Fields = new ItemFields[] { }, Fields = Array.Empty<ItemFields>(),
EnableImages = false, EnableImages = false,
EnableUserData = false EnableUserData = false
}, },

View File

@ -613,7 +613,7 @@ namespace MediaBrowser.Controller.Entities
{ {
if (!IsFileProtocol) if (!IsFileProtocol)
{ {
return new string[] { }; return Array.Empty<string>();
} }
return new[] { Path }; return new[] { Path };

View File

@ -198,7 +198,7 @@ namespace MediaBrowser.Controller.Entities.Movies
public Guid[] GetLibraryFolderIds() public Guid[] GetLibraryFolderIds()
{ {
var expandedFolders = new List<Guid>() { }; var expandedFolders = new List<Guid>();
return FlattenItems(this, expandedFolders) return FlattenItems(this, expandedFolders)
.SelectMany(i => LibraryManager.GetCollectionFolders(i)) .SelectMany(i => LibraryManager.GetCollectionFolders(i))

View File

@ -38,7 +38,7 @@ namespace MediaBrowser.Controller.Library
}; };
} }
return new DayOfWeek[] { }; return Array.Empty<DayOfWeek>();
} }
return null; return null;

View File

@ -41,7 +41,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
var outputStream = new BlurayDiscInfo var outputStream = new BlurayDiscInfo
{ {
MediaStreams = new MediaStream[] { } MediaStreams = Array.Empty<MediaStream>()
}; };
if (playlist == null) if (playlist == null)

View File

@ -1008,7 +1008,7 @@ namespace MediaBrowser.MediaEncoding.Probing
var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist"); var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist");
if (string.IsNullOrWhiteSpace(artist)) if (string.IsNullOrWhiteSpace(artist))
{ {
audio.Artists = new string[] { }; audio.Artists = Array.Empty<string>();
} }
else else
{ {
@ -1031,7 +1031,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (string.IsNullOrWhiteSpace(albumArtist)) if (string.IsNullOrWhiteSpace(albumArtist))
{ {
audio.AlbumArtists = new string[] { }; audio.AlbumArtists = Array.Empty<string>();
} }
else else
{ {

View File

@ -206,7 +206,7 @@ namespace MediaBrowser.Model.Dlna
} }
} }
return new MediaFormatProfile[] { }; return Array.Empty<MediaFormatProfile>();
} }
private MediaFormatProfile ValueOf(string value) private MediaFormatProfile ValueOf(string value)

View File

@ -813,18 +813,18 @@ namespace MediaBrowser.Model.Dlna
{ {
var stream = TargetAudioStream; var stream = TargetAudioStream;
string inputCodec = stream == null ? null : stream.Codec; string inputCodec = stream?.Codec;
if (IsDirectStream) if (IsDirectStream)
{ {
return string.IsNullOrEmpty(inputCodec) ? new string[] { } : new[] { inputCodec }; return string.IsNullOrEmpty(inputCodec) ? Array.Empty<string>() : new[] { inputCodec };
} }
foreach (string codec in AudioCodecs) foreach (string codec in AudioCodecs)
{ {
if (string.Equals(codec, inputCodec, StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, inputCodec, StringComparison.OrdinalIgnoreCase))
{ {
return string.IsNullOrEmpty(codec) ? new string[] { } : new[] { codec }; return string.IsNullOrEmpty(codec) ? Array.Empty<string>() : new[] { codec };
} }
} }
@ -838,18 +838,18 @@ namespace MediaBrowser.Model.Dlna
{ {
var stream = TargetVideoStream; var stream = TargetVideoStream;
string inputCodec = stream == null ? null : stream.Codec; string inputCodec = stream?.Codec;
if (IsDirectStream) if (IsDirectStream)
{ {
return string.IsNullOrEmpty(inputCodec) ? new string[] { } : new[] { inputCodec }; return string.IsNullOrEmpty(inputCodec) ? Array.Empty<string>() : new[] { inputCodec };
} }
foreach (string codec in VideoCodecs) foreach (string codec in VideoCodecs)
{ {
if (string.Equals(codec, inputCodec, StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, inputCodec, StringComparison.OrdinalIgnoreCase))
{ {
return string.IsNullOrEmpty(codec) ? new string[] { } : new[] { codec }; return string.IsNullOrEmpty(codec) ? Array.Empty<string>() : new[] { codec };
} }
} }

View File

@ -1,6 +1,7 @@
#nullable disable #nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Querying namespace MediaBrowser.Model.Querying
@ -54,7 +55,7 @@ namespace MediaBrowser.Model.Querying
public UpcomingEpisodesQuery() public UpcomingEpisodesQuery()
{ {
EnableImageTypes = new ImageType[] { }; EnableImageTypes = Array.Empty<ImageType>();
} }
} }
} }

View File

@ -723,7 +723,7 @@ namespace MediaBrowser.Providers.Manager
userDataList.AddRange(localItem.UserDataList); userDataList.AddRange(localItem.UserDataList);
} }
MergeData(localItem, temp, new MetadataField[] { }, !options.ReplaceAllMetadata, true); MergeData(localItem, temp, Array.Empty<MetadataField>(), !options.ReplaceAllMetadata, true);
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport; refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
// Only one local provider allowed per item // Only one local provider allowed per item
@ -849,7 +849,7 @@ namespace MediaBrowser.Providers.Manager
{ {
result.Provider = provider.Name; result.Provider = provider.Name;
MergeData(result, temp, new MetadataField[] { }, false, false); MergeData(result, temp, Array.Empty<MetadataField>(), false, false);
MergeNewData(temp.Item, id); MergeNewData(temp.Item, id);
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataDownload; refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataDownload;