| | 1 | | #if NETFRAMEWORK |
| | 2 | |
|
| | 3 | | // Some attribute definitions that are not available on .NET Framework. |
| | 4 | | // Add additional ones as required. |
| | 5 | |
|
| | 6 | | namespace System.Diagnostics.CodeAnalysis; |
| | 7 | |
|
| | 8 | | /// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the |
| | 9 | | [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] |
| | 10 | | internal sealed class NotNullWhenAttribute : Attribute |
| | 11 | | { |
| | 12 | | /// <summary>Initializes the attribute with the specified return value condition.</summary> |
| | 13 | | /// <param name="returnValue"> |
| | 14 | | /// The return value condition. If the method returns this value, the associated parameter will not be null. |
| | 15 | | /// </param> |
| 0 | 16 | | public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; |
| | 17 | |
|
| | 18 | | /// <summary>Gets the return value condition.</summary> |
| 0 | 19 | | public bool ReturnValue { get; } |
| | 20 | | } |
| | 21 | |
|
| | 22 | | /// <summary>Specifies that the output will be non-null if the named parameter is non-null.</summary> |
| | 23 | | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = t |
| | 24 | | internal sealed class NotNullIfNotNullAttribute : Attribute |
| | 25 | | { |
| | 26 | | /// <summary>Initializes the attribute with the associated parameter name.</summary> |
| | 27 | | /// <param name="parameterName"> |
| | 28 | | /// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-nu |
| | 29 | | /// </param> |
| | 30 | | public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName; |
| | 31 | |
|
| | 32 | | /// <summary>Gets the associated parameter name.</summary> |
| | 33 | | public string ParameterName { get; } |
| | 34 | | } |
| | 35 | | #endif |