Merge pull request #6083 from Bond-009/nullable4

Enable nullable reference types for Emby.Server.Implementations
pull/6090/head
Bond-009 3 years ago committed by GitHub
commit d61530eb4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.AppBase
CachePath = cacheDirectoryPath;
WebPath = webDirectoryPath;
DataPath = Path.Combine(ProgramDataPath, "data");
_dataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
}
/// <summary>
@ -55,11 +55,7 @@ namespace Emby.Server.Implementations.AppBase
/// Gets the folder path to the data directory.
/// </summary>
/// <value>The data directory.</value>
public string DataPath
{
get => _dataPath;
private set => _dataPath = Directory.CreateDirectory(value).FullName;
}
public string DataPath => _dataPath;
/// <inheritdoc />
public string VirtualDataPath => "%AppDataPath%";

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.IO;
using System.Linq;

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

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Globalization;

@ -82,9 +82,9 @@ namespace Emby.Server.Implementations.Collections
return null;
})
.Where(i => i != null)
.GroupBy(x => x.Id)
.GroupBy(x => x!.Id) // We removed the null values
.Select(x => x.First())
.ToList();
.ToList()!; // Again... the list doesn't contain any null values
}
/// <inheritdoc />

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.IO;

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Globalization;
using System.IO;

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Security.Cryptography;

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

@ -9,7 +9,7 @@ namespace Emby.Server.Implementations.Data
{
public class ManagedConnection : IDisposable
{
private SQLiteDatabaseConnection _db;
private SQLiteDatabaseConnection? _db;
private readonly SemaphoreSlim _writeLock;
private bool _disposed = false;

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

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

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

@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.Data
/// This holds all the types in the running assemblies
/// so that we can de-serialize properly when we don't have strong types.
/// </summary>
private readonly ConcurrentDictionary<string, Type> _typeMap = new ConcurrentDictionary<string, Type>();
private readonly ConcurrentDictionary<string, Type?> _typeMap = new ConcurrentDictionary<string, Type?>();
/// <summary>
/// Gets the type.
@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="typeName">Name of the type.</param>
/// <returns>Type.</returns>
/// <exception cref="ArgumentNullException"><c>typeName</c> is null.</exception>
public Type GetType(string typeName)
public Type? GetType(string typeName)
{
if (string.IsNullOrEmpty(typeName))
{
@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="typeName">Name of the type.</param>
/// <returns>Type.</returns>
private Type LookupType(string typeName)
private Type? LookupType(string typeName)
{
return AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(typeName))

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

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

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

@ -44,6 +44,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->
<NoWarn>AD0001</NoWarn>
<AnalysisMode Condition=" '$(Configuration)' == 'Debug' ">AllEnabledByDefault</AnalysisMode>

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

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

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

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.Net.Sockets;
using System.Threading;

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

@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
{
if (requestContext.Request.HttpContext.Items.TryGetValue("AuthorizationInfo", out var cached))
{
return (AuthorizationInfo)cached;
return (AuthorizationInfo)cached!; // Cache should never contain null
}
return GetAuthorization(requestContext);
@ -55,15 +55,15 @@ namespace Emby.Server.Implementations.HttpServer.Security
}
private AuthorizationInfo GetAuthorizationInfoFromDictionary(
in Dictionary<string, string> auth,
in Dictionary<string, string>? auth,
in IHeaderDictionary headers,
in IQueryCollection queryString)
{
string deviceId = null;
string device = null;
string client = null;
string version = null;
string token = null;
string? deviceId = null;
string? device = null;
string? client = null;
string? version = null;
string? token = null;
if (auth != null)
{
@ -206,7 +206,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
/// </summary>
/// <param name="httpReq">The HTTP req.</param>
/// <returns>Dictionary{System.StringSystem.String}.</returns>
private Dictionary<string, string> GetAuthorizationDictionary(HttpContext httpReq)
private Dictionary<string, string>? GetAuthorizationDictionary(HttpContext httpReq)
{
var auth = httpReq.Request.Headers["X-Emby-Authorization"];
@ -223,7 +223,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
/// </summary>
/// <param name="httpReq">The HTTP req.</param>
/// <returns>Dictionary{System.StringSystem.String}.</returns>
private Dictionary<string, string> GetAuthorizationDictionary(HttpRequest httpReq)
private Dictionary<string, string>? GetAuthorizationDictionary(HttpRequest httpReq)
{
var auth = httpReq.Headers["X-Emby-Authorization"];
@ -240,7 +240,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
/// </summary>
/// <param name="authorizationHeader">The authorization header.</param>
/// <returns>Dictionary{System.StringSystem.String}.</returns>
private Dictionary<string, string> GetAuthorization(ReadOnlySpan<char> authorizationHeader)
private Dictionary<string, string>? GetAuthorization(ReadOnlySpan<char> authorizationHeader)
{
if (authorizationHeader == null)
{

@ -36,14 +36,14 @@ namespace Emby.Server.Implementations.HttpServer.Security
return GetSession((HttpContext)requestContext);
}
public User GetUser(HttpContext requestContext)
public User? GetUser(HttpContext requestContext)
{
var session = GetSession(requestContext);
return session == null || session.UserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(session.UserId);
}
public User GetUser(object requestContext)
public User? GetUser(object requestContext)
{
return GetUser(((HttpRequest)requestContext).HttpContext);
}

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.Buffers;
using System.IO.Pipelines;

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

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

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

@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.IO
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentNullException">filename</exception>
public virtual string ResolveShortcut(string filename)
public virtual string? ResolveShortcut(string filename)
{
if (string.IsNullOrEmpty(filename))
{
@ -601,7 +601,7 @@ namespace Emby.Server.Implementations.IO
return GetFiles(path, null, false, recursive);
}
public virtual IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string> extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
public virtual IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
{
var enumerationOptions = GetEnumerationOptions(recursive);
@ -655,7 +655,7 @@ namespace Emby.Server.Implementations.IO
return GetFilePaths(path, null, false, recursive);
}
public virtual IEnumerable<string> GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
public virtual IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
{
var enumerationOptions = GetEnumerationOptions(recursive);

@ -17,7 +17,7 @@ namespace Emby.Server.Implementations.IO
public string Extension => ".mblink";
public string Resolve(string shortcutPath)
public string? Resolve(string shortcutPath)
{
if (string.IsNullOrEmpty(shortcutPath))
{

@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.IO
{
public class StreamHelper : IStreamHelper
{
public async Task CopyToAsync(Stream source, Stream destination, int bufferSize, Action onStarted, CancellationToken cancellationToken)
public async Task CopyToAsync(Stream source, Stream destination, int bufferSize, Action? onStarted, CancellationToken cancellationToken)
{
byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
try

@ -1,5 +1,4 @@
#pragma warning disable CS1591
#nullable enable
namespace Emby.Server.Implementations
{

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

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

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

@ -1,3 +1,5 @@
#nullable disable
#pragma warning disable CS1591
using System.Collections.Generic;

@ -1,3 +1,5 @@
#nullable disable
#pragma warning disable CS1591
using System.Collections.Generic;

@ -1,3 +1,5 @@
#nullable disable
#pragma warning disable CS1591
using System.Collections.Generic;

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

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.Linq;
using DotNet.Globbing;

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

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

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

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

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

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
using MediaBrowser.Common.Providers;

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.IO;
using System.Linq;

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

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Linq;
using System.Threading.Tasks;

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

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

@ -1,3 +1,5 @@
#nullable disable
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;

@ -1,3 +1,5 @@
#nullable disable
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.IO;
using MediaBrowser.Controller.Entities;

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.IO;

@ -1,3 +1,5 @@
#nullable disable
using System;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;

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

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

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

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Linq;
using MediaBrowser.Controller.Entities;

@ -1,3 +1,5 @@
#nullable disable
using System.Globalization;
using Emby.Naming.TV;
using MediaBrowser.Controller.Entities.TV;

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

@ -1,3 +1,5 @@
#nullable disable
#pragma warning disable CS1591
using MediaBrowser.Controller.Entities;

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

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

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

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

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

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

@ -6,7 +6,6 @@ using MediaBrowser.Controller.LiveTv;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
internal class EpgChannelData
{
@ -39,13 +38,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
public ChannelInfo GetChannelById(string id)
public ChannelInfo? GetChannelById(string id)
=> _channelsById.GetValueOrDefault(id);
public ChannelInfo GetChannelByNumber(string number)
public ChannelInfo? GetChannelByNumber(string number)
=> _channelsByNumber.GetValueOrDefault(number);
public ChannelInfo GetChannelByName(string name)
public ChannelInfo? GetChannelByName(string name)
=> _channelsByName.GetValueOrDefault(name);
public static string NormalizeName(string value)

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

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

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

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

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

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

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

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

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

@ -1,3 +1,5 @@
#nullable disable
namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
internal class Channels

@ -1,3 +1,5 @@
#nullable disable
using System;
namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun

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

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

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

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

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

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

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

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;

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

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

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

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

@ -1,5 +1,3 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;

@ -1,3 +1,5 @@
#nullable disable
using System;
using System.Collections.Concurrent;
using System.Globalization;

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

@ -1,3 +1,5 @@
#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