Merge pull request #3962 from mkorkalo/fix_MonoBtlsContext_memory_leak
[mono.git] / mcs / class / referencesource / System.Activities.DurableInstancing / TD.Designer.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated>
3 //     This code was generated by a tool.
4 //
5 //     Changes to this file may cause incorrect behavior and will be lost if
6 //     the code is regenerated.
7 // </auto-generated>
8 //------------------------------------------------------------------------------
9
10 namespace System.Activities.DurableInstancing
11 {
12     using System.Runtime;
13     using System.Runtime.Diagnostics;
14     using System.Security;
15     
16     
17     internal partial class TD
18     {
19         
20         static System.Resources.ResourceManager resourceManager;
21         
22         static System.Globalization.CultureInfo resourceCulture;
23         
24         [System.Security.SecurityCriticalAttribute()]
25         static System.Runtime.Diagnostics.EventDescriptor[] eventDescriptors;
26         
27         static object syncLock = new object();
28         
29         // Double-checked locking pattern requires volatile for read/write synchronization
30         static volatile bool eventDescriptorsCreated;
31         
32         private TD()
33         {
34         }
35         
36         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification="This is an auto-generated code, some ETW/TraceSource mixed code would use it.")]
37         static System.Resources.ResourceManager ResourceManager
38         {
39             get
40             {
41                 if (object.ReferenceEquals(resourceManager, null))
42                 {
43                     resourceManager = new System.Resources.ResourceManager("System.Activities.DurableInstancing.TD", typeof(TD).Assembly);
44                 }
45                 return resourceManager;
46             }
47         }
48         
49         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification="This template is shared across all assemblies, some of which use this accessor.")]
50         internal static System.Globalization.CultureInfo Culture
51         {
52             get
53             {
54                 return resourceCulture;
55             }
56             set
57             {
58                 resourceCulture = value;
59             }
60         }
61         
62         /// <summary>
63         /// Check if trace definition is enabled
64         /// Event description ID=4201, Level=Verbose, Channel=debug
65         /// </summary>
66         internal static bool EndSqlCommandExecuteIsEnabled()
67         {
68             return (FxTrace.ShouldTraceVerbose 
69                         && (FxTrace.ShouldTraceVerboseToTraceSource || TD.IsEtwEventEnabled(0)));
70         }
71         
72         /// <summary>
73         /// Gets trace definition like: End SQL command execution: {0}
74         /// Event description ID=4201, Level=Verbose, Channel=debug
75         /// </summary>
76         /// <param name="param0">Parameter 0 for event: End SQL command execution: {0}</param>
77         internal static void EndSqlCommandExecute(string param0)
78         {
79             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
80             if (TD.IsEtwEventEnabled(0))
81             {
82                 TD.WriteEtwEvent(0, null, param0, payload.AppDomainFriendlyName);
83             }
84             if (FxTrace.ShouldTraceVerboseToTraceSource)
85             {
86                 string description = string.Format(Culture, ResourceManager.GetString("EndSqlCommandExecute", Culture), param0);
87                 TD.WriteTraceSource(0, description, payload);
88             }
89         }
90         
91         /// <summary>
92         /// Check if trace definition is enabled
93         /// Event description ID=4202, Level=Verbose, Channel=debug
94         /// </summary>
95         internal static bool StartSqlCommandExecuteIsEnabled()
96         {
97             return (FxTrace.ShouldTraceVerbose 
98                         && (FxTrace.ShouldTraceVerboseToTraceSource || TD.IsEtwEventEnabled(1)));
99         }
100         
101         /// <summary>
102         /// Gets trace definition like: Starting SQL command execution: {0}
103         /// Event description ID=4202, Level=Verbose, Channel=debug
104         /// </summary>
105         /// <param name="param0">Parameter 0 for event: Starting SQL command execution: {0}</param>
106         internal static void StartSqlCommandExecute(string param0)
107         {
108             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
109             if (TD.IsEtwEventEnabled(1))
110             {
111                 TD.WriteEtwEvent(1, null, param0, payload.AppDomainFriendlyName);
112             }
113             if (FxTrace.ShouldTraceVerboseToTraceSource)
114             {
115                 string description = string.Format(Culture, ResourceManager.GetString("StartSqlCommandExecute", Culture), param0);
116                 TD.WriteTraceSource(1, description, payload);
117             }
118         }
119         
120         /// <summary>
121         /// Check if trace definition is enabled
122         /// Event description ID=4203, Level=Error, Channel=debug
123         /// </summary>
124         internal static bool RenewLockSystemErrorIsEnabled()
125         {
126             return (FxTrace.ShouldTraceError 
127                         && (FxTrace.ShouldTraceErrorToTraceSource || TD.IsEtwEventEnabled(2)));
128         }
129         
130         /// <summary>
131         /// Gets trace definition like: Failed to extend lock expiration, lock expiration already passed or the lock owner was deleted. Aborting SqlWorkflowInstanceStore.
132         /// Event description ID=4203, Level=Error, Channel=debug
133         /// </summary>
134         internal static void RenewLockSystemError()
135         {
136             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
137             if (TD.IsEtwEventEnabled(2))
138             {
139                 TD.WriteEtwEvent(2, null, payload.AppDomainFriendlyName);
140             }
141             if (FxTrace.ShouldTraceErrorToTraceSource)
142             {
143                 string description = string.Format(Culture, ResourceManager.GetString("RenewLockSystemError", Culture));
144                 TD.WriteTraceSource(2, description, payload);
145             }
146         }
147         
148         /// <summary>
149         /// Check if trace definition is enabled
150         /// Event description ID=4205, Level=Error, Channel=debug
151         /// </summary>
152         internal static bool FoundProcessingErrorIsEnabled()
153         {
154             return (FxTrace.ShouldTraceError 
155                         && (FxTrace.ShouldTraceErrorToTraceSource || TD.IsEtwEventEnabled(3)));
156         }
157         
158         /// <summary>
159         /// Gets trace definition like: Command failed: {0}
160         /// Event description ID=4205, Level=Error, Channel=debug
161         /// </summary>
162         /// <param name="eventTraceActivity">The event trace activity</param>
163         /// <param name="param0">Parameter 0 for event: Command failed: {0}</param>
164         /// <param name="exception">Exception associated with the event</param>
165         internal static void FoundProcessingError(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0, System.Exception exception)
166         {
167             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, exception);
168             if (TD.IsEtwEventEnabled(3))
169             {
170                 TD.WriteEtwEvent(3, eventTraceActivity, param0, payload.SerializedException, payload.AppDomainFriendlyName);
171             }
172             if (FxTrace.ShouldTraceErrorToTraceSource)
173             {
174                 string description = string.Format(Culture, ResourceManager.GetString("FoundProcessingError", Culture), param0);
175                 TD.WriteTraceSource(3, description, payload);
176             }
177         }
178         
179         /// <summary>
180         /// Check if trace definition is enabled
181         /// Event description ID=4206, Level=Error, Channel=debug
182         /// </summary>
183         internal static bool UnlockInstanceExceptionIsEnabled()
184         {
185             return (FxTrace.ShouldTraceError 
186                         && (FxTrace.ShouldTraceErrorToTraceSource || TD.IsEtwEventEnabled(4)));
187         }
188         
189         /// <summary>
190         /// Gets trace definition like: Encountered exception {0} while attempting to unlock instance.
191         /// Event description ID=4206, Level=Error, Channel=debug
192         /// </summary>
193         /// <param name="param0">Parameter 0 for event: Encountered exception {0} while attempting to unlock instance.</param>
194         internal static void UnlockInstanceException(string param0)
195         {
196             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
197             if (TD.IsEtwEventEnabled(4))
198             {
199                 TD.WriteEtwEvent(4, null, param0, payload.AppDomainFriendlyName);
200             }
201             if (FxTrace.ShouldTraceErrorToTraceSource)
202             {
203                 string description = string.Format(Culture, ResourceManager.GetString("UnlockInstanceException", Culture), param0);
204                 TD.WriteTraceSource(4, description, payload);
205             }
206         }
207         
208         /// <summary>
209         /// Check if trace definition is enabled
210         /// Event description ID=4207, Level=Informational, Channel=debug
211         /// </summary>
212         internal static bool MaximumRetriesExceededForSqlCommandIsEnabled()
213         {
214             return (FxTrace.ShouldTraceInformation 
215                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(5)));
216         }
217         
218         /// <summary>
219         /// Gets trace definition like: Giving up retrying a SQL command as the maximum number of retries have been performed.
220         /// Event description ID=4207, Level=Informational, Channel=debug
221         /// </summary>
222         /// <param name="eventTraceActivity">The event trace activity</param>
223         internal static void MaximumRetriesExceededForSqlCommand(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity)
224         {
225             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
226             if (TD.IsEtwEventEnabled(5))
227             {
228                 TD.WriteEtwEvent(5, eventTraceActivity, payload.AppDomainFriendlyName);
229             }
230             if (FxTrace.ShouldTraceInformationToTraceSource)
231             {
232                 string description = string.Format(Culture, ResourceManager.GetString("MaximumRetriesExceededForSqlCommand", Culture));
233                 TD.WriteTraceSource(5, description, payload);
234             }
235         }
236         
237         /// <summary>
238         /// Check if trace definition is enabled
239         /// Event description ID=4208, Level=Informational, Channel=debug
240         /// </summary>
241         internal static bool RetryingSqlCommandDueToSqlErrorIsEnabled()
242         {
243             return (FxTrace.ShouldTraceInformation 
244                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(6)));
245         }
246         
247         /// <summary>
248         /// Gets trace definition like: Retrying a SQL command due to SQL error number {0}.
249         /// Event description ID=4208, Level=Informational, Channel=debug
250         /// </summary>
251         /// <param name="eventTraceActivity">The event trace activity</param>
252         /// <param name="param0">Parameter 0 for event: Retrying a SQL command due to SQL error number {0}.</param>
253         internal static void RetryingSqlCommandDueToSqlError(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0)
254         {
255             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
256             if (TD.IsEtwEventEnabled(6))
257             {
258                 TD.WriteEtwEvent(6, eventTraceActivity, param0, payload.AppDomainFriendlyName);
259             }
260             if (FxTrace.ShouldTraceInformationToTraceSource)
261             {
262                 string description = string.Format(Culture, ResourceManager.GetString("RetryingSqlCommandDueToSqlError", Culture), param0);
263                 TD.WriteTraceSource(6, description, payload);
264             }
265         }
266         
267         /// <summary>
268         /// Check if trace definition is enabled
269         /// Event description ID=4209, Level=Error, Channel=debug
270         /// </summary>
271         internal static bool TimeoutOpeningSqlConnectionIsEnabled()
272         {
273             return (FxTrace.ShouldTraceError 
274                         && (FxTrace.ShouldTraceErrorToTraceSource || TD.IsEtwEventEnabled(7)));
275         }
276         
277         /// <summary>
278         /// Gets trace definition like: Timeout trying to open a SQL connection. The operation did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout.
279         /// Event description ID=4209, Level=Error, Channel=debug
280         /// </summary>
281         /// <param name="eventTraceActivity">The event trace activity</param>
282         /// <param name="param0">Parameter 0 for event: Timeout trying to open a SQL connection. The operation did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout.</param>
283         internal static void TimeoutOpeningSqlConnection(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0)
284         {
285             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
286             if (TD.IsEtwEventEnabled(7))
287             {
288                 TD.WriteEtwEvent(7, eventTraceActivity, param0, payload.AppDomainFriendlyName);
289             }
290             if (FxTrace.ShouldTraceErrorToTraceSource)
291             {
292                 string description = string.Format(Culture, ResourceManager.GetString("TimeoutOpeningSqlConnection", Culture), param0);
293                 TD.WriteTraceSource(7, description, payload);
294             }
295         }
296         
297         /// <summary>
298         /// Check if trace definition is enabled
299         /// Event description ID=4210, Level=Warning, Channel=debug
300         /// </summary>
301         internal static bool SqlExceptionCaughtIsEnabled()
302         {
303             return (FxTrace.ShouldTraceWarning 
304                         && (FxTrace.ShouldTraceWarningToTraceSource || TD.IsEtwEventEnabled(8)));
305         }
306         
307         /// <summary>
308         /// Gets trace definition like: Caught SQL Exception number {0} message {1}.
309         /// Event description ID=4210, Level=Warning, Channel=debug
310         /// </summary>
311         /// <param name="eventTraceActivity">The event trace activity</param>
312         /// <param name="param0">Parameter 0 for event: Caught SQL Exception number {0} message {1}.</param>
313         /// <param name="param1">Parameter 1 for event: Caught SQL Exception number {0} message {1}.</param>
314         internal static void SqlExceptionCaught(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0, string param1)
315         {
316             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
317             if (TD.IsEtwEventEnabled(8))
318             {
319                 TD.WriteEtwEvent(8, eventTraceActivity, param0, param1, payload.AppDomainFriendlyName);
320             }
321             if (FxTrace.ShouldTraceWarningToTraceSource)
322             {
323                 string description = string.Format(Culture, ResourceManager.GetString("SqlExceptionCaught", Culture), param0, param1);
324                 TD.WriteTraceSource(8, description, payload);
325             }
326         }
327         
328         /// <summary>
329         /// Check if trace definition is enabled
330         /// Event description ID=4212, Level=Warning, Channel=debug
331         /// </summary>
332         internal static bool LockRetryTimeoutIsEnabled()
333         {
334             return (FxTrace.ShouldTraceWarning 
335                         && (FxTrace.ShouldTraceWarningToTraceSource || TD.IsEtwEventEnabled(9)));
336         }
337         
338         /// <summary>
339         /// Gets trace definition like: Timeout trying to acquire the instance lock.  The operation did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout.
340         /// Event description ID=4212, Level=Warning, Channel=debug
341         /// </summary>
342         /// <param name="eventTraceActivity">The event trace activity</param>
343         /// <param name="param0">Parameter 0 for event: Timeout trying to acquire the instance lock.  The operation did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout.</param>
344         internal static void LockRetryTimeout(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0)
345         {
346             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
347             if (TD.IsEtwEventEnabled(9))
348             {
349                 TD.WriteEtwEvent(9, eventTraceActivity, param0, payload.AppDomainFriendlyName);
350             }
351             if (FxTrace.ShouldTraceWarningToTraceSource)
352             {
353                 string description = string.Format(Culture, ResourceManager.GetString("LockRetryTimeout", Culture), param0);
354                 TD.WriteTraceSource(9, description, payload);
355             }
356         }
357         
358         /// <summary>
359         /// Check if trace definition is enabled
360         /// Event description ID=4211, Level=Warning, Channel=debug
361         /// </summary>
362         internal static bool QueuingSqlRetryIsEnabled()
363         {
364             return (FxTrace.ShouldTraceWarning 
365                         && (FxTrace.ShouldTraceWarningToTraceSource || TD.IsEtwEventEnabled(10)));
366         }
367         
368         /// <summary>
369         /// Gets trace definition like: Queuing SQL retry with delay {0} milliseconds.
370         /// Event description ID=4211, Level=Warning, Channel=debug
371         /// </summary>
372         /// <param name="eventTraceActivity">The event trace activity</param>
373         /// <param name="param0">Parameter 0 for event: Queuing SQL retry with delay {0} milliseconds.</param>
374         internal static void QueuingSqlRetry(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0)
375         {
376             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
377             if (TD.IsEtwEventEnabled(10))
378             {
379                 TD.WriteEtwEvent(10, eventTraceActivity, param0, payload.AppDomainFriendlyName);
380             }
381             if (FxTrace.ShouldTraceWarningToTraceSource)
382             {
383                 string description = string.Format(Culture, ResourceManager.GetString("QueuingSqlRetry", Culture), param0);
384                 TD.WriteTraceSource(10, description, payload);
385             }
386         }
387         
388         /// <summary>
389         /// Check if trace definition is enabled
390         /// Event description ID=4213, Level=Error, Channel=debug
391         /// </summary>
392         internal static bool RunnableInstancesDetectionErrorIsEnabled()
393         {
394             return (FxTrace.ShouldTraceError 
395                         && (FxTrace.ShouldTraceErrorToTraceSource || TD.IsEtwEventEnabled(11)));
396         }
397         
398         /// <summary>
399         /// Gets trace definition like: Detection of runnable instances failed due to the following exception
400         /// Event description ID=4213, Level=Error, Channel=debug
401         /// </summary>
402         /// <param name="exception">Exception associated with the event</param>
403         internal static void RunnableInstancesDetectionError(System.Exception exception)
404         {
405             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, exception);
406             if (TD.IsEtwEventEnabled(11))
407             {
408                 TD.WriteEtwEvent(11, null, payload.SerializedException, payload.AppDomainFriendlyName);
409             }
410             if (FxTrace.ShouldTraceErrorToTraceSource)
411             {
412                 string description = string.Format(Culture, ResourceManager.GetString("RunnableInstancesDetectionError", Culture));
413                 TD.WriteTraceSource(11, description, payload);
414             }
415         }
416         
417         /// <summary>
418         /// Check if trace definition is enabled
419         /// Event description ID=4214, Level=Error, Channel=debug
420         /// </summary>
421         internal static bool InstanceLocksRecoveryErrorIsEnabled()
422         {
423             return (FxTrace.ShouldTraceError 
424                         && (FxTrace.ShouldTraceErrorToTraceSource || TD.IsEtwEventEnabled(12)));
425         }
426         
427         /// <summary>
428         /// Gets trace definition like: Recovering instance locks failed due to the following exception
429         /// Event description ID=4214, Level=Error, Channel=debug
430         /// </summary>
431         /// <param name="exception">Exception associated with the event</param>
432         internal static void InstanceLocksRecoveryError(System.Exception exception)
433         {
434             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, exception);
435             if (TD.IsEtwEventEnabled(12))
436             {
437                 TD.WriteEtwEvent(12, null, payload.SerializedException, payload.AppDomainFriendlyName);
438             }
439             if (FxTrace.ShouldTraceErrorToTraceSource)
440             {
441                 string description = string.Format(Culture, ResourceManager.GetString("InstanceLocksRecoveryError", Culture));
442                 TD.WriteTraceSource(12, description, payload);
443             }
444         }
445         
446         /// <summary>
447         /// Creates the event descriptors array
448         /// </summary>
449         // Critical = Sets the SecurityCritical member eventDescriptors
450         // Safe = We control what the event descriptors contain
451         [System.Security.SecuritySafeCriticalAttribute()]
452         static void CreateEventDescriptors()
453         {
454             System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
455                     new System.Runtime.Diagnostics.EventDescriptor(4201, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0xa1d, 0x1000000008000000),
456                     new System.Runtime.Diagnostics.EventDescriptor(4202, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0xa1d, 0x1000000008000000),
457                     new System.Runtime.Diagnostics.EventDescriptor(4203, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
458                     new System.Runtime.Diagnostics.EventDescriptor(4205, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
459                     new System.Runtime.Diagnostics.EventDescriptor(4206, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
460                     new System.Runtime.Diagnostics.EventDescriptor(4207, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008400000),
461                     new System.Runtime.Diagnostics.EventDescriptor(4208, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
462                     new System.Runtime.Diagnostics.EventDescriptor(4209, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
463                     new System.Runtime.Diagnostics.EventDescriptor(4210, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
464                     new System.Runtime.Diagnostics.EventDescriptor(4212, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
465                     new System.Runtime.Diagnostics.EventDescriptor(4211, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
466                     new System.Runtime.Diagnostics.EventDescriptor(4213, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
467                     new System.Runtime.Diagnostics.EventDescriptor(4214, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000)};
468             // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
469             // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
470             // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
471             // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
472             // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
473             System.Collections.Generic.List<ushort> e2eEvents = new System.Collections.Generic.List<ushort>(7);
474             e2eEvents.Add(4205);
475             e2eEvents.Add(4207);
476             e2eEvents.Add(4208);
477             e2eEvents.Add(4209);
478             e2eEvents.Add(4210);
479             e2eEvents.Add(4211);
480             e2eEvents.Add(4212);
481             FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
482             eventDescriptors = descriptors;
483         }
484         
485         /// <summary>
486         /// Ensures that the event descriptors array is initialized
487         /// </summary>
488         static void EnsureEventDescriptors()
489         {
490             if (eventDescriptorsCreated)
491             {
492                 return;
493             }
494             System.Threading.Monitor.Enter(syncLock);
495             try
496             {
497                 if (eventDescriptorsCreated)
498                 {
499                     return;
500                 }
501                 CreateEventDescriptors();
502                 eventDescriptorsCreated = true;
503             }
504             finally
505             {
506                 System.Threading.Monitor.Exit(syncLock);
507             }
508         }
509         
510         /// <summary>
511         /// Check if ETW tracing is enabled for the particular event
512         /// </summary>
513         /// <param name="eventIndex">The index of the event descriptor</param>
514         static bool IsEtwEventEnabled(int eventIndex)
515         {
516             if (FxTrace.Trace.IsEtwProviderEnabled)
517             {
518                 EnsureEventDescriptors();
519                 return FxTrace.IsEventEnabled(eventIndex);
520             }
521             return false;
522         }
523         
524         /// <summary>
525         /// Writes ETW trace event
526         ///</summary>
527         /// <param name="eventIndex">The index of the event descriptor</param>>
528         /// <param name="eventParam0">A parameter of the ETW event</param>>
529         /// <param name="eventParam1">A parameter of the ETW event</param>>
530         /// <param name="eventParam2">A parameter of the ETW event</param>>
531         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
532         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
533         [System.Security.SecuritySafeCriticalAttribute()]
534         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2)
535         {
536             EnsureEventDescriptors();
537             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2);
538         }
539         
540         /// <summary>
541         /// Writes ETW trace event
542         ///</summary>
543         /// <param name="eventIndex">The index of the event descriptor</param>>
544         /// <param name="eventParam0">A parameter of the ETW event</param>>
545         /// <param name="eventParam1">A parameter of the ETW event</param>>
546         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
547         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
548         [System.Security.SecuritySafeCriticalAttribute()]
549         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1)
550         {
551             EnsureEventDescriptors();
552             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1);
553         }
554         
555         /// <summary>
556         /// Writes ETW trace event
557         ///</summary>
558         /// <param name="eventIndex">The index of the event descriptor</param>>
559         /// <param name="eventParam0">A parameter of the ETW event</param>>
560         /// <param name="eventParam1">A parameter of the ETW event</param>>
561         /// <param name="eventParam2">A parameter of the ETW event</param>>
562         /// <param name="eventParam3">A parameter of the ETW event</param>>
563         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
564         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
565         [System.Security.SecuritySafeCriticalAttribute()]
566         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3)
567         {
568             EnsureEventDescriptors();
569             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3);
570         }
571         
572         /// <summary>
573         /// write a trace source into the diagnostic trace
574         /// </summary>
575         /// <param name="eventIndex">The index of the event descriptor</param>
576         /// <param name="description">The description to write</param>
577         /// <param name="payload">The trace payload</param>
578         // Critical = Calls SecurityCritical method EtwDiagnosticTrace.WriteTraceSource
579         // Safe = We only allow setting of provider id from SecurityCritical code
580         [System.Security.SecuritySafeCriticalAttribute()]
581         static void WriteTraceSource(int eventIndex, string description, TracePayload payload)
582         {
583             EnsureEventDescriptors();
584             FxTrace.Trace.WriteTraceSource(ref eventDescriptors[eventIndex], description, payload);
585         }
586     }
587 }
588