Fixed warnings

This commit is contained in:
DarthAffe committed 2021-02-02 23:37:56 +01:00
1 parent 57dc9afb32
commit a0a1521658
118 files changed
+802 -1181

No files matched your search

@@ -14,7 +14,7 @@ namespace RGB.NET.Devices.Novation
/// </summary>
/// <param name="source">The enum value to get the description from.</param>
/// <returns>The value of the <see cref="DeviceIdAttribute"/> of the source.</returns>
internal static string GetDeviceId(this Enum source) => source.GetAttribute<DeviceIdAttribute>()?.Id;
internal static string? GetDeviceId(this Enum source) => source.GetAttribute<DeviceIdAttribute>()?.Id;
/// <summary>
/// Gets the value of the <see cref="ColorCapabilityAttribute"/>.
@@ -36,10 +36,11 @@ namespace RGB.NET.Devices.Novation
/// <param name="source">The enum value to get the attribute from</param>
/// <typeparam name="T">The generic attribute type</typeparam>
/// <returns>The <see cref="Attribute"/>.</returns>
private static T GetAttribute<T>(this Enum source)
private static T? GetAttribute<T>(this Enum source)
where T : Attribute
{
FieldInfo fi = source.GetType().GetField(source.ToString());
FieldInfo? fi = source.GetType().GetField(source.ToString());
if (fi == null) return null;
T[] attributes = (T[])fi.GetCustomAttributes(typeof(T), false);
return attributes.Length > 0 ? attributes[0] : null;
}