Use `ThrowHelper` for exceptions
I'm still looking at this one, although I haven't been able to find a suitable bit of code that I can benchmark (in benchmark.net) that demonstrates any speed increase.
I'm still looking at this one, although I haven't been able to find a suitable bit of code that I can benchmark (in benchmark.net) that demonstrates any speed increase.
Profiling this is quite tricky, although there are performance gains to be had, so this item should be implemented.
@SteveDunn What's the purpose for this? Maintainability or performance?
Performance- using a helper method improves the rendered code from JIT.
https://docs.microsoft.com/en-us/windows/communitytoolkit/developer-tools/throwhelper#technical-details
@viceroypenguin 👍 The ThrowHelper methods from CommunityToolkit.Diagnostics would only be used for the system exceptions then. Is that the only purpose, or should the ValueObjectValidationException receive a wrapper method as well, to benefit from the performance benefits?
Yes, other exceptions should be wrapped separately with a similar helper class to benefit from similar performance optimizations. All exceptions receive these optimizations, not just this library or the system exceptions - it's just that the system ones are the ones that make sense to put into CommunityToolkit.Diagnostics. Whether @SteveDunn wants to add a dependency to CommunityToolkit.Diagnostics or copy the relevant exceptions independently for Vogen is up to him.