Merge pull request #2767 from Bond-009/nullable3

Enable nullabe reference types for MediaBrowser.Model
This commit is contained in:
Vasily 2020-06-03 12:26:54 +03:00 committed by GitHub
commit 668e10ceb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
204 changed files with 629 additions and 508 deletions

View File

@ -100,15 +100,13 @@ namespace Emby.Dlna.Ssdp
var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
var args = new GenericEventArgs<UpnpDeviceInfo>
{
Argument = new UpnpDeviceInfo
var args = new GenericEventArgs<UpnpDeviceInfo>(
new UpnpDeviceInfo
{
Location = e.DiscoveredDevice.DescriptionLocation,
Headers = headers,
LocalIpAddress = e.LocalIpAddress
}
};
});
DeviceDiscoveredInternal?.Invoke(this, args);
}
@ -121,14 +119,12 @@ namespace Emby.Dlna.Ssdp
var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
var args = new GenericEventArgs<UpnpDeviceInfo>
{
Argument = new UpnpDeviceInfo
var args = new GenericEventArgs<UpnpDeviceInfo>(
new UpnpDeviceInfo
{
Location = e.DiscoveredDevice.DescriptionLocation,
Headers = headers
}
};
});
DeviceLeft?.Invoke(this, args);
}

View File

@ -114,7 +114,7 @@ namespace Emby.Drawing
=> _transparentImageTypes.Contains(Path.GetExtension(path));
/// <inheritdoc />
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
public async Task<(string path, string? mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
{
ItemImageInfo originalImage = options.Image;
BaseItem item = options.Item;
@ -230,7 +230,7 @@ namespace Emby.Drawing
return ImageFormat.Jpg;
}
private string GetMimeType(ImageFormat format, string path)
private string? GetMimeType(ImageFormat format, string path)
=> format switch
{
ImageFormat.Bmp => MimeTypes.GetMimeType("i.bmp"),

View File

@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.Configuration
ValidateMetadataPath(newConfig);
ValidateSslCertificate(newConfig);
ConfigurationUpdating?.Invoke(this, new GenericEventArgs<ServerConfiguration> { Argument = newConfig });
ConfigurationUpdating?.Invoke(this, new GenericEventArgs<ServerConfiguration>(newConfig));
base.ReplaceConfiguration(newConfiguration);
}

View File

@ -1,3 +1,5 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
@ -129,8 +131,6 @@ namespace Emby.Server.Implementations.Cryptography
_randomNumberGenerator.Dispose();
}
_randomNumberGenerator = null;
_disposed = true;
}
}

View File

@ -62,13 +62,7 @@ namespace Emby.Server.Implementations.Devices
{
_authRepo.UpdateDeviceOptions(deviceId, options);
if (DeviceOptionsUpdated != null)
{
DeviceOptionsUpdated(this, new GenericEventArgs<Tuple<string, DeviceOptions>>()
{
Argument = new Tuple<string, DeviceOptions>(deviceId, options)
});
}
DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, options)));
}
public DeviceOptions GetDeviceOptions(string deviceId)

View File

@ -47,10 +47,11 @@ namespace Emby.Server.Implementations.EntryPoints
}
/// <inheritdoc />
public async Task RunAsync()
public Task RunAsync()
{
_udpServer = new UdpServer(_logger, _appHost, _config);
_udpServer.Start(PortNumber, _cancellationTokenSource.Token);
return Task.CompletedTask;
}
/// <inheritdoc />

View File

@ -521,11 +521,7 @@ namespace Emby.Server.Implementations.Library
SetDefaultAudioAndSubtitleStreamIndexes(item, clone, user);
}
return new Tuple<LiveStreamResponse, IDirectStreamProvider>(new LiveStreamResponse
{
MediaSource = clone
}, liveStream as IDirectStreamProvider);
return new Tuple<LiveStreamResponse, IDirectStreamProvider>(new LiveStreamResponse(clone), liveStream as IDirectStreamProvider);
}
private static void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio)

View File

@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="user">The user.</param>
private void OnUserUpdated(User user)
{
UserUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
UserUpdated?.Invoke(this, new GenericEventArgs<User>(user));
}
/// <summary>
@ -135,7 +135,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="user">The user.</param>
private void OnUserDeleted(User user)
{
UserDeleted?.Invoke(this, new GenericEventArgs<User> { Argument = user });
UserDeleted?.Invoke(this, new GenericEventArgs<User>(user));
}
public NameIdPair[] GetAuthenticationProviders()
@ -751,7 +751,7 @@ namespace Emby.Server.Implementations.Library
_userRepository.CreateUser(user);
EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User> { Argument = user }, _logger);
EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User>(user), _logger);
return user;
}
@ -976,7 +976,7 @@ namespace Emby.Server.Implementations.Library
if (fireEvent)
{
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User>(user));
}
}
@ -1046,7 +1046,7 @@ namespace Emby.Server.Implementations.Library
if (fireEvent)
{
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User>(user));
}
}
}

View File

@ -109,7 +109,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (startDate < now)
{
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo> { Argument = item });
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(item));
return;
}
@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));
if (timer != null)
{
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo> { Argument = timer });
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(timer));
}
}

View File

@ -148,27 +148,18 @@ namespace Emby.Server.Implementations.LiveTv
{
var timerId = e.Argument;
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{
Argument = new TimerEventInfo
{
Id = timerId
}
});
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>(new TimerEventInfo(timerId)));
}
private void OnEmbyTvTimerCreated(object sender, GenericEventArgs<TimerInfo> e)
{
var timer = e.Argument;
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{
Argument = new TimerEventInfo
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>(
new TimerEventInfo(timer.Id)
{
ProgramId = _tvDtoService.GetInternalProgramId(timer.ProgramId),
Id = timer.Id
}
});
ProgramId = _tvDtoService.GetInternalProgramId(timer.ProgramId)
}));
}
public List<NameIdPair> GetTunerHostTypes()
@ -1724,13 +1715,7 @@ namespace Emby.Server.Implementations.LiveTv
if (!(service is EmbyTV.EmbyTV))
{
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{
Argument = new TimerEventInfo
{
Id = id
}
});
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>(new TimerEventInfo(id)));
}
}
@ -1747,13 +1732,7 @@ namespace Emby.Server.Implementations.LiveTv
await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
SeriesTimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{
Argument = new TimerEventInfo
{
Id = id
}
});
SeriesTimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>(new TimerEventInfo(id)));
}
public async Task<TimerInfoDto> GetTimer(string id, CancellationToken cancellationToken)
@ -2072,14 +2051,11 @@ namespace Emby.Server.Implementations.LiveTv
if (!(service is EmbyTV.EmbyTV))
{
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{
Argument = new TimerEventInfo
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>(
new TimerEventInfo(newTimerId)
{
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId),
Id = newTimerId
}
});
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId)
}));
}
}
@ -2104,14 +2080,11 @@ namespace Emby.Server.Implementations.LiveTv
await service.CreateSeriesTimerAsync(info, cancellationToken).ConfigureAwait(false);
}
SeriesTimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{
Argument = new TimerEventInfo
SeriesTimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>(
new TimerEventInfo(newTimerId)
{
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId),
Id = newTimerId
}
});
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId)
}));
}
public async Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken)

View File

@ -153,10 +153,7 @@ namespace Emby.Server.Implementations.Playlists
});
}
return new PlaylistCreationResult
{
Id = playlist.Id.ToString("N", CultureInfo.InvariantCulture)
};
return new PlaylistCreationResult(playlist.Id.ToString("N", CultureInfo.InvariantCulture));
}
finally
{

View File

@ -392,7 +392,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
((TaskManager)TaskManager).OnTaskExecuting(this);
progress.ProgressChanged += progress_ProgressChanged;
progress.ProgressChanged += OnProgressChanged;
TaskCompletionStatus status;
CurrentExecutionStartTime = DateTime.UtcNow;
@ -426,7 +426,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
var startTime = CurrentExecutionStartTime;
var endTime = DateTime.UtcNow;
progress.ProgressChanged -= progress_ProgressChanged;
progress.ProgressChanged -= OnProgressChanged;
CurrentCancellationTokenSource.Dispose();
CurrentCancellationTokenSource = null;
CurrentProgress = null;
@ -439,16 +439,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
void progress_ProgressChanged(object sender, double e)
private void OnProgressChanged(object sender, double e)
{
e = Math.Min(e, 100);
CurrentProgress = e;
TaskProgress?.Invoke(this, new GenericEventArgs<double>
{
Argument = e
});
TaskProgress?.Invoke(this, new GenericEventArgs<double>(e));
}
/// <summary>

View File

@ -240,10 +240,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <param name="task">The task.</param>
internal void OnTaskExecuting(IScheduledTaskWorker task)
{
TaskExecuting?.Invoke(this, new GenericEventArgs<IScheduledTaskWorker>
{
Argument = task
});
TaskExecuting?.Invoke(this, new GenericEventArgs<IScheduledTaskWorker>(task));
}
/// <summary>
@ -253,11 +250,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <param name="result">The result.</param>
internal void OnTaskCompleted(IScheduledTaskWorker task, TaskResult result)
{
TaskCompleted?.Invoke(task, new TaskCompletionEventArgs
{
Result = result,
Task = task
});
TaskCompleted?.Invoke(task, new TaskCompletionEventArgs(task, result));
ExecuteQueuedTasks();
}

View File

@ -456,7 +456,7 @@ namespace Emby.Server.Implementations.Updates
_config.SaveConfiguration();
}
PluginUninstalled?.Invoke(this, new GenericEventArgs<IPlugin> { Argument = plugin });
PluginUninstalled?.Invoke(this, new GenericEventArgs<IPlugin>(plugin));
_applicationHost.NotifyPendingRestart();
}

View File

@ -226,12 +226,7 @@ namespace MediaBrowser.Api
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
private IEnumerable<FileSystemEntryInfo> GetDrives()
{
return _fileSystem.GetDrives().Select(d => new FileSystemEntryInfo
{
Name = d.Name,
Path = d.FullName,
Type = FileSystemEntryType.Directory
});
return _fileSystem.GetDrives().Select(d => new FileSystemEntryInfo(d.Name, d.FullName, FileSystemEntryType.Directory));
}
/// <summary>
@ -261,13 +256,7 @@ namespace MediaBrowser.Api
return request.IncludeDirectories || !isDirectory;
});
return entries.Select(f => new FileSystemEntryInfo
{
Name = f.Name,
Path = f.FullName,
Type = f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File
});
return entries.Select(f => new FileSystemEntryInfo(f.Name, f.FullName, f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File));
}
public object Get(GetParentPath request)

View File

@ -147,9 +147,8 @@ namespace MediaBrowser.Api.Images
{
var item = _libraryManager.GetItemById(request.Id);
var images = await _providerManager.GetAvailableRemoteImages(item, new RemoteImageQuery
var images = await _providerManager.GetAvailableRemoteImages(item, new RemoteImageQuery(request.ProviderName)
{
ProviderName = request.ProviderName,
IncludeAllLanguages = request.IncludeAllLanguages,
IncludeDisabledProviders = true,
ImageType = request.Type

View File

@ -1,10 +1,19 @@
#nullable enable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Controller.LiveTv
{
public class TimerEventInfo
{
public string Id { get; set; }
public Guid ProgramId { get; set; }
public TimerEventInfo(string id)
{
Id = id;
}
public string Id { get; }
public Guid? ProgramId { get; set; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.ApiClient

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Branding

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Channels

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -13,8 +14,11 @@ namespace MediaBrowser.Model.Channels
/// </summary>
/// <value>The fields.</value>
public ItemFields[] Fields { get; set; }
public bool? EnableImages { get; set; }
public int? ImageTypeLimit { get; set; }
public ImageType[] EnableImageTypes { get; set; }
/// <summary>
@ -48,7 +52,9 @@ namespace MediaBrowser.Model.Channels
/// </summary>
/// <value><c>null</c> if [is favorite] contains no value, <c>true</c> if [is favorite]; otherwise, <c>false</c>.</value>
public bool? IsFavorite { get; set; }
public bool? IsRecordingsFolder { get; set; }
public bool RefreshLatestChannelItems { get; set; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
using System;
using System.Xml.Serialization;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Configuration

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -12,12 +13,15 @@ namespace MediaBrowser.Model.Configuration
public string ItemType { get; set; }
public string[] DisabledMetadataSavers { get; set; }
public string[] LocalMetadataReaderOrder { get; set; }
public string[] DisabledMetadataFetchers { get; set; }
public string[] MetadataFetcherOrder { get; set; }
public string[] DisabledImageFetchers { get; set; }
public string[] ImageFetcherOrder { get; set; }
public MetadataOptions()

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Configuration

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Configuration

View File

@ -10,7 +10,7 @@ namespace MediaBrowser.Model.Cryptography
IEnumerable<string> GetSupportedHashMethods();
byte[] ComputeHash(string HashMethod, byte[] bytes, byte[] salt);
byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt);
byte[] ComputeHashWithDefaultMethod(byte[] bytes, byte[] salt);

View File

@ -1,15 +1,19 @@
#nullable disable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Devices
{
public class ContentUploadHistory
{
public string DeviceId { get; set; }
public LocalFileInfo[] FilesUploaded { get; set; }
public ContentUploadHistory()
{
FilesUploaded = new LocalFileInfo[] { };
FilesUploaded = Array.Empty<LocalFileInfo>();
}
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Devices
@ -5,8 +6,11 @@ namespace MediaBrowser.Model.Devices
public class LocalFileInfo
{
public string Name { get; set; }
public string Id { get; set; }
public string Album { get; set; }
public string MimeType { get; set; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -19,12 +20,17 @@ namespace MediaBrowser.Model.Dlna
}
public bool EnableDirectPlay { get; set; }
public bool EnableDirectStream { get; set; }
public bool ForceDirectPlay { get; set; }
public bool ForceDirectStream { get; set; }
public Guid ItemId { get; set; }
public MediaSourceInfo[] MediaSources { get; set; }
public DeviceProfile Profile { get; set; }
/// <summary>

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Model.Dlna
int? height,
int? videoBitDepth,
int? videoBitrate,
string videoProfile,
string? videoProfile,
double? videoLevel,
float? videoFramerate,
int? packetLength,
@ -25,7 +25,7 @@ namespace MediaBrowser.Model.Dlna
int? refFrames,
int? numVideoStreams,
int? numAudioStreams,
string videoCodecTag,
string? videoCodecTag,
bool? isAvc)
{
switch (condition.Property)
@ -103,7 +103,7 @@ namespace MediaBrowser.Model.Dlna
int? audioBitrate,
int? audioSampleRate,
int? audioBitDepth,
string audioProfile,
string? audioProfile,
bool? isSecondaryTrack)
{
switch (condition.Property)
@ -154,7 +154,7 @@ namespace MediaBrowser.Model.Dlna
return false;
}
private static bool IsConditionSatisfied(ProfileCondition condition, string currentValue)
private static bool IsConditionSatisfied(ProfileCondition condition, string? currentValue)
{
if (string.IsNullOrEmpty(currentValue))
{
@ -201,34 +201,6 @@ namespace MediaBrowser.Model.Dlna
return false;
}
private static bool IsConditionSatisfied(ProfileCondition condition, float currentValue)
{
if (currentValue <= 0)
{
// If the value is unknown, it satisfies if not marked as required
return !condition.IsRequired;
}
if (float.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected))
{
switch (condition.Condition)
{
case ProfileConditionType.Equals:
return currentValue.Equals(expected);
case ProfileConditionType.GreaterThanEqual:
return currentValue >= expected;
case ProfileConditionType.LessThanEqual:
return currentValue <= expected;
case ProfileConditionType.NotEquals:
return !currentValue.Equals(expected);
default:
throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition);
}
}
return false;
}
private static bool IsConditionSatisfied(ProfileCondition condition, double? currentValue)
{
if (!currentValue.HasValue)

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -10,6 +11,7 @@ namespace MediaBrowser.Model.Dlna
{
[XmlAttribute("type")]
public DlnaProfileType Type { get; set; }
public ProfileCondition[] Conditions { get; set; }
[XmlAttribute("container")]

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -32,7 +33,10 @@ namespace MediaBrowser.Model.Dlna
DlnaFlags.InteractiveTransferMode |
DlnaFlags.DlnaV15;
string dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}", DlnaMaps.FlagsToString(flagValue));
string dlnaflags = string.Format(
CultureInfo.InvariantCulture,
";DLNA.ORG_FLAGS={0}",
DlnaMaps.FlagsToString(flagValue));
ResponseProfile mediaProfile = _profile.GetImageMediaProfile(container,
width,

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Dlna

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System.Xml.Serialization;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System.Xml.Serialization;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Dlna
@ -5,7 +6,9 @@ namespace MediaBrowser.Model.Dlna
public interface ITranscoderSupport
{
bool CanEncodeToAudioCodec(string codec);
bool CanEncodeToSubtitleCodec(string codec);
bool CanExtractSubtitles(string codec);
}
@ -15,10 +18,12 @@ namespace MediaBrowser.Model.Dlna
{
return true;
}
public bool CanEncodeToSubtitleCodec(string codec)
{
return true;
}
public bool CanExtractSubtitles(string codec)
{
return true;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -21,13 +22,13 @@ namespace MediaBrowser.Model.Dlna
if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
{
MediaFormatProfile? val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { };
return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty<MediaFormatProfile>();
}
if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase))
{
MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { };
return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty<MediaFormatProfile>();
}
if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))
@ -61,18 +62,18 @@ namespace MediaBrowser.Model.Dlna
if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase))
{
MediaFormatProfile? val = ResolveVideo3GPFormat(videoCodec, audioCodec);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { };
return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty<MediaFormatProfile>();
}
if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
return new MediaFormatProfile[] { MediaFormatProfile.OGV };
return new MediaFormatProfile[] { };
return Array.Empty<MediaFormatProfile>();
}
private MediaFormatProfile[] ResolveVideoMPEG2TSFormat(string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType)
{
string suffix = "";
string suffix = string.Empty;
switch (timestampType)
{
@ -92,16 +93,18 @@ namespace MediaBrowser.Model.Dlna
if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
{
var list = new List<MediaFormatProfile>();
list.Add(ValueOf("MPEG_TS_SD_NA" + suffix));
list.Add(ValueOf("MPEG_TS_SD_EU" + suffix));
list.Add(ValueOf("MPEG_TS_SD_KO" + suffix));
var list = new List<MediaFormatProfile>
{
ValueOf("MPEG_TS_SD_NA" + suffix),
ValueOf("MPEG_TS_SD_EU" + suffix),
ValueOf("MPEG_TS_SD_KO" + suffix)
};
if ((timestampType == TransportStreamTimestamp.Valid) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{
list.Add(MediaFormatProfile.MPEG_TS_JP_T);
}
return list.ToArray();
}
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
@ -115,6 +118,7 @@ namespace MediaBrowser.Model.Dlna
{
return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_ISO };
}
return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_T };
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System.Xml.Serialization;
@ -6,18 +7,6 @@ namespace MediaBrowser.Model.Dlna
{
public class ProfileCondition
{
[XmlAttribute("condition")]
public ProfileConditionType Condition { get; set; }
[XmlAttribute("property")]
public ProfileConditionValue Property { get; set; }
[XmlAttribute("value")]
public string Value { get; set; }
[XmlAttribute("isRequired")]
public bool IsRequired { get; set; }
public ProfileCondition()
{
IsRequired = true;
@ -36,5 +25,17 @@ namespace MediaBrowser.Model.Dlna
Value = value;
IsRequired = isRequired;
}
[XmlAttribute("condition")]
public ProfileConditionType Condition { get; set; }
[XmlAttribute("property")]
public ProfileConditionValue Property { get; set; }
[XmlAttribute("value")]
public string Value { get; set; }
[XmlAttribute("isRequired")]
public bool IsRequired { get; set; }
}
}

View File

@ -5,6 +5,7 @@ namespace MediaBrowser.Model.Dlna
public class ResolutionConfiguration
{
public int MaxWidth { get; set; }
public int MaxBitrate { get; set; }
public ResolutionConfiguration(int maxWidth, int maxBitrate)

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -17,7 +18,8 @@ namespace MediaBrowser.Model.Dlna
new ResolutionConfiguration(3840, 35000000)
};
public static ResolutionOptions Normalize(int? inputBitrate,
public static ResolutionOptions Normalize(
int? inputBitrate,
int? unused1,
int? unused2,
int outputBitrate,
@ -83,6 +85,7 @@ namespace MediaBrowser.Model.Dlna
{
return .5;
}
return 1;
}

View File

@ -5,6 +5,7 @@ namespace MediaBrowser.Model.Dlna
public class ResolutionOptions
{
public int? MaxWidth { get; set; }
public int? MaxHeight { get; set; }
}
}

View File

@ -1,5 +1,7 @@
#nullable disable
#pragma warning disable CS1591
using System;
using System.Xml.Serialization;
namespace MediaBrowser.Model.Dlna
@ -28,7 +30,7 @@ namespace MediaBrowser.Model.Dlna
public ResponseProfile()
{
Conditions = new ProfileCondition[] { };
Conditions = Array.Empty<ProfileCondition>();
}
public string[] GetContainers()

View File

@ -34,9 +34,9 @@ namespace MediaBrowser.Model.Dlna
public SearchCriteria(string search)
{
if (string.IsNullOrEmpty(search))
if (search.Length == 0)
{
throw new ArgumentNullException(nameof(search));
throw new ArgumentException("String can't be empty.", nameof(search));
}
SearchType = SearchType.Unknown;
@ -48,11 +48,10 @@ namespace MediaBrowser.Model.Dlna
if (subFactors.Length == 3)
{
if (string.Equals("upnp:class", subFactors[0], StringComparison.OrdinalIgnoreCase) &&
(string.Equals("=", subFactors[1]) || string.Equals("derivedfrom", subFactors[1], StringComparison.OrdinalIgnoreCase)))
(string.Equals("=", subFactors[1], StringComparison.Ordinal) || string.Equals("derivedfrom", subFactors[1], StringComparison.OrdinalIgnoreCase)))
{
if (string.Equals("\"object.item.imageItem\"", subFactors[2]) || string.Equals("\"object.item.imageItem.photo\"", subFactors[2], StringComparison.OrdinalIgnoreCase))
if (string.Equals("\"object.item.imageItem\"", subFactors[2], StringComparison.Ordinal) || string.Equals("\"object.item.imageItem.photo\"", subFactors[2], StringComparison.OrdinalIgnoreCase))
{
SearchType = SearchType.Image;
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -339,6 +340,7 @@ namespace MediaBrowser.Model.Dlna
{
transcodeReasons.Add(transcodeReason.Value);
}
all = false;
break;
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Dlna
@ -5,13 +6,21 @@ namespace MediaBrowser.Model.Dlna
public class SubtitleStreamInfo
{
public string Url { get; set; }
public string Language { get; set; }
public string Name { get; set; }
public bool IsForced { get; set; }
public string Format { get; set; }
public string DisplayTitle { get; set; }
public int Index { get; set; }
public SubtitleDeliveryMethod DeliveryMethod { get; set; }
public bool IsExternalUrl { get; set; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System.Xml.Serialization;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -9,8 +10,11 @@ namespace MediaBrowser.Model.Dlna
public class UpnpDeviceInfo
{
public Uri Location { get; set; }
public Dictionary<string, string> Headers { get; set; }
public IPAddress LocalIpAddress { get; set; }
public int LocalPort { get; set; }
}
}

View File

@ -8,6 +8,7 @@ namespace MediaBrowser.Model.Dlna
public class VideoOptions : AudioOptions
{
public int? AudioStreamIndex { get; set; }
public int? SubtitleStreamIndex { get; set; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System.Xml.Serialization;

View File

@ -16,7 +16,8 @@ namespace MediaBrowser.Model.Drawing
/// <param name="maxWidth">A max fixed width, if desired.</param>
/// <param name="maxHeight">A max fixed height, if desired.</param>
/// <returns>A new size object.</returns>
public static ImageDimensions Resize(ImageDimensions size,
public static ImageDimensions Resize(
ImageDimensions size,
int width,
int height,
int maxWidth,
@ -62,7 +63,7 @@ namespace MediaBrowser.Model.Drawing
/// <param name="currentHeight">Height of the current.</param>
/// <param name="currentWidth">Width of the current.</param>
/// <param name="newHeight">The new height.</param>
/// <returns>the new width</returns>
/// <returns>The new width.</returns>
private static int GetNewWidth(int currentHeight, int currentWidth, int newHeight)
=> Convert.ToInt32((double)newHeight / currentHeight * currentWidth);

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
using System.Text.Json.Serialization;
namespace MediaBrowser.Model.Dto

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Dto

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Dto

View File

@ -1,3 +1,4 @@
#nullable disable
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Dto
@ -20,9 +21,9 @@ namespace MediaBrowser.Model.Dto
public int? ImageIndex { get; set; }
/// <summary>
/// The image tag
/// Gets or sets the image tag.
/// </summary>
public string ImageTag;
public string ImageTag { get; set; }
/// <summary>
/// Gets or sets the path.

View File

@ -1,3 +1,4 @@
#nullable disable
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
@ -8,6 +9,14 @@ namespace MediaBrowser.Model.Dto
/// </summary>
public class ImageOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageOptions" /> class.
/// </summary>
public ImageOptions()
{
EnableImageEnhancers = true;
}
/// <summary>
/// Gets or sets the type of the image.
/// </summary>
@ -98,13 +107,5 @@ namespace MediaBrowser.Model.Dto
/// </summary>
/// <value>The color of the background.</value>
public string BackgroundColor { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ImageOptions" /> class.
/// </summary>
public ImageOptions()
{
EnableImageEnhancers = true;
}
}
}

View File

@ -1,20 +0,0 @@
namespace MediaBrowser.Model.Dto
{
/// <summary>
/// Class ItemIndex.
/// </summary>
public class ItemIndex
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the item count.
/// </summary>
/// <value>The item count.</value>
public int ItemCount { get; set; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Dto
@ -6,7 +7,6 @@ namespace MediaBrowser.Model.Dto
{
public NameValuePair()
{
}
public NameValuePair(string name, string value)

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
using System;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Users;

View File

@ -1,3 +1,4 @@
#nullable disable
using System;
namespace MediaBrowser.Model.Dto

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
using System.Collections.Generic;
namespace MediaBrowser.Model.Entities

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace MediaBrowser.Model.Entities
{
/// <summary>
/// Since BaseItem and DTOBaseItem both have ProviderIds, this interface helps avoid code repition by using extension methods.
/// Since BaseItem and DTOBaseItem both have ProviderIds, this interface helps avoid code repetition by using extension methods.
/// </summary>
public interface IHasProviderIds
{

View File

@ -5,15 +5,29 @@ using System;
namespace MediaBrowser.Model.Entities
{
/// <summary>
/// Class LibraryUpdateInfo
/// Class LibraryUpdateInfo.
/// </summary>
public class LibraryUpdateInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="LibraryUpdateInfo"/> class.
/// </summary>
public LibraryUpdateInfo()
{
FoldersAddedTo = Array.Empty<string>();
FoldersRemovedFrom = Array.Empty<string>();
ItemsAdded = Array.Empty<string>();
ItemsRemoved = Array.Empty<string>();
ItemsUpdated = Array.Empty<string>();
CollectionFolders = Array.Empty<string>();
}
/// <summary>
/// Gets or sets the folders added to.
/// </summary>
/// <value>The folders added to.</value>
public string[] FoldersAddedTo { get; set; }
/// <summary>
/// Gets or sets the folders removed from.
/// </summary>
@ -41,18 +55,5 @@ namespace MediaBrowser.Model.Entities
public string[] CollectionFolders { get; set; }
public bool IsEmpty => FoldersAddedTo.Length == 0 && FoldersRemovedFrom.Length == 0 && ItemsAdded.Length == 0 && ItemsRemoved.Length == 0 && ItemsUpdated.Length == 0 && CollectionFolders.Length == 0;
/// <summary>
/// Initializes a new instance of the <see cref="LibraryUpdateInfo"/> class.
/// </summary>
public LibraryUpdateInfo()
{
FoldersAddedTo = Array.Empty<string>();
FoldersRemovedFrom = Array.Empty<string>();
ItemsAdded = Array.Empty<string>();
ItemsRemoved = Array.Empty<string>();
ItemsUpdated = Array.Empty<string>();
CollectionFolders = Array.Empty<string>();
}
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
namespace MediaBrowser.Model.Entities
{
/// <summary>

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Entities

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -7,32 +8,32 @@ namespace MediaBrowser.Model.Entities
public class PackageReviewInfo
{
/// <summary>
/// The package id (database key) for this review
/// Gets or sets the package id (database key) for this review.
/// </summary>
public int id { get; set; }
/// <summary>
/// The rating value
/// Gets or sets the rating value.
/// </summary>
public int rating { get; set; }
/// <summary>
/// Whether or not this review recommends this item
/// Gets or sets whether or not this review recommends this item.
/// </summary>
public bool recommend { get; set; }
/// <summary>
/// A short description of the review
/// Gets or sets a short description of the review.
/// </summary>
public string title { get; set; }
/// <summary>
/// A full review
/// Gets or sets the full review.
/// </summary>
public string review { get; set; }
/// <summary>
/// Time of review
/// Gets or sets the time of review.
/// </summary>
public DateTime timestamp { get; set; }

View File

@ -1,12 +1,23 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Entities
{
/// <summary>
/// Class ParentalRating
/// Class ParentalRating.
/// </summary>
public class ParentalRating
{
public ParentalRating()
{
}
public ParentalRating(string name, int value)
{
Name = name;
Value = value;
}
/// <summary>
/// Gets or sets the name.
/// </summary>
@ -18,16 +29,5 @@ namespace MediaBrowser.Model.Entities
/// </summary>
/// <value>The value.</value>
public int Value { get; set; }
public ParentalRating()
{
}
public ParentalRating(string name, int value)
{
Name = name;
Value = value;
}
}
}

View File

@ -25,7 +25,7 @@ namespace MediaBrowser.Model.Entities
/// <param name="instance">The instance.</param>
/// <param name="provider">The provider.</param>
/// <returns>System.String.</returns>
public static string GetProviderId(this IHasProviderIds instance, MetadataProviders provider)
public static string? GetProviderId(this IHasProviderIds instance, MetadataProviders provider)
{
return instance.GetProviderId(provider.ToString());
}
@ -36,7 +36,7 @@ namespace MediaBrowser.Model.Entities
/// <param name="instance">The instance.</param>
/// <param name="name">The name.</param>
/// <returns>System.String.</returns>
public static string GetProviderId(this IHasProviderIds instance, string name)
public static string? GetProviderId(this IHasProviderIds instance, string name)
{
if (instance == null)
{

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -22,12 +22,5 @@ namespace MediaBrowser.Model.Events
{
Argument = arg;
}
/// <summary>
/// Initializes a new instance of the <see cref="GenericEventArgs{T}"/> class.
/// </summary>
public GenericEventArgs()
{
}
}
}

View File

@ -0,0 +1,29 @@
#nullable disable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Extensions
{
// TODO: @bond remove
public static class ListHelper
{
public static bool ContainsIgnoreCase(string[] list, string value)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
foreach (var item in list)
{
if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
}
}

View File

@ -12,9 +12,9 @@ namespace MediaBrowser.Model.Extensions
/// <returns>The string with the first character as uppercase.</returns>
public static string FirstToUpper(string str)
{
if (string.IsNullOrEmpty(str))
if (str.Length == 0)
{
return string.Empty;
return str;
}
if (char.IsUpper(str[0]))

View File

@ -1,3 +1,4 @@
#nullable disable
namespace MediaBrowser.Model.Globalization
{
/// <summary>

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
using System.Collections.Generic;
using System.Globalization;
using MediaBrowser.Model.Entities;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Globalization
@ -11,6 +12,7 @@ namespace MediaBrowser.Model.Globalization
}
public string Name { get; set; }
public string Value { get; set; }
}
}

View File

@ -1,26 +1,39 @@
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Class FileSystemEntryInfo
/// Class FileSystemEntryInfo.
/// </summary>
public class FileSystemEntryInfo
{
/// <summary>
/// Gets or sets the name.
/// Initializes a new instance of the <see cref="FileSystemEntryInfo" /> class.
/// </summary>
/// <param name="name">The filename.</param>
/// <param name="path">The file path.</param>
/// <param name="type">The file type.</param>
public FileSystemEntryInfo(string name, string path, FileSystemEntryType type)
{
Name = name;
Path = path;
Type = type;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
public string Name { get; }
/// <summary>
/// Gets or sets the path.
/// Gets the path.
/// </summary>
/// <value>The path.</value>
public string Path { get; set; }
public string Path { get; }
/// <summary>
/// Gets or sets the type.
/// Gets the type.
/// </summary>
/// <value>The type.</value>
public FileSystemEntryType Type { get; set; }
public FileSystemEntryType Type { get; }
}
}

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;

View File

@ -16,7 +16,6 @@ namespace MediaBrowser.Model.IO
/// <param name="isoPath">The iso path.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>IsoMount.</returns>
/// <exception cref="ArgumentNullException">isoPath</exception>
/// <exception cref="IOException">Unable to create mount.</exception>
Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken);

View File

@ -8,7 +8,7 @@ namespace MediaBrowser.Model.IO
public interface IIsoMount : IDisposable
{
/// <summary>
/// Gets or sets the iso path.
/// Gets the iso path.
/// </summary>
/// <value>The iso path.</value>
string IsoPath { get; }

Some files were not shown because too many files have changed in this diff Show More