question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code documentation for WithMessage is lacking (explanation of wildcards)

See original GitHub issue

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

What I would like to have

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
Wolfsblvtcommented, May 31, 2019

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?

1reaction
eNeRGy164commented, Aug 18, 2021

Is this one closed by #1586?

Read more comments on GitHub >

github_iconTop Results From Across the Web

New WithMessage isn't matching substrings without explicit ...
New WithMessage isn't matching substrings without explicit ... Actually, the default behavior is that the message can be a wildcard, ...
Read more >
How to query ElasticSearch with a wildcard
Ignore this, see edit 2. I think you're indeed misunderstanding how wildcards work. Can you post your complete mapping by chance?
Read more >
Using Wild Card Characters - TIBCO Product Documentation
The wild card characters '*' and '?' can be used when filtering on text attributes (work item name, description, etc.) — wild card...
Read more >
Exceptions
However, we discovered that testing the exception message for a substring is so common, that we changed the default behavior of WithMessage to...
Read more >
NRQL reference
Get the values of all available attributes by using * as a wildcard. For example: SELECT * from Transaction . Get values associated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found