Fix IDE0025 (use expression body for properties)
[mono-project.git] / netcore / System.Private.CoreLib / shared / System / Diagnostics / Tracing / TraceLogging / SimpleEventTypes.cs
blob2bcfcdcf56dd8e05877a310b6ff9b0a929897831
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.
5 using System;
6 using System.Diagnostics;
7 using Interlocked = System.Threading.Interlocked;
9 #if ES_BUILD_STANDALONE
10 namespace Microsoft.Diagnostics.Tracing
11 #else
12 namespace System.Diagnostics.Tracing
13 #endif
15 /// <summary>
16 /// TraceLogging: Contains the metadata needed to emit an event, optimized
17 /// for events with one top-level compile-time-typed payload object.
18 /// </summary>
19 /// <typeparam name="T">
20 /// Type of the top-level payload object. Should be EmptyStruct if the
21 /// event has no payload.
22 /// </typeparam>
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);
35 return instance;