AssemblyExtendedEnumTypeAttribute.cs 1.7 KB

1234567891011121314151617181920212223242526
  1. // ReSharper disable ClassNeverInstantiated.Global
  2. #nullable enable
  3. namespace Terminal.Gui.Analyzers.Internal.Attributes;
  4. /// <summary>Assembly attribute declaring a known pairing of an <see langword="enum" /> type to an extension class.</summary>
  5. /// <remarks>This attribute should only be written by internal source generators for Terminal.Gui. No other usage of any kind is supported.</remarks>
  6. [System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)]
  7. internal sealed class AssemblyExtendedEnumTypeAttribute : System.Attribute
  8. {
  9. /// <summary>Creates a new instance of <see cref="AssemblyExtendedEnumTypeAttribute" /> from the provided parameters.</summary>
  10. /// <param name="enumType">The <see cref="System.Type" /> of an <see langword="enum" /> decorated with a <see cref="GenerateEnumExtensionMethodsAttribute" />.</param>
  11. /// <param name="extensionClass">The <see cref="System.Type" /> of the <see langword="class" /> decorated with an <see cref="ExtensionsForEnumTypeAttribute{TEnum}" /> referring to the same type as <paramref name="enumType" />.</param>
  12. public AssemblyExtendedEnumTypeAttribute (System.Type enumType, System.Type extensionClass)
  13. {
  14. EnumType = enumType;
  15. ExtensionClass = extensionClass;
  16. }
  17. ///<summary>An <see langword="enum" /> type that has been extended by Terminal.Gui source generators.</summary>
  18. public System.Type EnumType { get; init; }
  19. ///<summary>A class containing extension methods for <see cref="EnumType"/>.</summary>
  20. public System.Type ExtensionClass { get; init; }
  21. /// <inheritdoc />
  22. public override string ToString () => $"{EnumType.Name},{ExtensionClass.Name}";
  23. }