@@ -127,36 +127,52 @@ sealed class DoesNotReturnIfAttribute : Attribute
127127 }
128128
129129 /// <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 ) ]
131131#if INTERNAL_NULLABLE_ATTRIBUTES
132132 internal
133133#else
134- [ CLSCompliant ( false ) ]
135134 public
136135#endif
137136 sealed class MemberNotNullAttribute : Attribute
138137 {
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+
139144 /// <summary>Initializes the attribute with the list of field and property members.</summary>
140145 /// <param name="members">
141146 /// The list of field and property members that are promised to be not-null.
142147 /// </param>
143- public MemberNotNullAttribute ( params string [ ] members )
144- => Members = members ;
148+ public MemberNotNullAttribute ( params string [ ] members ) => Members = members ;
145149
146150 /// <summary>Gets field or property member names.</summary>
147151 public string [ ] Members { get ; }
148152 }
149153
150154 /// <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 ) ]
152156#if INTERNAL_NULLABLE_ATTRIBUTES
153157 internal
154158#else
155- [ CLSCompliant ( false ) ]
156159 public
157160#endif
158161 sealed class MemberNotNullWhenAttribute : Attribute
159162 {
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+
160176 /// <summary>Initializes the attribute with the specified return value condition and list of field and property members.</summary>
161177 /// <param name="returnValue">
162178 /// The return value condition. If the method returns this value, the associated parameter will not be null.
0 commit comments