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.

[Feature Request] Specify string comparison for `string.Contain()` and friends

See original GitHub issue

Please consider adding support to specify string comparison options, to: Contain(), ContainAll(), ContainAny(), NotContain(), NotContainAll(), NotContainAny().

Then instead of this:

foo.ToUpperInvariant().Should().NotContainAny(
  nameof(Foo.Spam).ToUpperInvariant(),
  nameof(Foo.Ham).ToUpperInvariant(),
  nameof(Foo.Eggs).ToUpperInvariant(),
  nameof(Something).ToUpperInvariant(),
  "bar".ToUpperInvariant()
);

We could do this:

foo.Should().NotContainAny(
  StringComparison.InvariantCultureIgnoreCase,
  nameof(Foo.Spam),
  nameof(Foo.Ham),
  nameof(Foo.Eggs),
  nameof(Something),
  "bar"
);

(Yes, I chose the ugliest example. I needed to make a point! 😄 Thanks.)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lonix1commented, Oct 25, 2021

Also a good point. In my experience, sometimes, when the problem seems too complicated the best option is to do nothing. Often it’s a problem that doesn’t require solving.

My code won’t explode if these overloads aren’t added. If it’s easier to ignore my feature request, please do so. And thanks for maintaining this awesome library.

1reaction
dennisdoomencommented, Oct 21, 2021

ContainAllEquivalentOf -> ContainOnlyEquivalentOf

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to compare String from query parameter in nodejs
I'm new to node.js and javascript. Can you please tell, why this comparison is not working? My route handler code: friends = [{...
Read more >
CA1307: Specify StringComparison for clarity (code analysis)
A string comparison operation uses a method overload that does not set a StringComparison parameter. Rule description. Many string compare ...
Read more >
C# Compare Strings?
Hello guys, I am having an issue with comparing strings in C#. ... Do you have an array of strings, and you're trying...
Read more >
Find if a string is interleaved of two other strings | DP-33
Write a function that checks whether C is an interleaving of A and B. C is said to be interleaving A and B,...
Read more >
Python Strings (With Examples)
In computer programming, a string is a sequence of characters. For example, "hello" is a string containing a sequence of characters 'h' ,...
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