-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added "polyfills" to allow internal usage of some C#11 compiler featu…
…res, including the `required` and `init` keywords. (#772) Co-authored-by: Chris Pulman <[email protected]>
- Loading branch information
1 parent
ab11599
commit 70e02b5
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/DynamicData/Polyfills/CompilerFeatureRequiredAttribute.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved. | ||
// Roland Pheasant licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
// Allows use of the C#11 `required` keyword, internally within this library, when targeting frameworks older than .NET 7. | ||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] | ||
internal sealed class CompilerFeatureRequiredAttribute | ||
: Attribute | ||
{ | ||
public CompilerFeatureRequiredAttribute(string featureName) | ||
=> FeatureName = featureName; | ||
|
||
public string FeatureName { get; } | ||
|
||
public bool IsOptional { get; init; } | ||
|
||
public const string RefStructs | ||
= nameof(RefStructs); | ||
|
||
public const string RequiredMembers | ||
= nameof(RequiredMembers); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved. | ||
// Roland Pheasant licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
// Allows use of the C#11 `init` keyword, internally within this library, when targeting frameworks older than .NET 5. | ||
internal sealed class IsExternalInit | ||
Check warning on line 8 in src/DynamicData/Polyfills/IsExternalInit.cs GitHub Actions / build (Release)
|
||
{ | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved. | ||
// Roland Pheasant licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using System.ComponentModel; | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
// Allows use of the C#11 `required` keyword, internally within this library, when targeting frameworks older than .NET 7. | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal sealed class RequiredMemberAttribute | ||
: Attribute | ||
{ | ||
} |