Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/GuardClauses/GuardAgainstExpressionExtensionsDeprecated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ public static partial class GuardClauseExtensions
/// <param name="message"></param>
/// <returns><paramref name="input"/> if the <paramref name="func"/> evaluates to true </returns>
/// <exception cref="ArgumentException"></exception>
[Obsolete("Deprecated: Switch to Expression for validation.")]
[Obsolete("Deprecated: Switch to Expression for validation (and reverse logic).")]
public static T AgainstExpression<T>(this IGuardClause guardClause,
Func<T, bool> func,
T input,
string message) where T : struct
{
if (!func(input))
{
throw new ArgumentException(message);
}
if (!func(input)) throw new ArgumentException(message);

return input;
}
Expand All @@ -39,16 +36,13 @@ public static T AgainstExpression<T>(this IGuardClause guardClause,
/// <param name="message"></param>
/// <returns><paramref name="input"/> if the <paramref name="func"/> evaluates to true </returns>
/// <exception cref="ArgumentException"></exception>
[Obsolete("Deprecated: Switch to ExpressionAsync for asynchronous validation.")]
[Obsolete("Deprecated: Switch to ExpressionAsync for asynchronous validation (and reverse logic).")]
public static async Task<T> AgainstExpressionAsync<T>(this IGuardClause guardClause,
Func<T, Task<bool>> func,
T input,
string message) where T : struct
{
if (!await func(input))
{
throw new ArgumentException(message);
}
if (!await func(input)) throw new ArgumentException(message);

return input;
}
Expand All @@ -64,14 +58,11 @@ public static async Task<T> AgainstExpressionAsync<T>(this IGuardClause guardCla
/// <param name="paramName">The name of the parameter that is invalid</param>
/// <returns><paramref name="input"/> if the <paramref name="func"/> evaluates to true </returns>
/// <exception cref="ArgumentException"></exception>
[Obsolete("Deprecated: Switch to Expression for validation.")]
[Obsolete("Deprecated: Switch to Expression for validation (and reverse logic).")]
public static T AgainstExpression<T>(this IGuardClause guardClause, Func<T, bool> func,
T input, string message, string paramName) where T : struct
{
if (!func(input))
{
throw new ArgumentException(message, paramName);
}
if (!func(input)) throw new ArgumentException(message, paramName);

return input;
}
Expand Down
Loading