@@ -127,36 +127,52 @@ sealed class DoesNotReturnIfAttribute : Attribute
127
127
}
128
128
129
129
/// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values.</summary>
130
- [ AttributeUsage ( AttributeTargets . Method | AttributeTargets . Property , Inherited = false ) ]
130
+ [ AttributeUsage ( AttributeTargets . Method | AttributeTargets . Property , Inherited = false , AllowMultiple = true ) ]
131
131
#if INTERNAL_NULLABLE_ATTRIBUTES
132
132
internal
133
133
#else
134
- [ CLSCompliant ( false ) ]
135
134
public
136
135
#endif
137
136
sealed class MemberNotNullAttribute : Attribute
138
137
{
138
+ /// <summary>Initializes the attribute with a field or property member.</summary>
139
+ /// <param name="member">
140
+ /// The field or property member that is promised to be not-null.
141
+ /// </param>
142
+ public MemberNotNullAttribute ( string member ) => Members = new [ ] { member } ;
143
+
139
144
/// <summary>Initializes the attribute with the list of field and property members.</summary>
140
145
/// <param name="members">
141
146
/// The list of field and property members that are promised to be not-null.
142
147
/// </param>
143
- public MemberNotNullAttribute ( params string [ ] members )
144
- => Members = members ;
148
+ public MemberNotNullAttribute ( params string [ ] members ) => Members = members ;
145
149
146
150
/// <summary>Gets field or property member names.</summary>
147
151
public string [ ] Members { get ; }
148
152
}
149
153
150
154
/// <summary>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.</summary>
151
- [ AttributeUsage ( AttributeTargets . Method | AttributeTargets . Property , Inherited = false ) ]
155
+ [ AttributeUsage ( AttributeTargets . Method | AttributeTargets . Property , Inherited = false , AllowMultiple = true ) ]
152
156
#if INTERNAL_NULLABLE_ATTRIBUTES
153
157
internal
154
158
#else
155
- [ CLSCompliant ( false ) ]
156
159
public
157
160
#endif
158
161
sealed class MemberNotNullWhenAttribute : Attribute
159
162
{
163
+ /// <summary>Initializes the attribute with the specified return value condition and a field or property member.</summary>
164
+ /// <param name="returnValue">
165
+ /// The return value condition. If the method returns this value, the associated parameter will not be null.
166
+ /// </param>
167
+ /// <param name="member">
168
+ /// The field or property member that is promised to be not-null.
169
+ /// </param>
170
+ public MemberNotNullWhenAttribute ( bool returnValue , string member )
171
+ {
172
+ ReturnValue = returnValue ;
173
+ Members = new [ ] { member } ;
174
+ }
175
+
160
176
/// <summary>Initializes the attribute with the specified return value condition and list of field and property members.</summary>
161
177
/// <param name="returnValue">
162
178
/// The return value condition. If the method returns this value, the associated parameter will not be null.
0 commit comments