Hey.
I got another small problem. I think the code documentation (xml comments, and online documentation) for the .WithMessage() method on exceptions is a bit lacking.
I did not really understand what those special wildcards mean, and the method does not explain it really well.
I mean the * is quite obvious, meaning a match-all from there-on, but what's the ??
I had to dig into the source code to find that one out: https://github.com/fluentassertions/fluentassertions/blob/aa96583536589d3c860e695cdb075089b1cb0f56/Src/FluentAssertions/Primitives/StringWildcardMatchingValidator.cs#L42
A quick note on the code documentation and online documentation explaining both wildcards with a sentence.
A side note: Are you sure that using the .* pattern is what you want for the star wildcard? Isn't .*? the better choice, being non-greedy? That is especially important if someone decides to use the wildcard inside of a string.
A quick note on the code documentation and online documentation explaining both wildcards with a sentence.
Would you be able to provide us with a PR?
Are you sure that using the .* pattern is what you want for the star wildcard? Isn't .*? the better choice, being non-greedy? That is especially important if someone decides to use the wildcard inside of a string.
If that works, yeah, let's change that. Again, we would welcome a PR.
If that works, yeah, let's change that. Again, we would welcome a PR.
Yes, it works. And it's what people want most of the time anyway. It's sometime a bit confusing to understand regex really well, but this one should be easy.
A good article on that: Why Using the Greedy .* in Regular Expressions Is Almost Never What You Actually Want
I am already working on a PR for the usages of Jetbrains annotations, so yeah, I will be able to do a PR for this (:
Give me some time, I need to prepare a bit for it. (Setting up a new development system for myself currently)
I also thought that I'll write some additional logic so that you can match a star or question mark without them being replaced with the wildcard patterns, maybe with escaping them before.
Guess I should make unit tests for the code changes as well?
I also thought that I'll write some additional logic so that you can match a star or question mark without them being replaced with the wildcard patterns, maybe with escaping them before.
As long as it is not a breaking change and is a consistent change to everything that supports wildcard patterns.
Guess I should make unit tests for the code changes as well?
TDD it is ;-)
Yeah, I will make sure that it will not break past patterns and matches.
Shouldn't be difficult, because ? as a . did match any character, so also a question mark, and * as a .* did match any sequence from zero to endless containing any characters, so it did match a star as well.
I guess the only thing that would break would be if the pattern before was something like this: Why? and the real exception text was Why! or something else that was no question mark. But I guess that was an error in the test case before, and only slipped through because the question mark did match any character.
A fall positive indeed.
Most helpful comment
Yes, it works. And it's what people want most of the time anyway. It's sometime a bit confusing to understand regex really well, but this one should be easy.
A good article on that: Why Using the Greedy .* in Regular Expressions Is Almost Never What You Actually Want
I am already working on a PR for the usages of Jetbrains annotations, so yeah, I will be able to do a PR for this (:
Give me some time, I need to prepare a bit for it. (Setting up a new development system for myself currently)
I also thought that I'll write some additional logic so that you can match a star or question mark without them being replaced with the wildcard patterns, maybe with escaping them before.
Guess I should make unit tests for the code changes as well?