forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModuleInitializer.cs
More file actions
39 lines (34 loc) · 1.03 KB
/
ModuleInitializer.cs
File metadata and controls
39 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System;
internal static class ModuleInitializer
{
#if NET
[Runtime.CompilerServices.ModuleInitializer]
#endif
[SuppressMessage("Usage", "CA2255:The 'ModuleInitializer' attribute should not be used in libraries", Justification = "Intentional use of module initializer to register trace listener.")]
internal static void Initialize()
{
Trace.Listeners.Clear();
Trace.Listeners.Add(ThrowingTraceListener.Instance);
}
#if NETFRAMEWORK
private static bool s_initialized;
private static readonly object s_lock = new object();
internal static void EnsureInitialized()
{
if (!s_initialized)
{
lock (s_lock)
{
if (s_initialized)
{
return;
}
Initialize();
s_initialized = true;
}
}
}
#endif
}