Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Obsolete message to note reversal of logic. #357

Merged
merged 1 commit into from
Sep 30, 2024
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