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
It's common to have Assert.SomeMethod(arguments, message: $"... {something} ... etc");.
The message is only needed when the assert actually fails, which hopefully isn't the common case when running tests :)
Currently, we are paying the cost to construct the string while it ends up not being used. That is exactly what interpolated string handlers tries to solve.
Background and Motivation
Introducing new interpolated string handlers overloads will solve the performance costs for this scenario.
That analyzer is specific to Debug.Assert which is costly on older versions of .NET where there is no available overload that has interpolated string handler parameter which is a bit different than what I was suggesting in the original issue. Still, enabling that analyzer may bring benefits for us.
Summary
It's common to have
Assert.SomeMethod(arguments, message: $"... {something} ... etc");
.The message is only needed when the assert actually fails, which hopefully isn't the common case when running tests :)
Currently, we are paying the cost to construct the string while it ends up not being used. That is exactly what interpolated string handlers tries to solve.
Background and Motivation
Introducing new interpolated string handlers overloads will solve the performance costs for this scenario.
See https://learn.microsoft.com/dotnet/csharp/advanced-topics/performance/interpolated-string-handler for info.
The text was updated successfully, but these errors were encountered: