From f1b0a48309961fac6529b15b431f1935deeadf49 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 10 Aug 2022 11:29:05 +0200 Subject: [PATCH] Add UnscopedRefAttribute polyfill --- .../ComputeSharp.Core.NetStandard.projitems | 1 + .../UnscopedRefAttribute.cs | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/ComputeSharp.Core.NetStandard/System/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.cs diff --git a/src/ComputeSharp.Core.NetStandard/ComputeSharp.Core.NetStandard.projitems b/src/ComputeSharp.Core.NetStandard/ComputeSharp.Core.NetStandard.projitems index c73e175d..e36f15e7 100644 --- a/src/ComputeSharp.Core.NetStandard/ComputeSharp.Core.NetStandard.projitems +++ b/src/ComputeSharp.Core.NetStandard/ComputeSharp.Core.NetStandard.projitems @@ -15,5 +15,6 @@ + \ No newline at end of file diff --git a/src/ComputeSharp.Core.NetStandard/System/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.cs b/src/ComputeSharp.Core.NetStandard/System/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.cs new file mode 100644 index 00000000..0c81c0b1 --- /dev/null +++ b/src/ComputeSharp.Core.NetStandard/System/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.cs @@ -0,0 +1,36 @@ +// 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; + +/// +/// Used to indicate a byref escapes and is not scoped. +/// +/// +/// +/// There are several cases where the C# compiler treats a as implicitly +/// - where the compiler does not allow the to escape the method. +/// +/// +/// For example: +/// +/// for instance methods. +/// parameters that refer to types. +/// parameters. +/// +/// +/// +/// This attribute is used in those instances where the should be allowed to escape. +/// +/// +/// Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for +/// API authors to understand the lifetime implications of applying this attribute and how it may impact their users. +/// +/// +[AttributeUsage( + AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, + AllowMultiple = false, + Inherited = false)] +public sealed class UnscopedRefAttribute : Attribute +{ +} \ No newline at end of file