#if !NETSTANDARD2_1
namespace System.Diagnostics.CodeAnalysis
{
// Effectively the Microsoft implementation for when it doesn't exist for my convenience
///
/// Specifies that when a method returns ,
/// the parameter may be even if the corresponding type disallows it.
///
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
internal sealed class MaybeNullWhenAttribute : Attribute
{
///
/// Initializes the attribute with the specified return value condition.
///
/// The return value condition. If the method returns this
/// value, the associated parameter may be null.
public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
///
/// Gets the return value condition.
///
/// The return value condition. If the method returns this value, the
/// associated parameter may be null.
public bool ReturnValue { get; }
}
///
/// Specifies that when a method returns ,
/// the parameter is not even if the corresponding type allows it.
///
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
internal sealed class NotNullWhenAttribute : Attribute
{
///
/// Initializes the attribute with the specified return value condition.
///
/// The return value condition. If the method returns this
/// value, the associated parameter is not null.
public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
///
/// Gets the return value condition.
///
/// The return value condition. If the method returns this value, the
/// associated parameter is not null.
public bool ReturnValue { get; }
}
///
/// Specifies that an output may be even if the corresponding type disallows it.
///
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
internal sealed class MaybeNullAttribute : Attribute
{
}
///
/// Specifies that the method will not return if the associated Boolean parameter is passed the specified value.
///
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
internal sealed class DoesNotReturnIfAttribute : Attribute
{
///
/// Initializes the attribute with the specified parameter value.
///
///
/// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to
/// the associated parameter matches this value.
///
public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue;
///
/// Gets the condition parameter value.
///
public bool ParameterValue { get; }
}
}
#endif