From 90073ad56edae51cae265c0ef219cec2829fff69 Mon Sep 17 00:00:00 2001 From: Brandon Thetford Date: Tue, 9 Jul 2024 21:46:29 -0700 Subject: [PATCH] Bring in last generated code for existing extensions and format to match project. --- .../EnumExtensions/AddOrSubtractExtensions.cs | 51 ++++++++++ .../EnumExtensions/AlignmentExtensions.cs | 53 +++++++++++ .../AlignmentModesExtensions.cs | 90 ++++++++++++++++++ .../BorderSettingsExtensions.cs | 89 ++++++++++++++++++ .../EnumExtensions/DimAutoStyleExtensions.cs | 89 ++++++++++++++++++ .../DimPercentModeExtensions.cs | 51 ++++++++++ .../EnumExtensions/DimensionExtensions.cs | 51 ++++++++++ .../KeyBindingScopeExtensions.cs | 93 +++++++++++++++++++ Terminal.Gui/EnumExtensions/SideExtensions.cs | 53 +++++++++++ .../ViewDiagnosticFlagsExtensions.cs | 93 +++++++++++++++++++ 10 files changed, 713 insertions(+) create mode 100644 Terminal.Gui/EnumExtensions/AddOrSubtractExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/AlignmentExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/AlignmentModesExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/BorderSettingsExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/DimAutoStyleExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/DimPercentModeExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/DimensionExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/KeyBindingScopeExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/SideExtensions.cs create mode 100644 Terminal.Gui/EnumExtensions/ViewDiagnosticFlagsExtensions.cs diff --git a/Terminal.Gui/EnumExtensions/AddOrSubtractExtensions.cs b/Terminal.Gui/EnumExtensions/AddOrSubtractExtensions.cs new file mode 100644 index 000000000..8fb98d81c --- /dev/null +++ b/Terminal.Gui/EnumExtensions/AddOrSubtractExtensions.cs @@ -0,0 +1,51 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class AddOrSubtractExtensions +{ + /// + /// Directly converts this value to an value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this AddOrSubtract e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this AddOrSubtract e) => Unsafe.As (ref e); + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this AddOrSubtract _, int value) + { + return value switch + { + 0 => true, + 1 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/AlignmentExtensions.cs b/Terminal.Gui/EnumExtensions/AlignmentExtensions.cs new file mode 100644 index 000000000..3666d2de5 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/AlignmentExtensions.cs @@ -0,0 +1,53 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class AlignmentExtensions +{ + /// + /// Directly converts this value to an value with the same + /// binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this Alignment e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the same + /// binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this Alignment e) => Unsafe.As (ref e); + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this Alignment _, int value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + 3 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/AlignmentModesExtensions.cs b/Terminal.Gui/EnumExtensions/AlignmentModesExtensions.cs new file mode 100644 index 000000000..3babe81b6 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/AlignmentModesExtensions.cs @@ -0,0 +1,90 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class AlignmentModesExtensions +{ + /// + /// Directly converts this value to an value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this AlignmentModes e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this AlignmentModes e) => Unsafe.As (ref e); + + /// + /// Determines if the specified flags are set in the current value of this + /// . + /// + /// NO VALIDATION IS PERFORMED! + /// + /// True, if all flags present in are also present in the current value of the + /// .
Otherwise false. + ///
+ [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this AlignmentModes e, AlignmentModes checkFlags) + { + ref uint enumCurrentValueRef = ref Unsafe.As (ref e); + ref uint checkFlagsValueRef = ref Unsafe.As (ref checkFlags); + + return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef; + } + + /// + /// Determines if the specified mask bits are set in the current value of this + /// . + /// + /// The value to check against the value. + /// A mask to apply to the current value. + /// + /// True, if all bits set to 1 in the mask are also set to 1 in the current value of the + /// .
Otherwise false. + ///
+ /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this AlignmentModes e, int mask) + { + ref int enumCurrentValueRef = ref Unsafe.As (ref e); + + return (enumCurrentValueRef & mask) == mask; + } + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this AlignmentModes _, int value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + 4 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/BorderSettingsExtensions.cs b/Terminal.Gui/EnumExtensions/BorderSettingsExtensions.cs new file mode 100644 index 000000000..074a45976 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/BorderSettingsExtensions.cs @@ -0,0 +1,89 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class BorderSettingsExtensions +{ + /// + /// Directly converts this value to an value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this BorderSettings e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this BorderSettings e) => Unsafe.As (ref e); + + /// + /// Determines if the specified flags are set in the current value of this + /// . + /// + /// NO VALIDATION IS PERFORMED! + /// + /// True, if all flags present in are also present in the current value of the + /// .
Otherwise false. + ///
+ [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this BorderSettings e, BorderSettings checkFlags) + { + ref uint enumCurrentValueRef = ref Unsafe.As (ref e); + ref uint checkFlagsValueRef = ref Unsafe.As (ref checkFlags); + + return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef; + } + + /// + /// Determines if the specified mask bits are set in the current value of this + /// . + /// + /// The value to check against the value. + /// A mask to apply to the current value. + /// + /// True, if all bits set to 1 in the mask are also set to 1 in the current value of the + /// .
Otherwise false. + ///
+ /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this BorderSettings e, int mask) + { + ref int enumCurrentValueRef = ref Unsafe.As (ref e); + + return (enumCurrentValueRef & mask) == mask; + } + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this BorderSettings _, int value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/DimAutoStyleExtensions.cs b/Terminal.Gui/EnumExtensions/DimAutoStyleExtensions.cs new file mode 100644 index 000000000..6c0813df8 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/DimAutoStyleExtensions.cs @@ -0,0 +1,89 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class DimAutoStyleExtensions +{ + /// + /// Directly converts this value to an value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this DimAutoStyle e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this DimAutoStyle e) => Unsafe.As (ref e); + + /// + /// Determines if the specified flags are set in the current value of this + /// . + /// + /// NO VALIDATION IS PERFORMED! + /// + /// True, if all flags present in are also present in the current value of the + /// .
Otherwise false. + ///
+ [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this DimAutoStyle e, DimAutoStyle checkFlags) + { + ref uint enumCurrentValueRef = ref Unsafe.As (ref e); + ref uint checkFlagsValueRef = ref Unsafe.As (ref checkFlags); + + return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef; + } + + /// + /// Determines if the specified mask bits are set in the current value of this + /// . + /// + /// The value to check against the value. + /// A mask to apply to the current value. + /// + /// True, if all bits set to 1 in the mask are also set to 1 in the current value of the + /// .
Otherwise false. + ///
+ /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this DimAutoStyle e, int mask) + { + ref int enumCurrentValueRef = ref Unsafe.As (ref e); + + return (enumCurrentValueRef & mask) == mask; + } + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this DimAutoStyle _, int value) + { + return value switch + { + 1 => true, + 2 => true, + 3 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/DimPercentModeExtensions.cs b/Terminal.Gui/EnumExtensions/DimPercentModeExtensions.cs new file mode 100644 index 000000000..2fc943f17 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/DimPercentModeExtensions.cs @@ -0,0 +1,51 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class DimPercentModeExtensions +{ + /// + /// Directly converts this value to an value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this DimPercentMode e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this DimPercentMode e) => Unsafe.As (ref e); + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this DimPercentMode _, int value) + { + return value switch + { + 0 => true, + 1 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/DimensionExtensions.cs b/Terminal.Gui/EnumExtensions/DimensionExtensions.cs new file mode 100644 index 000000000..ccbfbf5ed --- /dev/null +++ b/Terminal.Gui/EnumExtensions/DimensionExtensions.cs @@ -0,0 +1,51 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +public static class DimensionExtensions +{ + /// + /// Directly converts this value to an value with the same + /// binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this Dimension e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the same + /// binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this Dimension e) => Unsafe.As (ref e); + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this Dimension _, int value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/KeyBindingScopeExtensions.cs b/Terminal.Gui/EnumExtensions/KeyBindingScopeExtensions.cs new file mode 100644 index 000000000..6f42f4c82 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/KeyBindingScopeExtensions.cs @@ -0,0 +1,93 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class KeyBindingScopeExtensions +{ + /// + /// Directly converts this value to an value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this KeyBindingScope e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the + /// same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this KeyBindingScope e) => Unsafe.As (ref e); + + /// + /// Determines if the specified flags are set in the current value of this + /// . + /// + /// NO VALIDATION IS PERFORMED! + /// + /// True, if all flags present in are also present in the current value of the + /// .
Otherwise false. + ///
+ [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this KeyBindingScope e, KeyBindingScope checkFlags) + { + ref uint enumCurrentValueRef = ref Unsafe.As (ref e); + ref uint checkFlagsValueRef = ref Unsafe.As (ref checkFlags); + + return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef; + } + + /// + /// Determines if the specified mask bits are set in the current value of this + /// . + /// + /// + /// The value to check against the + /// value. + /// + /// A mask to apply to the current value. + /// + /// True, if all bits set to 1 in the mask are also set to 1 in the current value of the + /// .
Otherwise false. + ///
+ /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this KeyBindingScope e, int mask) + { + ref int enumCurrentValueRef = ref Unsafe.As (ref e); + + return (enumCurrentValueRef & mask) == mask; + } + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this KeyBindingScope _, int value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + 4 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/SideExtensions.cs b/Terminal.Gui/EnumExtensions/SideExtensions.cs new file mode 100644 index 000000000..b50e12bdc --- /dev/null +++ b/Terminal.Gui/EnumExtensions/SideExtensions.cs @@ -0,0 +1,53 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class SideExtensions +{ + /// + /// Directly converts this value to an value with the same binary + /// representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this Side e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with the same binary + /// representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this Side e) => Unsafe.As (ref e); + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this Side _, int value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + 3 => true, + _ => false + }; + } +} diff --git a/Terminal.Gui/EnumExtensions/ViewDiagnosticFlagsExtensions.cs b/Terminal.Gui/EnumExtensions/ViewDiagnosticFlagsExtensions.cs new file mode 100644 index 000000000..1aa18fe72 --- /dev/null +++ b/Terminal.Gui/EnumExtensions/ViewDiagnosticFlagsExtensions.cs @@ -0,0 +1,93 @@ +#nullable enable + +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Terminal.Gui.EnumExtensions; + +/// Extension methods for the type. +[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")] +[CompilerGenerated] +[DebuggerNonUserCode] +[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")] +[PublicAPI] +public static class ViewDiagnosticFlagsExtensions +{ + /// + /// Directly converts this value to an value with + /// the same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static int AsInt32 (this ViewDiagnosticFlags e) => Unsafe.As (ref e); + + /// + /// Directly converts this value to a value with + /// the same binary representation. + /// + /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static uint AsUInt32 (this ViewDiagnosticFlags e) => Unsafe.As (ref e); + + /// + /// Determines if the specified flags are set in the current value of this + /// . + /// + /// NO VALIDATION IS PERFORMED! + /// + /// True, if all flags present in are also present in the current value of the + /// .
Otherwise false. + ///
+ [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this ViewDiagnosticFlags e, ViewDiagnosticFlags checkFlags) + { + ref uint enumCurrentValueRef = ref Unsafe.As (ref e); + ref uint checkFlagsValueRef = ref Unsafe.As (ref checkFlags); + + return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef; + } + + /// + /// Determines if the specified mask bits are set in the current value of this + /// . + /// + /// + /// The value to check against the + /// value. + /// + /// A mask to apply to the current value. + /// + /// True, if all bits set to 1 in the mask are also set to 1 in the current value of the + /// .
Otherwise false. + ///
+ /// NO VALIDATION IS PERFORMED! + [MethodImpl (MethodImplOptions.AggressiveInlining)] + public static bool FastHasFlags (this ViewDiagnosticFlags e, uint mask) + { + ref uint enumCurrentValueRef = ref Unsafe.As (ref e); + + return (enumCurrentValueRef & mask) == mask; + } + + /// + /// Determines if the specified value is explicitly defined as a named value of the + /// type. + /// + /// + /// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are + /// not explicitly named will return false. + /// + public static bool FastIsDefined (this ViewDiagnosticFlags _, uint value) + { + return value switch + { + 0 => true, + 1 => true, + 2 => true, + 4 => true, + _ => false + }; + } +}