Skip to content

Commit 7da11fd

Browse files
committed
Policyfill UnscopedRef
1 parent a773580 commit 7da11fd

File tree

3 files changed

+42
-463
lines changed

3 files changed

+42
-463
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
#if NET6_0
4+
// Licensed to the .NET Foundation under one or more agreements.
5+
// The .NET Foundation licenses this file to you under the MIT license.
6+
namespace System.Diagnostics.CodeAnalysis
7+
{
8+
/// <summary>
9+
/// Used to indicate a byref escapes and is not scoped.
10+
/// </summary>
11+
/// <remarks>
12+
/// <para>
13+
/// There are several cases where the C# compiler treats a <see langword="ref"/> as implicitly
14+
/// <see langword="scoped"/> - where the compiler does not allow the <see langword="ref"/> to escape the method.
15+
/// </para>
16+
/// <para>
17+
/// For example:
18+
/// <list type="number">
19+
/// <item><see langword="this"/> for <see langword="struct"/> instance methods.</item>
20+
/// <item><see langword="ref"/> parameters that refer to <see langword="ref"/> <see langword="struct"/> types.</item>
21+
/// <item><see langword="out"/> parameters.</item>
22+
/// </list>
23+
/// </para>
24+
/// <para>
25+
/// This attribute is used in those instances where the <see langword="ref"/> should be allowed to escape.
26+
/// </para>
27+
/// <para>
28+
/// Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for
29+
/// API authors to understand the lifetime implications of applying this attribute and how it may impact their users.
30+
/// </para>
31+
/// </remarks>
32+
[global::System.AttributeUsage(
33+
global::System.AttributeTargets.Method |
34+
global::System.AttributeTargets.Property |
35+
global::System.AttributeTargets.Parameter,
36+
AllowMultiple = false,
37+
Inherited = false)]
38+
internal sealed class UnscopedRefAttribute : global::System.Attribute
39+
{
40+
}
41+
}
42+
#endif

src/ImageSharp/Primitives/ColorMatrix.Impl.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
#if NET7_0_OR_GREATER
54
#pragma warning disable SA1117 // Parameters should be on same line or separate lines
65
using System.Diagnostics.CodeAnalysis;
76
using System.Numerics;
@@ -205,5 +204,3 @@ public readonly bool Equals(in Impl other) =>
205204
public override readonly int GetHashCode() => HashCode.Combine(this.X, this.Y, this.Z, this.W, this.V);
206205
}
207206
}
208-
#endif
209-

0 commit comments

Comments
 (0)