Enable nullabe reference types for MediaBrowser.Model

pull/2767/head
Bond_009 4 years ago
parent 29539174a3
commit 30ce346f34

@ -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);
}

@ -91,7 +91,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);
}

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

@ -86,13 +86,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)
@ -251,14 +245,12 @@ namespace Emby.Server.Implementations.Devices
if (CameraImageUploaded != null)
{
CameraImageUploaded?.Invoke(this, new GenericEventArgs<CameraImageUploadInfo>
{
Argument = new CameraImageUploadInfo
CameraImageUploaded?.Invoke(this, new GenericEventArgs<CameraImageUploadInfo>(
new CameraImageUploadInfo
{
Device = device,
FileInfo = file
}
});
}));
}
}

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

@ -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)

@ -131,7 +131,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>
@ -140,7 +140,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()
@ -755,7 +755,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;
}
@ -980,7 +980,7 @@ namespace Emby.Server.Implementations.Library
if (fireEvent)
{
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User>(user));
}
}
@ -1050,7 +1050,7 @@ namespace Emby.Server.Implementations.Library
if (fireEvent)
{
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User>(user));
}
}
}

@ -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));
}
}

@ -149,27 +149,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()
@ -1725,13 +1716,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)));
}
}
@ -1748,13 +1733,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)
@ -2073,14 +2052,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)
}));
}
}
@ -2105,14 +2081,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)

@ -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
{

@ -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>

@ -254,10 +254,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>
@ -267,11 +264,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();
}

@ -427,7 +427,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();
}

@ -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>
@ -266,13 +261,7 @@ namespace MediaBrowser.Api
return true;
});
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)

@ -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

@ -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; }
}
}

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

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

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

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

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

@ -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; }
}
}

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

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Configuration
@ -5,10 +6,15 @@ namespace MediaBrowser.Model.Configuration
public class EncodingOptions
{
public int EncodingThreadCount { get; set; }
public string TranscodingTempPath { get; set; }
public double DownMixAudioBoost { get; set; }
public bool EnableThrottling { get; set; }
public int ThrottleDelaySeconds { get; set; }
public string HardwareAccelerationType { get; set; }
/// <summary>
@ -20,12 +26,19 @@ namespace MediaBrowser.Model.Configuration
/// The current FFmpeg path being used by the system and displayed on the transcode page.
/// </summary>
public string EncoderAppPathDisplay { get; set; }
public string VaapiDevice { get; set; }
public int H264Crf { get; set; }
public int H265Crf { get; set; }
public string EncoderPreset { get; set; }
public string DeinterlaceMethod { get; set; }
public bool EnableHardwareEncoding { get; set; }
public bool EnableSubtitleExtraction { get; set; }
public string[] HardwareDecodingCodecs { get; set; }

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

@ -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()

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

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

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

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

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

@ -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);

@ -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>();
}
}
}

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

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -7,7 +8,9 @@ namespace MediaBrowser.Model.Devices
public class DevicesOptions
{
public string[] EnabledCameraUploadDevices { get; set; }
public string CameraUploadPath { get; set; }
public bool EnableCameraUploadSubfolders { get; set; }
public DevicesOptions()

@ -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; }
}
}

@ -11,13 +11,21 @@ namespace MediaBrowser.Model.Diagnostics
event EventHandler Exited;
void Kill();
bool WaitForExit(int timeMs);
Task<bool> WaitForExitAsync(int timeMs);
int ExitCode { get; }
void Start();
StreamWriter StandardInput { get; }
StreamReader StandardError { get; }
StreamReader StandardOutput { get; }
ProcessOptions StartInfo { get; }
}
}

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Diagnostics
@ -10,15 +11,25 @@ namespace MediaBrowser.Model.Diagnostics
public class ProcessOptions
{
public string FileName { get; set; }
public string Arguments { get; set; }
public string WorkingDirectory { get; set; }
public bool CreateNoWindow { get; set; }
public bool UseShellExecute { get; set; }
public bool EnableRaisingEvents { get; set; }
public bool ErrorDialog { get; set; }
public bool RedirectStandardError { get; set; }
public bool RedirectStandardInput { get; set; }
public bool RedirectStandardOutput { get; set; }
public bool IsHidden { get; set; }
}
}

@ -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>

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

@ -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))
{
@ -203,34 +203,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)

@ -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")]
@ -45,7 +47,7 @@ namespace MediaBrowser.Model.Dlna
public static bool ContainsContainer(string profileContainers, string inputContainer)
{
var isNegativeList = false;
if (profileContainers != null && profileContainers.StartsWith("-"))
if (profileContainers != null && profileContainers.StartsWith("-", StringComparison.Ordinal))
{
isNegativeList = true;
profileContainers = profileContainers.Substring(1);

@ -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,

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

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

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

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

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

@ -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;

@ -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 };
}

@ -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; }
}
}

@ -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)

@ -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;
}

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

@ -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()

@ -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;
}

@ -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;
}

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

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

@ -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; }
}
}

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

@ -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; }
}
}

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

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

@ -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);

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

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

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

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

@ -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.

@ -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;
}
}
}

@ -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; }
}
}

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

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

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

@ -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)

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

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

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

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

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

@ -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
{

@ -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>();
}
}
}

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

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

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

@ -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; }

@ -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;
}
}
}

@ -20,23 +20,23 @@ namespace MediaBrowser.Model.Entities
}
/// <summary>
/// Gets a provider id
/// Gets a provider id.
/// </summary>
/// <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());
}
/// <summary>
/// Gets a provider id
/// Gets a provider id.
/// </summary>
/// <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)
{
@ -53,7 +53,7 @@ namespace MediaBrowser.Model.Entities
}
/// <summary>
/// Sets a provider id
/// Sets a provider id.
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="name">The name.</param>
@ -89,7 +89,7 @@ namespace MediaBrowser.Model.Entities
}
/// <summary>
/// Sets a provider id
/// Sets a provider id.
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="provider">The provider.</param>

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

@ -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()
{
}
}
}

@ -1,3 +1,4 @@
#nullable disable
#pragma warning disable CS1591
using System;
@ -21,6 +22,7 @@ namespace MediaBrowser.Model.Extensions
return true;
}
}
return false;
}
}

@ -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]))

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

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

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

@ -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; }
}
}

@ -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; }
}
}

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

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

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

Loading…
Cancel
Save