diff --git a/.editorconfig b/.editorconfig index 15950d2..8738748 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,7 @@ indent_style = space trim_trailing_whitespace = true charset = utf-8 end_of_line = lf +max_line_length = 120 # Verify settings # https://github.com/VerifyTests/Verify?tab=readme-ov-file#text-file-settings diff --git a/Directory.Packages.props b/Directory.Packages.props index a5f6e6b..001df32 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,11 +9,8 @@ - - + + value switch { - string stringValue when _compareValue is char compareValue => stringValue.StartsWith( - compareValue - ), + string stringValue when _compareValue is char compareValue => stringValue.StartsWith(compareValue), string stringValue when _compareValue is string compareValue => stringValue.StartsWith( compareValue, _comparison ?? default diff --git a/src/NetEvolve.FluentValue/Constraints/WhiteSpaceConstraint.cs b/src/NetEvolve.FluentValue/Constraints/WhiteSpaceConstraint.cs index e97e61d..a3fe22b 100644 --- a/src/NetEvolve.FluentValue/Constraints/WhiteSpaceConstraint.cs +++ b/src/NetEvolve.FluentValue/Constraints/WhiteSpaceConstraint.cs @@ -12,8 +12,7 @@ public override bool IsSatisfiedBy(object? value) => _ => false, }; - public override void SetDescription(StringBuilder builder) => - builder.Append(" is "); + public override void SetDescription(StringBuilder builder) => builder.Append(" is "); private static bool IsWhiteSpace(ReadOnlySpan value) { diff --git a/src/NetEvolve.FluentValue/IConstraint.cs b/src/NetEvolve.FluentValue/IConstraint.cs index 2d2a641..3bc5203 100644 --- a/src/NetEvolve.FluentValue/IConstraint.cs +++ b/src/NetEvolve.FluentValue/IConstraint.cs @@ -7,11 +7,7 @@ /// /// Public interface for constraints, which can be used to build complex expressions. /// -[SuppressMessage( - "Naming", - "CA1716:Identifiers should not match keywords", - Justification = "As designed." -)] +[SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "As designed.")] public interface IConstraint { /// diff --git a/src/NetEvolve.FluentValue/IOperator.cs b/src/NetEvolve.FluentValue/IOperator.cs index da0e92c..8489f38 100644 --- a/src/NetEvolve.FluentValue/IOperator.cs +++ b/src/NetEvolve.FluentValue/IOperator.cs @@ -9,11 +9,7 @@ /// /// Public interface for operators, which can be used to build complex expressions. /// -[SuppressMessage( - "Naming", - "CA1716:Identifiers should not match keywords", - Justification = "As designed." -)] +[SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "As designed.")] public interface IOperator : IConstraint { /// @@ -51,8 +47,7 @@ IConstraint Contains(char compareValue, StringComparison comparison = default) = /// /// The current instance. /// - IConstraint Contains(object? compareValue) => - SetConstraint(new ContainsConstraint(compareValue)); + IConstraint Contains(object? compareValue) => SetConstraint(new ContainsConstraint(compareValue)); /// /// Appends a constraint that the value contains the specified string. @@ -147,9 +142,7 @@ IConstraint Matches( #if NET7_0_OR_GREATER [StringSyntax(StringSyntaxAttribute.Regex)] #endif - string pattern, - RegexOptions? options = null - ) => SetConstraint(new MatchesConstraint(pattern, options)); + string pattern, RegexOptions? options = null) => SetConstraint(new MatchesConstraint(pattern, options)); /// /// Appends a negation operator. @@ -186,8 +179,7 @@ IOperator Not /// /// The current instance. /// - IConstraint Parenthesis(IConstraint constraint) => - SetConstraint(new ParenthesisConstraint(constraint)); + IConstraint Parenthesis(IConstraint constraint) => SetConstraint(new ParenthesisConstraint(constraint)); /// /// Appends a constraint that the value starts with the specified character. @@ -198,8 +190,7 @@ IConstraint Parenthesis(IConstraint constraint) => /// /// The current instance. /// - IConstraint StartsWith(char compareValue) => - SetConstraint(new StartsWithConstraint(compareValue)); + IConstraint StartsWith(char compareValue) => SetConstraint(new StartsWithConstraint(compareValue)); /// /// Appends a constraint that the value starts with the specified string. diff --git a/src/NetEvolve.FluentValue/Value.cs b/src/NetEvolve.FluentValue/Value.cs index dcd3bbb..e109220 100644 --- a/src/NetEvolve.FluentValue/Value.cs +++ b/src/NetEvolve.FluentValue/Value.cs @@ -37,10 +37,8 @@ public static IConstraint Contains(char compareValue, StringComparison compariso /// /// The current instance. /// - public static IConstraint Contains( - string compareValue, - StringComparison comparison = default - ) => new ContainsConstraint(compareValue, comparison); + public static IConstraint Contains(string compareValue, StringComparison comparison = default) => + new ContainsConstraint(compareValue, comparison); /// /// Appends a constraint that the value contains a . @@ -51,8 +49,7 @@ public static IConstraint Contains( /// /// The current instance. /// - public static IConstraint Contains(object? compareValue) => - new ContainsConstraint(compareValue); + public static IConstraint Contains(object? compareValue) => new ContainsConstraint(compareValue); /// /// Appends a constraint that the value is the default value. @@ -87,10 +84,8 @@ public static IConstraint Contains(object? compareValue) => /// /// The current instance. /// - public static IConstraint EndsWith( - string compareValue, - StringComparison comparison = default - ) => new EndsWithConstraint(compareValue, comparison); + public static IConstraint EndsWith(string compareValue, StringComparison comparison = default) => + new EndsWithConstraint(compareValue, comparison); /// /// Appends a constraint that the value is equal to the specified . @@ -132,9 +127,7 @@ public static IConstraint EqualTo(string compareValue, StringComparison comparis /// public static IConstraint Matches( #if NET7_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.StringSyntax( - System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex - )] + [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] #endif string pattern, RegexOptions? options = null @@ -159,8 +152,7 @@ public static IConstraint Matches( /// /// The current instance. /// - public static IConstraint Parenthesis(IConstraint constraint) => - new ParenthesisConstraint(constraint); + public static IConstraint Parenthesis(IConstraint constraint) => new ParenthesisConstraint(constraint); /// /// Appends a constraint that the value starts with the specified character. @@ -171,8 +163,7 @@ public static IConstraint Parenthesis(IConstraint constraint) => /// /// The current instance. /// - public static IConstraint StartsWith(char compareValue) => - new StartsWithConstraint(compareValue); + public static IConstraint StartsWith(char compareValue) => new StartsWithConstraint(compareValue); /// /// Appends a constraint that the value starts with the specified string. @@ -186,10 +177,8 @@ public static IConstraint StartsWith(char compareValue) => /// /// The current instance. /// - public static IConstraint StartsWith( - string compareValue, - StringComparison comparison = default - ) => new StartsWithConstraint(compareValue, comparison); + public static IConstraint StartsWith(string compareValue, StringComparison comparison = default) => + new StartsWithConstraint(compareValue, comparison); /// /// Appends a constraint that the value is a whitespace character. diff --git a/tests/NetEvolve.FluentValue.Tests.Unit/ConstraintTests.cs b/tests/NetEvolve.FluentValue.Tests.Unit/ConstraintTests.cs index a08bcdb..1569e43 100644 --- a/tests/NetEvolve.FluentValue.Tests.Unit/ConstraintTests.cs +++ b/tests/NetEvolve.FluentValue.Tests.Unit/ConstraintTests.cs @@ -29,9 +29,7 @@ public void Value_MultipleOperators_ThrowsInvalidOperationException() => [Fact] public void Value_Contains_Object_ThrowsNotSupportedException() => - _ = Assert.Throws(() => - Value.Contains(new object()).IsSatisfiedBy(new object()) - ); + _ = Assert.Throws(() => Value.Contains(new object()).IsSatisfiedBy(new object())); [Theory] [MemberData(nameof(InvalidConstraintData))] @@ -149,16 +147,8 @@ public void Value_Theory_Expected(bool expected, IConstraint constraint, object? { true, Value.WhiteSpace, '\n' }, { false, Value.WhiteSpace, 1 }, // .And Operators - { - false, - Value.Contains("Hello", OrdinalIgnoreCase).And.Contains("Welt!", Ordinal), - "Hello World!" - }, - { - true, - Value.Contains("Hello", OrdinalIgnoreCase).And.Contains("World!", Ordinal), - "Hello World!" - }, + { false, Value.Contains("Hello", OrdinalIgnoreCase).And.Contains("Welt!", Ordinal), "Hello World!" }, + { true, Value.Contains("Hello", OrdinalIgnoreCase).And.Contains("World!", Ordinal), "Hello World!" }, // .Or Operators { false, Value.Null.Or.Empty, "Hello World!" }, { true, Value.Null.Or.Empty, null }, @@ -166,16 +156,8 @@ public void Value_Theory_Expected(bool expected, IConstraint constraint, object? // .Xor Operators { false, Value.Null.Xor.Empty, "Hello World!" }, { true, Value.Null.Xor.Empty, string.Empty }, - { - false, - Value.Contains("Hello", OrdinalIgnoreCase).Xor.Contains("World!", Ordinal), - "Hello World!" - }, - { - true, - Value.Contains("Hello", OrdinalIgnoreCase).Xor.Not.Contains("World!", Ordinal), - "Hello World!" - }, + { false, Value.Contains("Hello", OrdinalIgnoreCase).Xor.Contains("World!", Ordinal), "Hello World!" }, + { true, Value.Contains("Hello", OrdinalIgnoreCase).Xor.Not.Contains("World!", Ordinal), "Hello World!" }, // .Not Operators { false, Value.Not.EqualTo(2), "2" }, { false, Value.Not.EqualTo("Hello World!"), "Hello World!" }, @@ -247,10 +229,7 @@ public void ToString_Theory_Expected(string expected, IConstraint constraint) // .WhiteSpace { "\"{Value} is .\"", Value.WhiteSpace }, // .And Operators - { - "\"{Value} contains `Hello` and contains `World!`.\"", - Value.Contains("Hello").And.Contains("World!") - }, + { "\"{Value} contains `Hello` and contains `World!`.\"", Value.Contains("Hello").And.Contains("World!") }, // .Or Operators { "\"{Value} is or is .\"", Value.Null.Or.Empty }, // .Not.Null