Refactor StringValidator to avoid inheritance#2296
Refactor StringValidator to avoid inheritance#2296dennisdoomen merged 8 commits intofluentassertions:developfrom vbreuss:topic/refactor-string-validator
StringValidator to avoid inheritance#2296Conversation
Qodana for .NETIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at [email protected]
|
StringValidatorStringValidator to avoid inheritance
|
Something to rethink either: I think it is odd to have a What about aligning them either use into If we agree to the latter: Should then |
The |
|
I believe that enough work is done and there's no need to increase the scope. Moreover, the involved classes are all |
jnyrup
left a comment
There was a problem hiding this comment.
That's some nice untangling of this unnecessary class hierarchy 🧹
Src/FluentAssertions/Primitives/StringWildcardMatchingStrategy.cs
Outdated
Show resolved
Hide resolved
(cherry picked from commit bb50da5)
… for equality" (#2972) * Refactor `StringValidator` to avoid inheritance (#2296) (cherry picked from commit bb50da5) * Improve failure message for string assertions when checking for equality (#2307) * Draft improved failure message when checking for equality. * Use line and column for multiline strings * Fix failing tests * Fix Qodana issues * Fix further failing tests * Also fix tests on MacOS (due to different newline) * Calculate expected index * Fix paranthesis * Move specific methods from common StringExtensions to the `StringEqualityStrategy` class * Fix review comments from @dennisdoomen and add tests for word boundary algorithm * Improve tests by using [raw string literals](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#raw-string-literals) * Update releases.md * Implement review comments from @jnyrup * Adapt due to survived mutants * Adapt test names --------- Co-authored-by: Valentin Breuß <[email protected]> (cherry picked from commit 6859575)
… for equality" (#2972) * Refactor `StringValidator` to avoid inheritance (#2296) (cherry picked from commit bb50da5) * Improve failure message for string assertions when checking for equality (#2307) * Draft improved failure message when checking for equality. * Use line and column for multiline strings * Fix failing tests * Fix Qodana issues * Fix further failing tests * Also fix tests on MacOS (due to different newline) * Calculate expected index * Fix paranthesis * Move specific methods from common StringExtensions to the `StringEqualityStrategy` class * Fix review comments from @dennisdoomen and add tests for word boundary algorithm * Improve tests by using [raw string literals](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#raw-string-literals) * Update releases.md * Implement review comments from @jnyrup * Adapt due to survived mutants * Adapt test names --------- Co-authored-by: Valentin Breuß <[email protected]> (cherry picked from commit 6859575)
Refactor the
StringValidatorto favor composition over inheritance (see this comment):Instead of subclassing the abstract
StringValidatorclass, this class now accepts an interfaceIStringMismatchValidatorwhich provides the necessary implementation details.If this PR is merged, it should simplify implementing #2050.
IMPORTANT
./build.sh --target spellcheckor.\build.ps1 --target spellcheckbefore pushing and check the good outcome