diff --git a/README.md b/README.md index 6f3dba4..2c3f034 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ Here's an example of some of the new features that **PolySharp** can enable down - `[ConstantExpected]` (see [proposal](https://github.com/dotnet/runtime/issues/33771)) - `[CompilerLoweringPreserve]` (see [proposal](https://github.com/dotnet/runtime/issues/103430)) - `[ExtensionMarker]` (needed for [extensions](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#extension-members)) +- `[IsClosedType]` (needed for [closed hierarchies](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-15.0/closed-hierarchies)) +- `[RequiresUnsafe]` (needed for [unsafe evolution](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/unsafe-evolution)) To leverage them, make sure to bump your C# language version. You can do this by setting the `` MSBuild property in your project. For instance, by adding `14.0` (or your desired C# version) to the first `` of your .csproj file. For more info on this, [see here](https://sergiopedri.medium.com/enabling-and-using-c-9-features-on-older-and-unsupported-runtimes-ce384d8debb), but remember that you don't need to manually copy polyfills anymore: simply adding a reference to **PolySharp** will do this for you automatically. diff --git a/src/PolySharp.Package/README.md b/src/PolySharp.Package/README.md index 576713a..9e7a46f 100644 --- a/src/PolySharp.Package/README.md +++ b/src/PolySharp.Package/README.md @@ -55,6 +55,8 @@ Here's an example of some of the new features that **PolySharp** can enable down - `[ConstantExpected]` (see [proposal](https://github.com/dotnet/runtime/issues/33771)) - `[CompilerLoweringPreserve]` (see [proposal](https://github.com/dotnet/runtime/issues/103430)) - `[ExtensionMarker]` (needed for [extensions](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#extension-members)) +- `[IsClosedType]` (needed for [closed hierarchies](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-15.0/closed-hierarchies)) +- `[RequiresUnsafe]` (needed for [unsafe evolution](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/unsafe-evolution)) To leverage them, make sure to bump your C# language version. You can do this by setting the `` MSBuild property in your project. For instance, by adding `14.0` (or your desired C# version) to the first `` of your .csproj file. For more info on this, [see here](https://sergiopedri.medium.com/enabling-and-using-c-9-features-on-older-and-unsupported-runtimes-ce384d8debb), but remember that you don't need to manually copy polyfills anymore: simply adding a reference to **PolySharp** will do this for you automatically. diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/LanguageSupport/System.Diagnostics.CodeAnalysis.RequiresUnsafeAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/LanguageSupport/System.Diagnostics.CodeAnalysis.RequiresUnsafeAttribute.cs new file mode 100644 index 0000000..f415f47 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/LanguageSupport/System.Diagnostics.CodeAnalysis.RequiresUnsafeAttribute.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable +#nullable enable annotations + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Diagnostics.CodeAnalysis +{ + /// + /// Indicates that the specified member requires the caller to be in an unsafe context. + /// + [global::System.AttributeUsage( + global::System.AttributeTargets.Constructor | + global::System.AttributeTargets.Event | + global::System.AttributeTargets.Method | + global::System.AttributeTargets.Property, + Inherited = false, + AllowMultiple = false)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::Microsoft.CodeAnalysis.Embedded] + internal sealed class RequiresUnsafeAttribute : global::System.Attribute + { + /// + /// Initializes a new instance of the class. + /// + public RequiresUnsafeAttribute() { } + } +} \ No newline at end of file diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/LanguageSupport/System.Runtime.CompilerServices.IsClosedTypeAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/LanguageSupport/System.Runtime.CompilerServices.IsClosedTypeAttribute.cs new file mode 100644 index 0000000..954ab37 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/LanguageSupport/System.Runtime.CompilerServices.IsClosedTypeAttribute.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable +#nullable enable annotations + +// 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 +{ + /// + /// Reserved for use by a compiler for tracking metadata. + /// This attribute should not be used by developers in source code. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.AttributeUsage(AttributeTargets.Class, Inherited = false)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::Microsoft.CodeAnalysis.Embedded] + public sealed class IsClosedTypeAttribute : global::System.Attribute + { + private global::System.Type[] _derivedTypes = global::System.Type.EmptyTypes; + + /// Initializes the attribute. + public IsClosedTypeAttribute() + { + } + + /// Gets or sets the derived types of the closed type. + /// An array of the derived types of the closed type. A value is normalized to an empty array. + public global::System.Type[] DerivedTypes + { + get => _derivedTypes; + set => _derivedTypes = value ?? global::System.Type.EmptyTypes; + } + } +} \ No newline at end of file