Merge pull request #709 from Bond-009/null

Fix always null expressions
pull/727/head
Andrew Rabert 6 years ago committed by GitHub
commit 7165868509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -76,7 +76,6 @@ namespace Emby.Dlna.ContentDirectory
_dlna.GetDefaultProfile(); _dlna.GetDefaultProfile();
var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase)); var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase));
string accessToken = null;
var user = GetUser(profile); var user = GetUser(profile);
@ -85,7 +84,7 @@ namespace Emby.Dlna.ContentDirectory
_libraryManager, _libraryManager,
profile, profile,
serverAddress, serverAddress,
accessToken, null,
_imageProcessor, _imageProcessor,
_userDataManager, _userDataManager,
user, user,

@ -162,9 +162,7 @@ namespace Emby.Dlna.PlayTo
uuid = location.GetMD5().ToString("N"); uuid = location.GetMD5().ToString("N");
} }
string deviceName = null; var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, null, uri.OriginalString, null);
var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, deviceName, uri.OriginalString, null);
var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault(); var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
@ -172,7 +170,7 @@ namespace Emby.Dlna.PlayTo
{ {
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, _timerFactory, cancellationToken).ConfigureAwait(false); var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, _timerFactory, cancellationToken).ConfigureAwait(false);
deviceName = device.Properties.Name; string deviceName = device.Properties.Name;
_sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName); _sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName);
@ -186,8 +184,6 @@ namespace Emby.Dlna.PlayTo
serverAddress = _appHost.GetLocalApiUrl(info.LocalIpAddress); serverAddress = _appHost.GetLocalApiUrl(info.LocalIpAddress);
} }
string accessToken = null;
controller = new PlayToController(sessionInfo, controller = new PlayToController(sessionInfo,
_sessionManager, _sessionManager,
_libraryManager, _libraryManager,
@ -196,7 +192,7 @@ namespace Emby.Dlna.PlayTo
_userManager, _userManager,
_imageProcessor, _imageProcessor,
serverAddress, serverAddress,
accessToken, null,
_deviceDiscovery, _deviceDiscovery,
_userDataManager, _userDataManager,
_localization, _localization,

@ -36,7 +36,7 @@ namespace Emby.Naming.AudioBook
return null; return null;
} }
var extension = Path.GetExtension(path) ?? string.Empty; var extension = Path.GetExtension(path);
// Check supported extensions // Check supported extensions
if (!_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) if (!_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{ {

@ -462,9 +462,8 @@ namespace Emby.Server.Implementations
private static Tuple<Assembly, string> GetAssembly(Type type) private static Tuple<Assembly, string> GetAssembly(Type type)
{ {
var assembly = type.GetTypeInfo().Assembly; var assembly = type.GetTypeInfo().Assembly;
string path = null;
return new Tuple<Assembly, string>(assembly, path); return new Tuple<Assembly, string>(assembly, null);
} }
public virtual IStreamHelper CreateStreamHelper() public virtual IStreamHelper CreateStreamHelper()

@ -1005,7 +1005,7 @@ namespace Emby.XmlTv.Classes
} }
} }
public static Regex _regDateWithOffset = new Regex(@"^(?<dateDigits>[0-9]{4,14})(\s(?<dateOffset>[+-]*[0-9]{1,4}))?$"); public const string _regDateWithOffset = @"^(?<dateDigits>[0-9]{4,14})(\s(?<dateOffset>[+-]*[0-9]{1,4}))?$";
public DateTimeOffset? ParseDate(string dateValue) public DateTimeOffset? ParseDate(string dateValue)
{ {
@ -1018,50 +1018,47 @@ namespace Emby.XmlTv.Classes
'200007281733 BST', '200209', '19880523083000 +0300'. (BST == +0100.) '200007281733 BST', '200209', '19880523083000 +0300'. (BST == +0100.)
*/ */
DateTimeOffset? result = null; if (string.IsNullOrEmpty(dateValue))
if (!string.IsNullOrEmpty(dateValue))
{ {
var completeDate = "20000101000000"; return null;
var dateComponent = string.Empty; }
var dateOffset = "+00:00";
var match = _regDateWithOffset.Match(dateValue); var completeDate = "20000101000000";
if (match.Success) var dateComponent = string.Empty;
var dateOffset = "+00:00";
var match = Regex.Match(dateValue, _regDateWithOffset);
if (match.Success)
{
dateComponent = match.Groups["dateDigits"].Value;
if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value))
{ {
dateComponent = match.Groups["dateDigits"].Value; dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later
if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value)) if (dateOffset.Length == 5)
{ {
dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later
if (dateOffset.Length == 5) }
{ else
dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later {
} dateOffset = "+00:00";
else
{
dateOffset = "+00:00";
}
} }
} }
}
// Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000 // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000
if (dateComponent.Length < 14) if (dateComponent.Length < 14)
{ {
dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length); dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length);
} }
var standardDate = string.Format("{0} {1}", dateComponent, dateOffset); var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);
if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parsedDateTime)) if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTimeOffset parsedDateTime))
{ {
return parsedDateTime.ToUniversalTime(); return parsedDateTime.ToUniversalTime();
}
else
{
//Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate);
}
} }
return result; // Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate);
return null;
} }
public string StandardiseDate(string value) public string StandardiseDate(string value)
@ -1070,7 +1067,7 @@ namespace Emby.XmlTv.Classes
var dateComponent = string.Empty; var dateComponent = string.Empty;
var dateOffset = "+0000"; var dateOffset = "+0000";
var match = _regDateWithOffset.Match(value); var match = Regex.Match(value, _regDateWithOffset);
if (match.Success) if (match.Success)
{ {
dateComponent = match.Groups["dateDigits"].Value; dateComponent = match.Groups["dateDigits"].Value;

@ -508,7 +508,7 @@ namespace MediaBrowser.Controller.Entities
if (query.IsLiked.HasValue) if (query.IsLiked.HasValue)
{ {
userData = userData ?? userDataManager.GetUserData(user, item); userData = userDataManager.GetUserData(user, item);
if (!userData.Likes.HasValue || userData.Likes != query.IsLiked.Value) if (!userData.Likes.HasValue || userData.Likes != query.IsLiked.Value)
{ {

@ -510,13 +510,11 @@ namespace MediaBrowser.Providers.Music
return new ValueTuple<string, string>(); return new ValueTuple<string, string>();
} }
private static ValueTuple<string, string> ParseArtistNameCredit(XmlReader reader) private static (string, string) ParseArtistNameCredit(XmlReader reader)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read(); reader.Read();
string name = null;
// http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator // http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator
// Loop through each element // Loop through each element
@ -547,7 +545,7 @@ namespace MediaBrowser.Providers.Music
} }
} }
return new ValueTuple<string, string>(name, null); return (null, null);
} }
private static ValueTuple<string, string> ParseArtistArtistCredit(XmlReader reader, string artistId) private static ValueTuple<string, string> ParseArtistArtistCredit(XmlReader reader, string artistId)

Loading…
Cancel
Save