Closed ironcev closed 5 years ago
Thanks for your pull request. Unfortunately, I'm currently pretty busy, thus it might be several more days until I'm able to have a look at your PR.
No problem, please take your time. If anyone fully understands the meaning of "being pretty busy", that's me :-)
Your code is flawless, thanks for the PR.
BTW: I've never seen assertions with exception factories being inlined. That's one of the reasons why I split assertions into two overloads, one that throws the default exception, and one that uses an exception factory. Before Light.GuardClauses 4.0, everything was done in one static method.
Thanks for the merge and for the explanation!
Description
Implements #64.
Remarks
Documentation
I had a bit of difficulty to meaningfully describe the
parameter
parameter in this overload:In all other cases where we have a parameter value passed to the
exceptionFactory
this parameter value is as well checked by the guard method. In this case, the parameter value is not checked within the guard, but just thecondition
. Of course, we assume that thecondition
checks theparameter
. Therefore I went for the following formulation:<param name="parameter">The value that is checked in the <paramref name="condition"/>. This value is passed to the <paramref name="exceptionFactory"/>.</param>
Performance
On my machine, the benchmarks are showing that the overloads with
exceptionFactory
are not inlined. In general, I had difficulties getting stable execution times in tests. But the ASM shows clear inlining in the first overload (withoutexceptionFactory
). On the other hand, the Inlining Analyzer shows that all the overloads should be inlined in benchmarks. Attached are results of two runs done on my laptop, in case you want to take a look. Benchmarks.zip