|
|
|
@ -35,8 +35,10 @@ namespace ICSharpCode.Decompiler.Util
@@ -35,8 +35,10 @@ namespace ICSharpCode.Decompiler.Util
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <exception cref="OverflowException">Overflow checking is enabled and an overflow occurred.</exception>
|
|
|
|
|
/// <exception cref="InvalidCastException">The cast is invalid, e.g. casting a boolean to an integer.</exception>
|
|
|
|
|
//[return: MaybeNull]
|
|
|
|
|
//[return: NotNullIfNotNull(nameof(input))]
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
[return: MaybeNull] |
|
|
|
|
[return: NotNullIfNotNull("input")] |
|
|
|
|
public static object Cast(TypeCode targetType, [MaybeNull] object input, bool checkForOverflow) |
|
|
|
|
{ |
|
|
|
|
if (input == null) |
|
|
|
@ -772,3 +774,35 @@ namespace ICSharpCode.Decompiler.Util
@@ -772,3 +774,35 @@ namespace ICSharpCode.Decompiler.Util
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#if (!NETSTANDARD2_0_OR_GREATER && !NETCORE) || MCS
|
|
|
|
|
namespace System.Diagnostics.CodeAnalysis |
|
|
|
|
{ |
|
|
|
|
/// <summary>Specifies that the output will be non-null if the named parameter is non-null.</summary>
|
|
|
|
|
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] |
|
|
|
|
internal sealed class NotNullIfNotNullAttribute : Attribute |
|
|
|
|
{ |
|
|
|
|
/// <summary>Initializes the attribute with the associated parameter name.</summary>
|
|
|
|
|
/// <param name="parameterName">
|
|
|
|
|
/// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null.
|
|
|
|
|
/// </param>
|
|
|
|
|
public NotNullIfNotNullAttribute(string parameterName) |
|
|
|
|
{ |
|
|
|
|
ParameterName = parameterName; |
|
|
|
|
} |
|
|
|
|
private string _parameterName; |
|
|
|
|
/// <summary>Gets the associated parameter name.</summary>
|
|
|
|
|
public string ParameterName { |
|
|
|
|
get { |
|
|
|
|
return _parameterName; |
|
|
|
|
} |
|
|
|
|
private set { |
|
|
|
|
_parameterName = value; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>Specifies that an output may be null even if the corresponding type disallows it.</summary>
|
|
|
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)] |
|
|
|
|
internal sealed class MaybeNullAttribute : Attribute { } |
|
|
|
|
} |
|
|
|
|
#endif
|