// ReSharper disable RedundantNullableDirective
// ReSharper disable RedundantUsingDirective
// ReSharper disable ClassNeverInstantiated.Global
#nullable enable
using System;
using Attribute = System.Attribute;
using AttributeUsageAttribute = System.AttributeUsageAttribute;
using AttributeTargets = System.AttributeTargets;
namespace Terminal.Gui.Analyzers.Internal.Attributes;
///
/// Used to enable source generation of a common set of extension methods for enum types.
///
[AttributeUsage (AttributeTargets.Enum)]
internal sealed class GenerateEnumExtensionMethodsAttribute : Attribute
{
///
/// The name of the generated static class.
///
///
/// If unspecified, null, empty, or only whitespace, defaults to the name of the enum plus "Extensions".
/// No other validation is performed, so illegal values will simply result in compiler errors.
///
/// Explicitly specifying a default value is unnecessary and will result in unnecessary processing.
///
///
public string? ClassName { get; set; }
///
/// The namespace in which to place the generated static class containing the extension methods.
///
///
/// If unspecified, null, empty, or only whitespace, defaults to the namespace of the enum.
/// No other validation is performed, so illegal values will simply result in compiler errors.
///
/// Explicitly specifying a default value is unnecessary and will result in unnecessary processing.
///
///
public string? ClassNamespace { get; set; }
///
/// Whether to generate a fast, zero-allocation, non-boxing, and reflection-free alternative to the built-in
/// method.
///
///
///
/// Default: false
///
///
/// If the enum is not decorated with , this option has no effect.
///
///
/// If multiple members have the same value, the first member with that value will be used and subsequent members
/// with the same value will be skipped.
///
///
/// Overloads taking the enum type itself as well as the underlying type of the enum will be generated, enabling
/// avoidance of implicit or explicit cast overhead.
///
///
/// Explicitly specifying a default value is unnecessary and will result in unnecessary processing.
///
///
public bool FastHasFlags { get; set; }
///
/// Whether to generate a fast, zero-allocation, and reflection-free alternative to the built-in
/// method,
/// using a switch expression as a hard-coded reverse mapping of numeric values to explicitly-named members.
///
///
///
/// Default: true
///
///
/// If multiple members have the same value, the first member with that value will be used and subsequent members
/// with the same value will be skipped.
///
///
/// As with the source generator only considers explicitly-named members.
/// Generation of values which represent valid bitwise combinations of members of enums decorated with
/// is not affected by this property.
///
///
public bool FastIsDefined { get; init; } = true;
///
/// Gets a value indicating if this instance
/// contains default values only. See remarks of this method or documentation on properties of this type for details.
///
///
/// A value indicating if all property values are default for this
/// instance.
///
///
/// Default values that will result in a return value are:
/// && ! &&
/// &&
///
///
public override bool IsDefaultAttribute ()
{
return FastIsDefined
&& !FastHasFlags
&& ClassName is null
&& ClassNamespace is null;
}
}