Add nullable context to SabreTools.Core

This commit is contained in:
Matt Nadareski
2023-08-12 00:55:41 -04:00
parent 12ee5895f9
commit ce6a64d4cd
18 changed files with 362 additions and 315 deletions

View File

@@ -10,7 +10,7 @@ namespace SabreTools.Core.Tools
/// </summary>
/// <param name="value">Value to use</param>
/// <returns>MappingAttribute attached to the value</returns>
public static MappingAttribute GetAttribute(T value)
public static MappingAttribute? GetAttribute(T? value)
{
// Null value in, null value out
if (value == null)
@@ -22,7 +22,7 @@ namespace SabreTools.Core.Tools
enumType = Nullable.GetUnderlyingType(enumType);
// If the value returns a null on ToString, just return null
string valueStr = value.ToString();
string? valueStr = value.ToString();
if (string.IsNullOrWhiteSpace(valueStr))
return null;
@@ -42,7 +42,7 @@ namespace SabreTools.Core.Tools
return null;
// Return the first attribute, if possible
return (MappingAttribute)attributes.FirstOrDefault();
return (MappingAttribute?)attributes.FirstOrDefault();
}
}
}