1+ #region License
2+ // MIT License
3+ //
4+ // Copyright (c) Manuel Römer
5+ //
6+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7+ // of this software and associated documentation files (the "Software"), to deal
8+ // in the Software without restriction, including without limitation the rights
9+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ // copies of the Software, and to permit persons to whom the Software is
11+ // furnished to do so, subject to the following conditions:
12+ //
13+ // The above copyright notice and this permission notice shall be included in all
14+ // copies or substantial portions of the Software.
15+ //
16+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ // SOFTWARE.
23+ #endregion
24+
25+ #if NETSTANDARD1_3_OR_GREATER || NET35 || NET40 || NET45 || NET452 || NET46 || NETCOREAPP2_1 || UAP10_0
26+
27+ // ReSharper disable once CheckNamespace
28+ namespace System . Diagnostics . CodeAnalysis ;
29+
30+ /// <summary>
31+ /// Specifies that when a method returns <see cref="ReturnValue"/>,
32+ /// the parameter will not be <see langword="null"/> even if the corresponding type allows it.
33+ /// </summary>
34+ [ AttributeUsage ( AttributeTargets . Parameter ) ]
35+ [ DebuggerNonUserCode ]
36+ internal sealed class NotNullWhenAttribute : Attribute
37+ {
38+ /// <summary>
39+ /// Gets the return value condition.
40+ /// If the method returns this value, the associated parameter will not be <see langword="null"/>.
41+ /// </summary>
42+ public bool ReturnValue { get ; }
43+
44+ /// <summary>
45+ /// Initializes the attribute with the specified return value condition.
46+ /// </summary>
47+ /// <param name="returnValue">
48+ /// The return value condition.
49+ /// If the method returns this value, the associated parameter will not be <see langword="null"/>.
50+ /// </param>
51+ public NotNullWhenAttribute ( bool returnValue )
52+ {
53+ ReturnValue = returnValue ;
54+ }
55+ }
56+ #endif
0 commit comments