-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompilerPolyfills.cs
More file actions
25 lines (22 loc) · 926 Bytes
/
Copy pathCompilerPolyfills.cs
File metadata and controls
25 lines (22 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// CompilerPolyfills.cs
//
// Marker types that enable C# 9–11 features (init, required, nullable) on
// .NET Framework 4.8 without a runtime upgrade. The compiler checks for their
// presence; the runtime never inspects them.
namespace System.Runtime.CompilerServices
{
internal static class IsExternalInit { }
[AttributeUsage(
AttributeTargets.Class | AttributeTargets.Struct |
AttributeTargets.Field | AttributeTargets.Property,
Inherited = false)]
internal sealed class RequiredMemberAttribute : Attribute { }
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public string FeatureName { get; }
public bool IsOptional { get; init; }
public CompilerFeatureRequiredAttribute(string featureName)
=> FeatureName = featureName;
}
}