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

using virtual fuction instead of reflection #11513

Merged
merged 7 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Framework/BuildEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand Down
12 changes: 10 additions & 2 deletions src/Shared/LogMessagePacketBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand Down Expand Up @@ -270,11 +270,12 @@ internal abstract class LogMessagePacketBase : INodePacket
/// </summary>
private static readonly int s_defaultPacketVersion = (Environment.Version.Major * 10) + Environment.Version.Minor;

#if TASKHOST
/// <summary>
/// Dictionary of methods used to read BuildEventArgs.
/// </summary>
private static Dictionary<LoggingEventType, MethodInfo> s_readMethodCache = new Dictionary<LoggingEventType, MethodInfo>();

#endif
/// <summary>
/// Dictionary of methods used to write BuildEventArgs.
/// </summary>
Expand Down Expand Up @@ -478,6 +479,8 @@ internal void ReadFromStream(ITranslator translator)

if (eventCanSerializeItself)
{

#if TASKHOST
MethodInfo methodInfo = null;
lock (s_readMethodCache)
{
Expand All @@ -492,6 +495,11 @@ internal void ReadFromStream(ITranslator translator)
ArgsReaderDelegate readerMethod = (ArgsReaderDelegate)CreateDelegateRobust(typeof(ArgsReaderDelegate), _buildEvent, methodInfo);

readerMethod(translator.Reader, packetVersion);

#else
_buildEvent.CreateFromStream(translator.Reader, packetVersion);
#endif

if (_eventType == LoggingEventType.TargetFinishedEvent && _targetFinishedTranslator != null)
{
_targetFinishedTranslator(translator, (TargetFinishedEventArgs)_buildEvent);
Expand Down