CompilerFeatureRequiredAttribute.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // ReSharper disable once CheckNamespace
  4. namespace System.Runtime.CompilerServices;
  5. /// <summary>
  6. /// Indicates that compiler support for a particular feature is required for the location where this attribute is
  7. /// applied.
  8. /// </summary>
  9. [AttributeUsage (AttributeTargets.All, AllowMultiple = true, Inherited = false)]
  10. internal sealed class CompilerFeatureRequiredAttribute(string featureName) : Attribute
  11. {
  12. /// <summary>
  13. /// The <see cref="FeatureName"/> used for the ref structs C# feature.
  14. /// </summary>
  15. public const string RefStructs = nameof (RefStructs);
  16. /// <summary>
  17. /// The <see cref="FeatureName"/> used for the required members C# feature.
  18. /// </summary>
  19. public const string RequiredMembers = nameof (RequiredMembers);
  20. /// <summary>
  21. /// The name of the compiler feature.
  22. /// </summary>
  23. public string FeatureName { get; } = featureName;
  24. /// <summary>
  25. /// If true, the compiler can choose to allow access to the location where this attribute is applied if it does not
  26. /// understand <see cref="FeatureName"/>.
  27. /// </summary>
  28. public bool IsOptional { get; init; }
  29. }