From 4b8d10154c39b1f56424d4ba2068a3150d90d475 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Thu, 7 Jan 2021 23:18:27 +0000 Subject: [PATCH] Use faster Guid/Name lookup for EventSource (#45745) --- .../src/System/Diagnostics/Tracing/EventSource.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index c63d070..1e67a98 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -2912,8 +2912,16 @@ namespace System.Diagnostics.Tracing if (eventSourceAttrib != null && eventSourceAttrib.LocalizationResources != null) resources = new ResourceManager(eventSourceAttrib.LocalizationResources, eventSourceType.Assembly); - manifest = new ManifestBuilder(GetName(eventSourceType, flags), GetGuid(eventSourceType), eventSourceDllName, + if (source is not null) + { + // We have the source so don't need to use reflection to get the Name and Guid + manifest = new ManifestBuilder(source.Name, source.Guid, eventSourceDllName, resources, flags); + } + else + { + manifest = new ManifestBuilder(GetName(eventSourceType, flags), GetGuid(eventSourceType), eventSourceDllName, resources, flags); + } // Add an entry unconditionally for event ID 0 which will be for a string message. manifest.StartEvent("EventSourceMessage", new EventAttribute(0) { Level = EventLevel.LogAlways, Task = (EventTask)0xFFFE }); -- 2.7.4