Bring in last generated code for existing extensions and format to match project.

This commit is contained in:
Brandon Thetford
2024-07-09 21:46:29 -07:00
parent b667c3de98
commit 90073ad56e
10 changed files with 713 additions and 0 deletions

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.AddOrSubtract"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class AddOrSubtractExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.AddOrSubtract"/> value to an <see langword="int"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this AddOrSubtract e) => Unsafe.As<AddOrSubtract, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.AddOrSubtract"/> value to a <see langword="uint"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this AddOrSubtract e) => Unsafe.As<AddOrSubtract, uint> (ref e);
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.AddOrSubtract"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this AddOrSubtract _, int value)
{
return value switch
{
0 => true,
1 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.Alignment"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class AlignmentExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.Alignment"/> value to an <see langword="int"/> value with the same
/// binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this Alignment e) => Unsafe.As<Alignment, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.Alignment"/> value to a <see langword="uint"/> value with the same
/// binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this Alignment e) => Unsafe.As<Alignment, uint> (ref e);
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.Alignment"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this Alignment _, int value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
3 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.AlignmentModes"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class AlignmentModesExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.AlignmentModes"/> value to an <see langword="int"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this AlignmentModes e) => Unsafe.As<AlignmentModes, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.AlignmentModes"/> value to a <see langword="uint"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this AlignmentModes e) => Unsafe.As<AlignmentModes, uint> (ref e);
/// <summary>
/// Determines if the specified flags are set in the current value of this
/// <see cref="Terminal.Gui.AlignmentModes"/>.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
/// <returns>
/// True, if all flags present in <paramref name="checkFlags"/> are also present in the current value of the
/// <see cref="Terminal.Gui.AlignmentModes"/>.<br/>Otherwise false.
/// </returns>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this AlignmentModes e, AlignmentModes checkFlags)
{
ref uint enumCurrentValueRef = ref Unsafe.As<AlignmentModes, uint> (ref e);
ref uint checkFlagsValueRef = ref Unsafe.As<AlignmentModes, uint> (ref checkFlags);
return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef;
}
/// <summary>
/// Determines if the specified mask bits are set in the current value of this
/// <see cref="Terminal.Gui.AlignmentModes"/>.
/// </summary>
/// <param name="e">The <see cref="Terminal.Gui.AlignmentModes"/> value to check against the <paramref name="mask"/> value.</param>
/// <param name="mask">A mask to apply to the current value.</param>
/// <returns>
/// True, if all bits set to 1 in the mask are also set to 1 in the current value of the
/// <see cref="Terminal.Gui.AlignmentModes"/>.<br/>Otherwise false.
/// </returns>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this AlignmentModes e, int mask)
{
ref int enumCurrentValueRef = ref Unsafe.As<AlignmentModes, int> (ref e);
return (enumCurrentValueRef & mask) == mask;
}
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.AlignmentModes"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this AlignmentModes _, int value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
4 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.BorderSettings"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class BorderSettingsExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.BorderSettings"/> value to an <see langword="int"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this BorderSettings e) => Unsafe.As<BorderSettings, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.BorderSettings"/> value to a <see langword="uint"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this BorderSettings e) => Unsafe.As<BorderSettings, uint> (ref e);
/// <summary>
/// Determines if the specified flags are set in the current value of this
/// <see cref="Terminal.Gui.BorderSettings"/>.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
/// <returns>
/// True, if all flags present in <paramref name="checkFlags"/> are also present in the current value of the
/// <see cref="Terminal.Gui.BorderSettings"/>.<br/>Otherwise false.
/// </returns>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this BorderSettings e, BorderSettings checkFlags)
{
ref uint enumCurrentValueRef = ref Unsafe.As<BorderSettings, uint> (ref e);
ref uint checkFlagsValueRef = ref Unsafe.As<BorderSettings, uint> (ref checkFlags);
return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef;
}
/// <summary>
/// Determines if the specified mask bits are set in the current value of this
/// <see cref="Terminal.Gui.BorderSettings"/>.
/// </summary>
/// <param name="e">The <see cref="Terminal.Gui.BorderSettings"/> value to check against the <paramref name="mask"/> value.</param>
/// <param name="mask">A mask to apply to the current value.</param>
/// <returns>
/// True, if all bits set to 1 in the mask are also set to 1 in the current value of the
/// <see cref="Terminal.Gui.BorderSettings"/>.<br/>Otherwise false.
/// </returns>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this BorderSettings e, int mask)
{
ref int enumCurrentValueRef = ref Unsafe.As<BorderSettings, int> (ref e);
return (enumCurrentValueRef & mask) == mask;
}
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.BorderSettings"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this BorderSettings _, int value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.DimAutoStyle"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class DimAutoStyleExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.DimAutoStyle"/> value to an <see langword="int"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this DimAutoStyle e) => Unsafe.As<DimAutoStyle, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.DimAutoStyle"/> value to a <see langword="uint"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this DimAutoStyle e) => Unsafe.As<DimAutoStyle, uint> (ref e);
/// <summary>
/// Determines if the specified flags are set in the current value of this <see cref="Terminal.Gui.DimAutoStyle"/>
/// .
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
/// <returns>
/// True, if all flags present in <paramref name="checkFlags"/> are also present in the current value of the
/// <see cref="Terminal.Gui.DimAutoStyle"/>.<br/>Otherwise false.
/// </returns>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this DimAutoStyle e, DimAutoStyle checkFlags)
{
ref uint enumCurrentValueRef = ref Unsafe.As<DimAutoStyle, uint> (ref e);
ref uint checkFlagsValueRef = ref Unsafe.As<DimAutoStyle, uint> (ref checkFlags);
return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef;
}
/// <summary>
/// Determines if the specified mask bits are set in the current value of this
/// <see cref="Terminal.Gui.DimAutoStyle"/>.
/// </summary>
/// <param name="e">The <see cref="Terminal.Gui.DimAutoStyle"/> value to check against the <paramref name="mask"/> value.</param>
/// <param name="mask">A mask to apply to the current value.</param>
/// <returns>
/// True, if all bits set to 1 in the mask are also set to 1 in the current value of the
/// <see cref="Terminal.Gui.DimAutoStyle"/>.<br/>Otherwise false.
/// </returns>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this DimAutoStyle e, int mask)
{
ref int enumCurrentValueRef = ref Unsafe.As<DimAutoStyle, int> (ref e);
return (enumCurrentValueRef & mask) == mask;
}
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.DimAutoStyle"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this DimAutoStyle _, int value)
{
return value switch
{
1 => true,
2 => true,
3 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.DimPercentMode"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class DimPercentModeExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.DimPercentMode"/> value to an <see langword="int"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this DimPercentMode e) => Unsafe.As<DimPercentMode, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.DimPercentMode"/> value to a <see langword="uint"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this DimPercentMode e) => Unsafe.As<DimPercentMode, uint> (ref e);
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.DimPercentMode"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this DimPercentMode _, int value)
{
return value switch
{
0 => true,
1 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.Dimension"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
public static class DimensionExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.Dimension"/> value to an <see langword="int"/> value with the same
/// binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this Dimension e) => Unsafe.As<Dimension, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.Dimension"/> value to a <see langword="uint"/> value with the same
/// binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this Dimension e) => Unsafe.As<Dimension, uint> (ref e);
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.Dimension"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this Dimension _, int value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.KeyBindingScope"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class KeyBindingScopeExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.KeyBindingScope"/> value to an <see langword="int"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this KeyBindingScope e) => Unsafe.As<KeyBindingScope, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.KeyBindingScope"/> value to a <see langword="uint"/> value with the
/// same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this KeyBindingScope e) => Unsafe.As<KeyBindingScope, uint> (ref e);
/// <summary>
/// Determines if the specified flags are set in the current value of this
/// <see cref="Terminal.Gui.KeyBindingScope"/>.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
/// <returns>
/// True, if all flags present in <paramref name="checkFlags"/> are also present in the current value of the
/// <see cref="Terminal.Gui.KeyBindingScope"/>.<br/>Otherwise false.
/// </returns>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this KeyBindingScope e, KeyBindingScope checkFlags)
{
ref uint enumCurrentValueRef = ref Unsafe.As<KeyBindingScope, uint> (ref e);
ref uint checkFlagsValueRef = ref Unsafe.As<KeyBindingScope, uint> (ref checkFlags);
return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef;
}
/// <summary>
/// Determines if the specified mask bits are set in the current value of this
/// <see cref="Terminal.Gui.KeyBindingScope"/>.
/// </summary>
/// <param name="e">
/// The <see cref="Terminal.Gui.KeyBindingScope"/> value to check against the <paramref name="mask"/>
/// value.
/// </param>
/// <param name="mask">A mask to apply to the current value.</param>
/// <returns>
/// True, if all bits set to 1 in the mask are also set to 1 in the current value of the
/// <see cref="Terminal.Gui.KeyBindingScope"/>.<br/>Otherwise false.
/// </returns>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this KeyBindingScope e, int mask)
{
ref int enumCurrentValueRef = ref Unsafe.As<KeyBindingScope, int> (ref e);
return (enumCurrentValueRef & mask) == mask;
}
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.KeyBindingScope"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this KeyBindingScope _, int value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
4 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.Side"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class SideExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.Side"/> value to an <see langword="int"/> value with the same binary
/// representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this Side e) => Unsafe.As<Side, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.Side"/> value to a <see langword="uint"/> value with the same binary
/// representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this Side e) => Unsafe.As<Side, uint> (ref e);
/// <summary>
/// Determines if the specified <see langword="int"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.Side"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this Side _, int value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
3 => true,
_ => false
};
}
}

View File

@@ -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;
/// <summary>Extension methods for the <see cref="Terminal.Gui.ViewDiagnosticFlags"/> <see langword="enum"/> type.</summary>
[GeneratedCode ("Terminal.Gui.Analyzers.Internal", "1.0")]
[CompilerGenerated]
[DebuggerNonUserCode]
[ExcludeFromCodeCoverage (Justification = "Generated code is already tested.")]
[PublicAPI]
public static class ViewDiagnosticFlagsExtensions
{
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.ViewDiagnosticFlags"/> value to an <see langword="int"/> value with
/// the same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static int AsInt32 (this ViewDiagnosticFlags e) => Unsafe.As<ViewDiagnosticFlags, int> (ref e);
/// <summary>
/// Directly converts this <see cref="Terminal.Gui.ViewDiagnosticFlags"/> value to a <see langword="uint"/> value with
/// the same binary representation.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static uint AsUInt32 (this ViewDiagnosticFlags e) => Unsafe.As<ViewDiagnosticFlags, uint> (ref e);
/// <summary>
/// Determines if the specified flags are set in the current value of this
/// <see cref="Terminal.Gui.ViewDiagnosticFlags"/>.
/// </summary>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
/// <returns>
/// True, if all flags present in <paramref name="checkFlags"/> are also present in the current value of the
/// <see cref="Terminal.Gui.ViewDiagnosticFlags"/>.<br/>Otherwise false.
/// </returns>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this ViewDiagnosticFlags e, ViewDiagnosticFlags checkFlags)
{
ref uint enumCurrentValueRef = ref Unsafe.As<ViewDiagnosticFlags, uint> (ref e);
ref uint checkFlagsValueRef = ref Unsafe.As<ViewDiagnosticFlags, uint> (ref checkFlags);
return (enumCurrentValueRef & checkFlagsValueRef) == checkFlagsValueRef;
}
/// <summary>
/// Determines if the specified mask bits are set in the current value of this
/// <see cref="Terminal.Gui.ViewDiagnosticFlags"/>.
/// </summary>
/// <param name="e">
/// The <see cref="Terminal.Gui.ViewDiagnosticFlags"/> value to check against the <paramref name="mask"/>
/// value.
/// </param>
/// <param name="mask">A mask to apply to the current value.</param>
/// <returns>
/// True, if all bits set to 1 in the mask are also set to 1 in the current value of the
/// <see cref="Terminal.Gui.ViewDiagnosticFlags"/>.<br/>Otherwise false.
/// </returns>
/// <remarks>NO VALIDATION IS PERFORMED!</remarks>
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public static bool FastHasFlags (this ViewDiagnosticFlags e, uint mask)
{
ref uint enumCurrentValueRef = ref Unsafe.As<ViewDiagnosticFlags, uint> (ref e);
return (enumCurrentValueRef & mask) == mask;
}
/// <summary>
/// Determines if the specified <see langword="uint"/> value is explicitly defined as a named value of the
/// <see cref="Terminal.Gui.ViewDiagnosticFlags"/> <see langword="enum"/> type.
/// </summary>
/// <remarks>
/// Only explicitly named values return true, as with IsDefined. Combined valid flag values of flags enums which are
/// not explicitly named will return false.
/// </remarks>
public static bool FastIsDefined (this ViewDiagnosticFlags _, uint value)
{
return value switch
{
0 => true,
1 => true,
2 => true,
4 => true,
_ => false
};
}
}