AssemblyExtendedEnumTypeAttribute.cs 1.7 KB

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