diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index 25c70875..4069daf0 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -14,6 +14,7 @@ Release date: not released yet - Added `Gapotchenko.FX.IOptional` interface for `Gapotchenko.FX.Optional` type to allow an untyped value introspection - Implemented memory span-based operations for `Gapotchenko.FX.IO.FragmentedMemoryStream` - Polyfills: + - Added polyfill for `System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute` type - Added `Zip(first, second)` and `Zip(first, second, third)` polyfill methods for `IEnumerable` type - Fixed issues: - Fixed issue with nested `Gapotchenko.FX.Optional` values that could occur during implicit value conversion diff --git a/Source/Modules/Catalog/Gapotchenko.FX/Runtime/CompilerServices/OverloadResolutionPriorityAttribute.cs b/Source/Modules/Catalog/Gapotchenko.FX/Runtime/CompilerServices/OverloadResolutionPriorityAttribute.cs new file mode 100644 index 00000000..d763b370 --- /dev/null +++ b/Source/Modules/Catalog/Gapotchenko.FX/Runtime/CompilerServices/OverloadResolutionPriorityAttribute.cs @@ -0,0 +1,44 @@ +#if !NET9_0_OR_GREATER + +#pragma warning disable IDE0130 // Namespace does not match folder structure + +namespace System.Runtime.CompilerServices; + +/// +/// +/// Specifies the priority of a member in overload resolution. +/// When unspecified, the default priority is 0. +/// +/// +/// This is a polyfill provided by Gapotchenko.FX. +/// +/// +[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] +public sealed class OverloadResolutionPriorityAttribute : Attribute +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// The priority of the attributed member. + /// Higher numbers are prioritized, lower numbers are deprioritized. + /// 0 is the default if no attribute is present. + /// + public OverloadResolutionPriorityAttribute(int priority) + { + Priority = priority; + } + + /// + /// The priority of the member. + /// + public int Priority { get; } +} + +#else + +using System.Runtime.CompilerServices; + +[assembly: TypeForwardedTo(typeof(OverloadResolutionPriorityAttribute))] + +#endif