Skip to content

Commit 41b2f2a

Browse files
committed
refactor: rename Check.StringAssertions.cs to Check.MustBeTrimmedAtEnd.cs
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
1 parent 15f4869 commit 41b2f2a

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed
Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,60 @@
11
using System;
2-
using System.Diagnostics.CodeAnalysis;
3-
using System.Text.RegularExpressions;
2+
using System.Runtime.CompilerServices;
43
using JetBrains.Annotations;
54
using Light.GuardClauses.Exceptions;
6-
using System.Runtime.CompilerServices;
75
using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute;
86

97
namespace Light.GuardClauses;
108

119
public static partial class Check
1210
{
1311
/// <summary>
14-
/// Ensures that the string is not null and trimmed at the end, or otherwise throws a <see cref="StringException"/>.
12+
/// Ensures that the string is not null and trimmed at the end, or otherwise throws a <see cref="StringException" />.
1513
/// Empty strings are regarded as trimmed.
1614
/// </summary>
1715
/// <param name="parameter">The string to be checked.</param>
1816
/// <param name="parameterName">The name of the parameter (optional).</param>
1917
/// <param name="message">The message that will be passed to the resulting exception (optional).</param>
2018
/// <exception cref="StringException">
21-
/// Thrown when <paramref name="parameter"/> is not trimmed at the end, i.e. they end with white space characters.
19+
/// Thrown when <paramref name="parameter" /> is not trimmed at the end, i.e. they end with white space characters.
2220
/// Empty strings are regarded as trimmed.
2321
/// </exception>
24-
/// <exception cref="ArgumentNullException">Thrown when <paramref name="parameter"/> is null.</exception>
22+
/// <exception cref="ArgumentNullException">Thrown when <paramref name="parameter" /> is null.</exception>
2523
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2624
[ContractAnnotation("parameter:null => halt; parameter:notnull => notnull")]
27-
public static string MustBeTrimmedAtEnd([NotNull, ValidatedNotNull] this string? parameter, [CallerArgumentExpression("parameter")] string? parameterName = null, string? message = null)
25+
public static string MustBeTrimmedAtEnd(
26+
[NotNull] [ValidatedNotNull] this string? parameter,
27+
[CallerArgumentExpression("parameter")] string? parameterName = null,
28+
string? message = null
29+
)
2830
{
2931
if (!parameter.MustNotBeNull(parameterName, message).IsTrimmedAtEnd())
32+
{
3033
Throw.NotTrimmedAtEnd(parameter, parameterName, message);
34+
}
35+
3136
return parameter;
3237
}
33-
38+
3439
/// <summary>
3540
/// Ensures that the string is not null and trimmed at the end, or otherwise throws your custom exception.
3641
/// Empty strings are regarded as trimmed.
3742
/// </summary>
3843
/// <param name="parameter">The string to be checked.</param>
39-
/// <param name="exceptionFactory">The delegate that creates your custom exception. <paramref name="parameter"/> is passed to this delegate.</param>
40-
/// <exception cref="Exception">Your custom exception thrown when <paramref name="parameter"/> is null or not trimmed at the end. Empty strings are regarded as trimmed.</exception>
44+
/// <param name="exceptionFactory">The delegate that creates your custom exception. <paramref name="parameter" /> is passed to this delegate.</param>
45+
/// <exception cref="Exception">Your custom exception thrown when <paramref name="parameter" /> is null or not trimmed at the end. Empty strings are regarded as trimmed.</exception>
4146
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4247
[ContractAnnotation("parameter:null => halt; parameter:notnull => notnull")]
43-
public static string MustBeTrimmedAtEnd([NotNull, ValidatedNotNull] this string? parameter, Func<string?, Exception> exceptionFactory)
48+
public static string MustBeTrimmedAtEnd(
49+
[NotNull] [ValidatedNotNull] this string? parameter,
50+
Func<string?, Exception> exceptionFactory
51+
)
4452
{
4553
if (parameter is null || !parameter.AsSpan().IsTrimmedAtEnd())
54+
{
4655
Throw.CustomException(exceptionFactory, parameter);
56+
}
57+
4758
return parameter;
4859
}
49-
}
60+
}

0 commit comments

Comments
 (0)