Skip to content

Commit fbe4c3d

Browse files
authored
Update Obsolete message to note reversal of logic. (#357)
Fixes #356
1 parent dc2b6e8 commit fbe4c3d

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/GuardClauses/GuardAgainstExpressionExtensionsDeprecated.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ public static partial class GuardClauseExtensions
1515
/// <param name="message"></param>
1616
/// <returns><paramref name="input"/> if the <paramref name="func"/> evaluates to true </returns>
1717
/// <exception cref="ArgumentException"></exception>
18-
[Obsolete("Deprecated: Switch to Expression for validation.")]
18+
[Obsolete("Deprecated: Switch to Expression for validation (and reverse logic).")]
1919
public static T AgainstExpression<T>(this IGuardClause guardClause,
2020
Func<T, bool> func,
2121
T input,
2222
string message) where T : struct
2323
{
24-
if (!func(input))
25-
{
26-
throw new ArgumentException(message);
27-
}
24+
if (!func(input)) throw new ArgumentException(message);
2825

2926
return input;
3027
}
@@ -39,16 +36,13 @@ public static T AgainstExpression<T>(this IGuardClause guardClause,
3936
/// <param name="message"></param>
4037
/// <returns><paramref name="input"/> if the <paramref name="func"/> evaluates to true </returns>
4138
/// <exception cref="ArgumentException"></exception>
42-
[Obsolete("Deprecated: Switch to ExpressionAsync for asynchronous validation.")]
39+
[Obsolete("Deprecated: Switch to ExpressionAsync for asynchronous validation (and reverse logic).")]
4340
public static async Task<T> AgainstExpressionAsync<T>(this IGuardClause guardClause,
4441
Func<T, Task<bool>> func,
4542
T input,
4643
string message) where T : struct
4744
{
48-
if (!await func(input))
49-
{
50-
throw new ArgumentException(message);
51-
}
45+
if (!await func(input)) throw new ArgumentException(message);
5246

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

7667
return input;
7768
}

0 commit comments

Comments
 (0)