Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf in LogMessage #4453

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
5 changes: 2 additions & 3 deletions src/TestFramework/TestFramework/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ public static void LogMessage(string format, params object?[] args)
? format
: string.Format(CultureInfo.InvariantCulture, format, args);

object?[] parameters = [message];
// Making sure all event handlers are called in sync on same thread.
foreach (Delegate invoker in OnLogMessage.GetInvocationList())
foreach (LogMessageHandler invoker in DelegatePolyfill.EnumerateInvocationList(OnLogMessage))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we don't call Logger.LogMessage at all. I don't know how much consumers will be calling this, but it doesn't seem to be a hot path.

@Evangelink I'm not sure if there are "valid" use cases for this Logger class or not. If not, we should consider breaking in v4.

{
try
{
invoker.GetMethodInfo()!.Invoke(invoker.Target, parameters);
invoker(message);
}
catch (Exception)
{
Expand Down