From cacf6a25b3053c82a077e31c9f22ce782977d5fa Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 6 Sep 2022 08:28:32 +0200 Subject: [PATCH] Add polyfills for required members feature --- .../CompilerFeatureRequiredAttribute.cs | 40 +++++++++++++++++++ .../Polyfills/RequiredMemberAttribute.cs | 18 +++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/ComputeSharp.D2D1/Properties/Polyfills/CompilerFeatureRequiredAttribute.cs create mode 100644 src/ComputeSharp.D2D1/Properties/Polyfills/RequiredMemberAttribute.cs diff --git a/src/ComputeSharp.D2D1/Properties/Polyfills/CompilerFeatureRequiredAttribute.cs b/src/ComputeSharp.D2D1/Properties/Polyfills/CompilerFeatureRequiredAttribute.cs new file mode 100644 index 00000000..ab911b2a --- /dev/null +++ b/src/ComputeSharp.D2D1/Properties/Polyfills/CompilerFeatureRequiredAttribute.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.CompilerServices; + +/// +/// Indicates that compiler support for a particular feature is required for the location where this attribute is applied. +/// +[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] +internal sealed class CompilerFeatureRequiredAttribute : Attribute +{ + /// + /// Initializes the with the identifier of the syntax used. + /// + /// The name of the compiler feature. + public CompilerFeatureRequiredAttribute(string featureName) + { + FeatureName = featureName; + } + + /// + /// The name of the compiler feature. + /// + public string FeatureName { get; } + + /// + /// If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand . + /// + public bool IsOptional { get; init; } + + /// + /// The used for the ref structs C# feature. + /// + public const string RefStructs = nameof(RefStructs); + + /// + /// The used for the required members C# feature. + /// + public const string RequiredMembers = nameof(RequiredMembers); +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Properties/Polyfills/RequiredMemberAttribute.cs b/src/ComputeSharp.D2D1/Properties/Polyfills/RequiredMemberAttribute.cs new file mode 100644 index 00000000..a9bc75c6 --- /dev/null +++ b/src/ComputeSharp.D2D1/Properties/Polyfills/RequiredMemberAttribute.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.CompilerServices; + +/// +/// Specifies that a type has required members or that a member is required. +/// +[AttributeUsage( + AttributeTargets.Class | + AttributeTargets.Struct | + AttributeTargets.Field | + AttributeTargets.Property, + AllowMultiple = false, + Inherited = false)] +internal sealed class RequiredMemberAttribute : Attribute +{ +} \ No newline at end of file