We use some extension methods, which allows us to write something like:
.Single(e => $"{nameof(SomeParameter)}: {SomeParameter}, ...")
instead of just
.Single()
where e
is an exception.
This greatly increases logging experience because the upper variant logs all parameters instead of useless "Sequence contains no elements", which the bottom one produces.
I need to write a test, which would find all non-compliant code, e.g. calls to .Single()
.
Sure, I can use a regex search or just a plain vanilla text search to look in all CS files starting from the solution root and maybe this is the way to go. I just wonder if there is already a simple and known solution for that.
Here is what I need:
Easily add / remove rules: e.g. find all files, which have
.Single()
, find all which have.Single(
but which is not in the form of.Single(e => $"
- this is to account for a combined Where + Single code, etc...The test(s) should run from xUnit.
Thanks a lot!