1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ using System . Runtime . CompilerServices ;
5
+
4
6
namespace System . Diagnostics . CodeAnalysis
5
7
{
6
8
/// <summary>
@@ -10,34 +12,39 @@ namespace System.Diagnostics.CodeAnalysis
10
12
/// To override a method that has a parameter annotated with this attribute, use the ? operator. For more information, see Nullable static analysis in the C# guide.
11
13
/// </remarks>
12
14
[ AttributeUsage ( AttributeTargets . Field | AttributeTargets . Parameter | AttributeTargets . Property , Inherited = false ) ]
15
+ [ ExcludeFromStubs ]
13
16
public sealed class AllowNullAttribute : Attribute
14
17
{ }
15
18
16
19
/// <summary>
17
20
/// Specifies that null is disallowed as an input even if the corresponding type allows it.
18
21
/// </summary>
19
22
[ AttributeUsage ( AttributeTargets . Field | AttributeTargets . Parameter | AttributeTargets . Property , Inherited = false ) ]
23
+ [ ExcludeFromStubs ]
20
24
public sealed class DisallowNullAttribute : Attribute
21
25
{ }
22
26
23
27
/// <summary>
24
28
/// Specifies that an output may be null even if the corresponding type disallows it.
25
29
/// </summary>
26
30
[ AttributeUsage ( AttributeTargets . Field | AttributeTargets . Parameter | AttributeTargets . Property | AttributeTargets . ReturnValue , Inherited = false ) ]
31
+ [ ExcludeFromStubs ]
27
32
public sealed class MaybeNullAttribute : Attribute
28
33
{ }
29
34
30
35
/// <summary>
31
36
/// Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns.
32
37
/// </summary>
33
38
[ AttributeUsage ( AttributeTargets . Field | AttributeTargets . Parameter | AttributeTargets . Property | AttributeTargets . ReturnValue , Inherited = false ) ]
39
+ [ ExcludeFromStubs ]
34
40
public sealed class NotNullAttribute : Attribute
35
41
{ }
36
42
37
43
/// <summary>
38
44
/// Specifies that when a method returns <see cref="ReturnValue"/>, the parameter may be null even if the corresponding type disallows it.
39
45
/// </summary>
40
46
[ AttributeUsage ( AttributeTargets . Parameter , Inherited = false ) ]
47
+ [ ExcludeFromStubs ]
41
48
public sealed class MaybeNullWhenAttribute : Attribute
42
49
{
43
50
/// <summary>
@@ -57,6 +64,7 @@ public sealed class MaybeNullWhenAttribute : Attribute
57
64
/// <summary>
58
65
/// Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the corresponding type allows it.
59
66
/// </summary>
67
+ [ ExcludeFromStubs ]
60
68
public sealed class NotNullWhenAttribute : Attribute
61
69
{
62
70
/// <summary>Initializes the attribute with the specified return value condition.</summary>
@@ -73,6 +81,7 @@ public sealed class NotNullWhenAttribute : Attribute
73
81
/// Specifies that the output will be non-null if the named parameter is non-null.
74
82
/// </summary>
75
83
[ AttributeUsage ( AttributeTargets . Parameter | AttributeTargets . Property | AttributeTargets . ReturnValue , AllowMultiple = true , Inherited = false ) ]
84
+ [ ExcludeFromStubs ]
76
85
public sealed class NotNullIfNotNullAttribute : Attribute
77
86
{
78
87
/// <summary>Initializes the attribute with the associated parameter name.</summary>
@@ -89,13 +98,15 @@ public sealed class NotNullIfNotNullAttribute : Attribute
89
98
/// Applied to a method that will never return under any circumstance.
90
99
/// </summary>
91
100
[ AttributeUsage ( AttributeTargets . Method , Inherited = false ) ]
101
+ [ ExcludeFromStubs ]
92
102
public sealed class DoesNotReturnAttribute : Attribute
93
103
{ }
94
104
95
105
/// <summary>
96
106
/// Specifies that the method will not return if the associated Boolean parameter is passed the specified value.
97
107
/// </summary>
98
108
[ AttributeUsage ( AttributeTargets . Parameter , Inherited = false ) ]
109
+ [ ExcludeFromStubs ]
99
110
public sealed class DoesNotReturnIfAttribute : Attribute
100
111
{
101
112
/// <summary>Initializes the attribute with the specified parameter value.</summary>
@@ -115,6 +126,7 @@ public sealed class DoesNotReturnIfAttribute : Attribute
115
126
/// Specifies that the method or property will ensure that the listed field and property members have not-null values.
116
127
/// </summary>
117
128
[ AttributeUsage ( AttributeTargets . Method | AttributeTargets . Property , Inherited = false , AllowMultiple = true ) ]
129
+ [ ExcludeFromStubs ]
118
130
public sealed class MemberNotNullAttribute : Attribute
119
131
{
120
132
/// <summary>Initializes the attribute with a field or property member.</summary>
@@ -139,6 +151,7 @@ public sealed class MemberNotNullAttribute : Attribute
139
151
/// Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition.
140
152
/// </summary>
141
153
[ AttributeUsage ( AttributeTargets . Method | AttributeTargets . Property , Inherited = false , AllowMultiple = true ) ]
154
+ [ ExcludeFromStubs ]
142
155
public sealed class MemberNotNullWhenAttribute : Attribute
143
156
{
144
157
/// <summary>Initializes the attribute with the specified return value condition and a field or property member.</summary>
0 commit comments