1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
6 using System
.Diagnostics
;
7 using Interlocked
= System
.Threading
.Interlocked
;
9 #if ES_BUILD_STANDALONE
10 namespace Microsoft
.Diagnostics
.Tracing
12 namespace System
.Diagnostics
.Tracing
16 /// TraceLogging: Contains the metadata needed to emit an event, optimized
17 /// for events with one top-level compile-time-typed payload object.
19 /// <typeparam name="T">
20 /// Type of the top-level payload object. Should be EmptyStruct if the
21 /// event has no payload.
23 internal static class SimpleEventTypes
<T
>
25 private static TraceLoggingEventTypes
? instance
;
27 public static TraceLoggingEventTypes Instance
=> instance
?? InitInstance();
29 private static TraceLoggingEventTypes
InitInstance()
31 var info
= TraceLoggingTypeInfo
.GetInstance(typeof(T
), null);
32 var newInstance
= new TraceLoggingEventTypes(info
.Name
, info
.Tags
, new TraceLoggingTypeInfo
[] { info }
);
33 Interlocked
.CompareExchange(ref instance
, newInstance
, null);
34 Debug
.Assert(instance
!= null);