AddOrSubtractExtensions.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.CodeDom.Compiler;
  2. using System.Diagnostics;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Runtime.CompilerServices;
  5. namespace Terminal.Gui.ViewBase;
  6. /// <summary>Extension methods for the <see cref="AddOrSubtract"/> <see langword="enum"/> type.</summary>
  7. [GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
  8. [CompilerGenerated]
  9. [DebuggerNonUserCode]
  10. [ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
  11. [PublicAPI]
  12. public static class AddOrSubtractExtensions
  13. {
  14. /// <summary>
  15. /// Directly converts this <see cref="AddOrSubtract"/> value to an <see langword="int"/> value with the
  16. /// same binary representation.
  17. /// </summary>
  18. /// <remarks>NO VALIDATION IS PERFORMED!</remarks>
  19. [MethodImpl (MethodImplOptions.AggressiveInlining)]
  20. public static int AsInt32 (this AddOrSubtract e) => Unsafe.As<AddOrSubtract, int> (ref e);
  21. /// <summary>
  22. /// Directly converts this <see cref="AddOrSubtract"/> value to a <see langword="uint"/> value with the
  23. /// same binary representation.
  24. /// </summary>
  25. /// <remarks>NO VALIDATION IS PERFORMED!</remarks>
  26. [MethodImpl (MethodImplOptions.AggressiveInlining)]
  27. public static uint AsUInt32 (this AddOrSubtract e) => Unsafe.As<AddOrSubtract, uint> (ref e);
  28. /// <summary>
  29. /// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
  30. /// <see cref="AddOrSubtract"/> <see langword="enum"/> type.
  31. /// </summary>
  32. /// <remarks>
  33. /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
  34. /// not explicitly named will return false.
  35. /// </remarks>
  36. public static bool FastIsDefined (this AddOrSubtract _, int value)
  37. {
  38. return value switch
  39. {
  40. 0 => true,
  41. 1 => true,
  42. _ => false
  43. };
  44. }
  45. }