Last active
July 12, 2024 22:41
-
-
Save bradwilson/ddcbd2ce591c669b7e0b843fd3fba1c4 to your computer and use it in GitHub Desktop.
Polyfill for `required` property support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if !NET7_0_OR_GREATER | |
namespace System.Runtime.CompilerServices | |
{ | |
/// <summary/> | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] | |
internal sealed class RequiredMemberAttribute : Attribute | |
{ } | |
/// <summary/> | |
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] | |
internal sealed class CompilerFeatureRequiredAttribute(string featureName) : Attribute | |
{ | |
/// <summary/> | |
public string FeatureName { get; } = featureName; | |
/// <summary/> | |
public bool IsOptional { get; set; } | |
} | |
} | |
namespace System.Diagnostics.CodeAnalysis | |
{ | |
/// <summary/> | |
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] | |
internal sealed class SetsRequiredMembersAttribute : Attribute | |
{ } | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment