Skip to content

Commit

Permalink
#28: Synergy.Contracts: Added Fail.IfArgumentWhiteSpace(text); method
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinCelej committed Feb 3, 2024
1 parent d7829ee commit 0290bc2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
) : void [NullableContext, AssertionMethod, ContractAnnotation]
- Fail.IfArgumentWhiteSpace(
argumentValue: string [CanBeNull, AssertionCondition],
argumentName: string [NotNull, NotNull]
argumentName: string? [Nullable, CallerArgumentExpression, Optional]
) : void [AssertionMethod, ContractAnnotation]
- Fail.IfCollectionContains<T>(
collection: IEnumerable<T> [CanBeNull, AssertionCondition],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
) : void [NullableContext, AssertionMethod, ContractAnnotation]
- Fail.IfArgumentWhiteSpace(
argumentValue: string [CanBeNull, AssertionCondition],
argumentName: string [NotNull, NotNull]
argumentName: string? [Nullable, CallerArgumentExpression, Optional]
) : void [AssertionMethod, ContractAnnotation]
- Fail.IfCollectionContains<T>(
collection: IEnumerable<T> [CanBeNull, AssertionCondition],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
) : void [NullableContext, AssertionMethod, ContractAnnotation]
- Fail.IfArgumentWhiteSpace(
argumentValue: string [CanBeNull, AssertionCondition],
argumentName: string [NotNull, NotNull]
argumentName: string? [Nullable, CallerArgumentExpression, Optional]
) : void [AssertionMethod, ContractAnnotation]
- Fail.IfCollectionContains<T>(
collection: IEnumerable<T> [CanBeNull, AssertionCondition],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public static Contractor CreateCompany([NotNull] string name)
}

[NotNull, Pure]
public static Contractor CreatePerson([NotNull] string firstName, [NotNull] string lastName)
public static Contractor CreatePerson(string firstName, string lastName)
{
Fail.IfArgumentEmpty(firstName);
Fail.IfArgumentWhiteSpace(lastName, nameof(lastName));
Fail.IfArgumentWhiteSpace(lastName);

return new Contractor()
{
Expand Down
Binary file modified Contracts/Synergy.Contracts.Test/Failures/FailStringTest.cs
Binary file not shown.
8 changes: 7 additions & 1 deletion Contracts/Synergy.Contracts/Failures/FailString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public static void IfEmpty(
[ContractAnnotation("argumentValue: null => halt")]
public static void IfArgumentWhiteSpace(
[CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string argumentValue,
[NotNull] [System.Diagnostics.CodeAnalysis.NotNull] string argumentName)
#if NET6_0_OR_GREATER
[System.Runtime.CompilerServices.CallerArgumentExpression("argumentValue")]
string? argumentName = null
#else
string argumentName
#endif
)
{
Fail.RequiresArgumentName(argumentName);
Fail.IfArgumentNull(argumentValue, argumentName);
Expand Down

0 comments on commit 0290bc2

Please sign in to comment.