-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ignores Rider * Adds HasValue which supports null check for nullable value types and objs * No need to capture, just use the existing value * Switches implementation After measuring the boxing path was more performant (both time and alloc) * Adds more tags to package
- Loading branch information
1 parent
4684853
commit 6667ce1
Showing
10 changed files
with
168 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using EnsureThat.Annotations; | ||
using JetBrains.Annotations; | ||
|
||
namespace EnsureThat | ||
{ | ||
public static partial class EnsureArg | ||
{ | ||
/// <summary> | ||
/// Ensures value is not null. | ||
/// Supports both <see cref="Nullable{T}"/> and reference types. | ||
/// If you know you are dealing with a certain type, e.g struct use preferred <see cref="IsNotNull{T}(T?, string, OptsFn)"/> | ||
/// overload instead as it is more performant. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="value"></param> | ||
/// <param name="paramName"></param> | ||
/// <param name="optsFn"></param> | ||
/// <returns></returns> | ||
/// <remarks>If you know you are dealing with e.g. a struct, the <see cref="IsNotNull{T}(T?, string, OptsFn)"/> overload is more performant.</remarks> | ||
[NotNull] | ||
[ContractAnnotation("value:null => halt")] | ||
public static T HasValue<T>([NoEnumeration, ValidatedNotNull] T value, [InvokerParameterName] string paramName = null, OptsFn optsFn = null) | ||
=> Ensure.Any.HasValue(value, paramName, optsFn); | ||
|
||
[NotNull] | ||
[ContractAnnotation("value:null => halt")] | ||
public static T IsNotNull<T>([NoEnumeration, ValidatedNotNull] T value, [InvokerParameterName] string paramName = null, OptsFn optsFn = null) where T : class | ||
=> Ensure.Any.IsNotNull(value, paramName, optsFn); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
|
||
namespace EnsureThat | ||
{ | ||
public static class EnsureThatAnyExtensions | ||
{ | ||
/// <summary> | ||
/// Ensures value is not null. | ||
/// Supports both <see cref="Nullable{T}"/> and reference types. | ||
/// If you know you are dealing with a certain type, e.g struct use preferred <see cref="EnsureThatValueTypeExtensions.IsNotNull{T}(in Param{T?})"/> | ||
/// overload instead as it is more performant. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="param"></param> | ||
/// <remarks>If you know you are dealing with e.g. a struct, the <see cref="EnsureThatValueTypeExtensions.IsNotNull{T}(in Param{T?})"/> overload is more performant.</remarks> | ||
public static void HasValue<T>(this in Param<T> param) | ||
=> Ensure.Any.HasValue(param.Value, param.Name, param.OptsFn); | ||
|
||
public static void IsNotNull<T>(this in Param<T> param) where T : class | ||
=> Ensure.Any.IsNotNull(param.Value, param.Name, param.OptsFn); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters