You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been writing some code along a very hot path and I'm finding some tension between wanting the safety of using Guard clauses but also worrying about the runtime overhead.
Has there been any consideration of defining a sister API that used ConditionalAttribute to elide these guards/assertions in release builds?
This can be done external to this library via #if DEBUG but there is some precedent with the Debug.Assert family of methods.
API breakdown
publicstaticclassDebugGuard//Open to any other name...{[ConditionalAttribute("Debug")]publicstaticvoidIsGreaterThan<T>(Tvalue,Tminimum,[CallerArgumentExpression(nameof(value))]stringname="");[ConditionalAttribute("Debug")]publicstaticvoidIsGreaterThanOrEqualTo<T>(Tvalue,Tminimum,[CallerArgumentExpression(nameof(value))]stringname="");
...}
Overview
I've been writing some code along a very hot path and I'm finding some tension between wanting the safety of using Guard clauses but also worrying about the runtime overhead.
Has there been any consideration of defining a sister API that used
ConditionalAttribute
to elide these guards/assertions in release builds?This can be done external to this library via
#if DEBUG
but there is some precedent with theDebug.Assert
family of methods.API breakdown
Usage example
Breaking change?
No
Alternatives
Additional context
No response
Help us help you
Yes, but only if others can assist
The text was updated successfully, but these errors were encountered: