feat: add ext method to check if enum is obsolete

This commit is contained in:
kalilistic 2023-02-21 22:53:54 -05:00
parent ca341ec3af
commit a9721079f6

View file

@ -27,4 +27,14 @@ public static class EnumExtensions
.OfType<TAttribute>()
.SingleOrDefault();
}
/// <summary>
/// Gets an indicator if enum has been flagged as obsolete (deprecated).
/// </summary>
/// <param name="value">The enum value that has an attached attribute.</param>
/// <returns>Indicator if enum has been flagged as obsolete.</returns>
public static bool IsObsolete(this Enum value)
{
return GetAttribute<ObsoleteAttribute>(value) != null;
}
}