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.ServiceModel.Activities
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 
TD()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.ServiceModel.Activities.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=57398, Level=Warning, Channel=Analytic
65         /// </summary>
MaxInstancesExceededIsEnabled()66         internal static bool MaxInstancesExceededIsEnabled()
67         {
68             return (FxTrace.ShouldTraceWarning
69                         && (FxTrace.ShouldTraceWarningToTraceSource || TD.IsEtwEventEnabled(0)));
70         }
71 
72         /// <summary>
73         /// Gets trace definition like: The system hit the limit set for throttle 'MaxConcurrentInstances'. Limit for this throttle was set to {0}. Throttle value can be changed by modifying attribute 'maxConcurrentInstances' in serviceThrottle element or by modifying 'MaxConcurrentInstances' property on behavior ServiceThrottlingBehavior.
74         /// Event description ID=57398, Level=Warning, Channel=Analytic
75         /// </summary>
76         /// <param name="limit">Parameter 0 for event: The system hit the limit set for throttle 'MaxConcurrentInstances'. Limit for this throttle was set to {0}. Throttle value can be changed by modifying attribute 'maxConcurrentInstances' in serviceThrottle element or by modifying 'MaxConcurrentInstances' property on behavior ServiceThrottlingBehavior.</param>
MaxInstancesExceeded(int limit)77         internal static void MaxInstancesExceeded(int limit)
78         {
79             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
80             if (TD.IsEtwEventEnabled(0))
81             {
82                 TD.WriteEtwEvent(0, null, limit, payload.AppDomainFriendlyName);
83             }
84             if (FxTrace.ShouldTraceWarningToTraceSource)
85             {
86                 string description = string.Format(Culture, ResourceManager.GetString("MaxInstancesExceeded", Culture), limit);
87                 TD.WriteTraceSource(0, description, payload);
88             }
89         }
90 
91         /// <summary>
92         /// Check if trace definition is enabled
93         /// Event description ID=3501, Level=Informational, Channel=Analytic
94         /// </summary>
InferredContractDescriptionIsEnabled()95         internal static bool InferredContractDescriptionIsEnabled()
96         {
97             return (FxTrace.ShouldTraceInformation
98                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(1)));
99         }
100 
101         /// <summary>
102         /// Gets trace definition like: ContractDescription with Name='{0}' and Namespace='{1}' has been inferred from WorkflowService.
103         /// Event description ID=3501, Level=Informational, Channel=Analytic
104         /// </summary>
105         /// <param name="param0">Parameter 0 for event: ContractDescription with Name='{0}' and Namespace='{1}' has been inferred from WorkflowService.</param>
106         /// <param name="param1">Parameter 1 for event: ContractDescription with Name='{0}' and Namespace='{1}' has been inferred from WorkflowService.</param>
InferredContractDescription(string param0, string param1)107         internal static void InferredContractDescription(string param0, string param1)
108         {
109             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
110             if (TD.IsEtwEventEnabled(1))
111             {
112                 TD.WriteEtwEvent(1, null, param0, param1, payload.AppDomainFriendlyName);
113             }
114             if (FxTrace.ShouldTraceInformationToTraceSource)
115             {
116                 string description = string.Format(Culture, ResourceManager.GetString("InferredContractDescription", Culture), param0, param1);
117                 TD.WriteTraceSource(1, description, payload);
118             }
119         }
120 
121         /// <summary>
122         /// Check if trace definition is enabled
123         /// Event description ID=3502, Level=Informational, Channel=Analytic
124         /// </summary>
InferredOperationDescriptionIsEnabled()125         internal static bool InferredOperationDescriptionIsEnabled()
126         {
127             return (FxTrace.ShouldTraceInformation
128                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(2)));
129         }
130 
131         /// <summary>
132         /// Gets trace definition like: OperationDescription with Name='{0}' in contract '{1}' has been inferred from WorkflowService. IsOneWay={2}.
133         /// Event description ID=3502, Level=Informational, Channel=Analytic
134         /// </summary>
135         /// <param name="param0">Parameter 0 for event: OperationDescription with Name='{0}' in contract '{1}' has been inferred from WorkflowService. IsOneWay={2}.</param>
136         /// <param name="param1">Parameter 1 for event: OperationDescription with Name='{0}' in contract '{1}' has been inferred from WorkflowService. IsOneWay={2}.</param>
137         /// <param name="param2">Parameter 2 for event: OperationDescription with Name='{0}' in contract '{1}' has been inferred from WorkflowService. IsOneWay={2}.</param>
InferredOperationDescription(string param0, string param1, string param2)138         internal static void InferredOperationDescription(string param0, string param1, string param2)
139         {
140             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
141             if (TD.IsEtwEventEnabled(2))
142             {
143                 TD.WriteEtwEvent(2, null, param0, param1, param2, payload.AppDomainFriendlyName);
144             }
145             if (FxTrace.ShouldTraceInformationToTraceSource)
146             {
147                 string description = string.Format(Culture, ResourceManager.GetString("InferredOperationDescription", Culture), param0, param1, param2);
148                 TD.WriteTraceSource(2, description, payload);
149             }
150         }
151 
152         /// <summary>
153         /// Check if trace definition is enabled
154         /// Event description ID=3503, Level=Warning, Channel=Analytic
155         /// </summary>
DuplicateCorrelationQueryIsEnabled()156         internal static bool DuplicateCorrelationQueryIsEnabled()
157         {
158             return (FxTrace.ShouldTraceWarning
159                         && (FxTrace.ShouldTraceWarningToTraceSource || TD.IsEtwEventEnabled(3)));
160         }
161 
162         /// <summary>
163         /// Gets trace definition like: A duplicate CorrelationQuery was found with Where='{0}'. This duplicate query will not be used when calculating correlation.
164         /// Event description ID=3503, Level=Warning, Channel=Analytic
165         /// </summary>
166         /// <param name="param0">Parameter 0 for event: A duplicate CorrelationQuery was found with Where='{0}'. This duplicate query will not be used when calculating correlation.</param>
DuplicateCorrelationQuery(string param0)167         internal static void DuplicateCorrelationQuery(string param0)
168         {
169             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
170             if (TD.IsEtwEventEnabled(3))
171             {
172                 TD.WriteEtwEvent(3, null, param0, payload.AppDomainFriendlyName);
173             }
174             if (FxTrace.ShouldTraceWarningToTraceSource)
175             {
176                 string description = string.Format(Culture, ResourceManager.GetString("DuplicateCorrelationQuery", Culture), param0);
177                 TD.WriteTraceSource(3, description, payload);
178             }
179         }
180 
181         /// <summary>
182         /// Check if trace definition is enabled
183         /// Event description ID=3507, Level=Informational, Channel=Analytic
184         /// </summary>
ServiceEndpointAddedIsEnabled()185         internal static bool ServiceEndpointAddedIsEnabled()
186         {
187             return (FxTrace.ShouldTraceInformation
188                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(4)));
189         }
190 
191         /// <summary>
192         /// Gets trace definition like: A service endpoint has been added for address '{0}', binding '{1}', and contract '{2}'.
193         /// Event description ID=3507, Level=Informational, Channel=Analytic
194         /// </summary>
195         /// <param name="param0">Parameter 0 for event: A service endpoint has been added for address '{0}', binding '{1}', and contract '{2}'.</param>
196         /// <param name="param1">Parameter 1 for event: A service endpoint has been added for address '{0}', binding '{1}', and contract '{2}'.</param>
197         /// <param name="param2">Parameter 2 for event: A service endpoint has been added for address '{0}', binding '{1}', and contract '{2}'.</param>
ServiceEndpointAdded(string param0, string param1, string param2)198         internal static void ServiceEndpointAdded(string param0, string param1, string param2)
199         {
200             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
201             if (TD.IsEtwEventEnabled(4))
202             {
203                 TD.WriteEtwEvent(4, null, param0, param1, param2, payload.AppDomainFriendlyName);
204             }
205             if (FxTrace.ShouldTraceInformationToTraceSource)
206             {
207                 string description = string.Format(Culture, ResourceManager.GetString("ServiceEndpointAdded", Culture), param0, param1, param2);
208                 TD.WriteTraceSource(4, description, payload);
209             }
210         }
211 
212         /// <summary>
213         /// Check if trace definition is enabled
214         /// Event description ID=440, Level=informational, Channel=Analytic
215         /// </summary>
StartSignpostEventIsEnabled()216         internal static bool StartSignpostEventIsEnabled()
217         {
218             return (FxTrace.ShouldTraceInformation
219                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(5)));
220         }
221 
222         /// <summary>
223         /// Gets trace definition like: Activity boundary.
224         /// Event description ID=440, Level=informational, Channel=Analytic
225         /// </summary>
226         /// <param name="traceRecord">Extended data (TraceRecord) for the event</param>
StartSignpostEvent(TraceRecord traceRecord)227         internal static void StartSignpostEvent(TraceRecord traceRecord)
228         {
229             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, traceRecord, null);
230             if (TD.IsEtwEventEnabled(5))
231             {
232                 TD.WriteEtwEvent(5, null, payload.ExtendedData, payload.AppDomainFriendlyName);
233             }
234             if (FxTrace.ShouldTraceInformationToTraceSource)
235             {
236                 string description = string.Format(Culture, ResourceManager.GetString("StartSignpostEvent", Culture));
237                 TD.WriteTraceSource(5, description, payload);
238             }
239         }
240 
241         /// <summary>
242         /// Check if trace definition is enabled
243         /// Event description ID=441, Level=informational, Channel=Analytic
244         /// </summary>
StopSignpostEventIsEnabled()245         internal static bool StopSignpostEventIsEnabled()
246         {
247             return (FxTrace.ShouldTraceInformation
248                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(6)));
249         }
250 
251         /// <summary>
252         /// Gets trace definition like: Activity boundary.
253         /// Event description ID=441, Level=informational, Channel=Analytic
254         /// </summary>
255         /// <param name="traceRecord">Extended data (TraceRecord) for the event</param>
StopSignpostEvent(TraceRecord traceRecord)256         internal static void StopSignpostEvent(TraceRecord traceRecord)
257         {
258             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, traceRecord, null);
259             if (TD.IsEtwEventEnabled(6))
260             {
261                 TD.WriteEtwEvent(6, null, payload.ExtendedData, payload.AppDomainFriendlyName);
262             }
263             if (FxTrace.ShouldTraceInformationToTraceSource)
264             {
265                 string description = string.Format(Culture, ResourceManager.GetString("StopSignpostEvent", Culture));
266                 TD.WriteTraceSource(6, description, payload);
267             }
268         }
269 
270         /// <summary>
271         /// Check if trace definition is enabled
272         /// Event description ID=3550, Level=Informational, Channel=Analytic
273         /// </summary>
BufferOutOfOrderMessageNoInstanceIsEnabled()274         internal static bool BufferOutOfOrderMessageNoInstanceIsEnabled()
275         {
276             return (FxTrace.ShouldTraceInformation
277                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(7)));
278         }
279 
280         /// <summary>
281         /// Gets trace definition like: Operation '{0}' cannot be performed at this time. Another attempt will be made when the service instance is ready to process this particular operation.
282         /// Event description ID=3550, Level=Informational, Channel=Analytic
283         /// </summary>
284         /// <param name="param0">Parameter 0 for event: Operation '{0}' cannot be performed at this time. Another attempt will be made when the service instance is ready to process this particular operation.</param>
BufferOutOfOrderMessageNoInstance(string param0)285         internal static void BufferOutOfOrderMessageNoInstance(string param0)
286         {
287             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
288             if (TD.IsEtwEventEnabled(7))
289             {
290                 TD.WriteEtwEvent(7, null, param0, payload.AppDomainFriendlyName);
291             }
292             if (FxTrace.ShouldTraceInformationToTraceSource)
293             {
294                 string description = string.Format(Culture, ResourceManager.GetString("BufferOutOfOrderMessageNoInstance", Culture), param0);
295                 TD.WriteTraceSource(7, description, payload);
296             }
297         }
298 
299         /// <summary>
300         /// Check if trace definition is enabled
301         /// Event description ID=3551, Level=Informational, Channel=Analytic
302         /// </summary>
BufferOutOfOrderMessageNoBookmarkIsEnabled()303         internal static bool BufferOutOfOrderMessageNoBookmarkIsEnabled()
304         {
305             return (FxTrace.ShouldTraceInformation
306                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(8)));
307         }
308 
309         /// <summary>
310         /// Gets trace definition like: Operation '{1}' on service instance '{0}' cannot be performed at this time. Another attempt will be made when the service instance is ready to process this particular operation.
311         /// Event description ID=3551, Level=Informational, Channel=Analytic
312         /// </summary>
313         /// <param name="eventTraceActivity">The event trace activity</param>
314         /// <param name="param0">Parameter 0 for event: Operation '{1}' on service instance '{0}' cannot be performed at this time. Another attempt will be made when the service instance is ready to process this particular operation.</param>
315         /// <param name="param1">Parameter 1 for event: Operation '{1}' on service instance '{0}' cannot be performed at this time. Another attempt will be made when the service instance is ready to process this particular operation.</param>
BufferOutOfOrderMessageNoBookmark(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0, string param1)316         internal static void BufferOutOfOrderMessageNoBookmark(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string param0, string param1)
317         {
318             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
319             if (TD.IsEtwEventEnabled(8))
320             {
321                 TD.WriteEtwEvent(8, eventTraceActivity, param0, param1, payload.AppDomainFriendlyName);
322             }
323             if (FxTrace.ShouldTraceInformationToTraceSource)
324             {
325                 string description = string.Format(Culture, ResourceManager.GetString("BufferOutOfOrderMessageNoBookmark", Culture), param0, param1);
326                 TD.WriteTraceSource(8, description, payload);
327             }
328         }
329 
330         /// <summary>
331         /// Check if trace definition is enabled
332         /// Event description ID=3552, Level=Warning, Channel=Analytic
333         /// </summary>
MaxPendingMessagesPerChannelExceededIsEnabled()334         internal static bool MaxPendingMessagesPerChannelExceededIsEnabled()
335         {
336             return (FxTrace.ShouldTraceWarning
337                         && (FxTrace.ShouldTraceWarningToTraceSource || TD.IsEtwEventEnabled(9)));
338         }
339 
340         /// <summary>
341         /// Gets trace definition like: The throttle 'MaxPendingMessagesPerChannel' limit of  '{0}' was hit. To increase this limit, adjust the MaxPendingMessagesPerChannel property on BufferedReceiveServiceBehavior.
342         /// Event description ID=3552, Level=Warning, Channel=Analytic
343         /// </summary>
344         /// <param name="limit">Parameter 0 for event: The throttle 'MaxPendingMessagesPerChannel' limit of  '{0}' was hit. To increase this limit, adjust the MaxPendingMessagesPerChannel property on BufferedReceiveServiceBehavior.</param>
MaxPendingMessagesPerChannelExceeded(int limit)345         internal static void MaxPendingMessagesPerChannelExceeded(int limit)
346         {
347             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
348             if (TD.IsEtwEventEnabled(9))
349             {
350                 TD.WriteEtwEvent(9, null, limit, payload.AppDomainFriendlyName);
351             }
352             if (FxTrace.ShouldTraceWarningToTraceSource)
353             {
354                 string description = string.Format(Culture, ResourceManager.GetString("MaxPendingMessagesPerChannelExceeded", Culture), limit);
355                 TD.WriteTraceSource(9, description, payload);
356             }
357         }
358 
359         /// <summary>
360         /// Check if trace definition is enabled
361         /// Event description ID=3555, Level=informational, Channel=debug
362         /// </summary>
CreateWorkflowServiceHostStartIsEnabled()363         internal static bool CreateWorkflowServiceHostStartIsEnabled()
364         {
365             return (FxTrace.ShouldTraceInformation && TD.IsEtwEventEnabled(10));
366         }
367 
368         /// <summary>
369         /// Gets trace definition like: CreateWorkflowServiceHost start
370         /// Event description ID=3555, Level=informational, Channel=debug
371         /// </summary>
CreateWorkflowServiceHostStart()372         internal static void CreateWorkflowServiceHostStart()
373         {
374             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
375             if (TD.IsEtwEventEnabled(10))
376             {
377                 TD.WriteEtwEvent(10, null, payload.AppDomainFriendlyName);
378             }
379         }
380 
381         /// <summary>
382         /// Check if trace definition is enabled
383         /// Event description ID=3556, Level=informational, Channel=debug
384         /// </summary>
CreateWorkflowServiceHostStopIsEnabled()385         internal static bool CreateWorkflowServiceHostStopIsEnabled()
386         {
387             return (FxTrace.ShouldTraceInformation && TD.IsEtwEventEnabled(11));
388         }
389 
390         /// <summary>
391         /// Gets trace definition like: CreateWorkflowServiceHost Stop
392         /// Event description ID=3556, Level=informational, Channel=debug
393         /// </summary>
CreateWorkflowServiceHostStop()394         internal static void CreateWorkflowServiceHostStop()
395         {
396             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
397             if (TD.IsEtwEventEnabled(11))
398             {
399                 TD.WriteEtwEvent(11, null, payload.AppDomainFriendlyName);
400             }
401         }
402 
403         /// <summary>
404         /// Check if trace definition is enabled
405         /// Event description ID=3557, Level=informational, Channel=Analytic
406         /// </summary>
TransactedReceiveScopeEndCommitFailedIsEnabled()407         internal static bool TransactedReceiveScopeEndCommitFailedIsEnabled()
408         {
409             return (FxTrace.ShouldTraceInformation
410                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(12)));
411         }
412 
413         /// <summary>
414         /// Gets trace definition like: The call to EndCommit on the CommittableTransaction with id = '{0}' threw a TransactionException with the following message: '{1}'.
415         /// Event description ID=3557, Level=informational, Channel=Analytic
416         /// </summary>
417         /// <param name="param0">Parameter 0 for event: The call to EndCommit on the CommittableTransaction with id = '{0}' threw a TransactionException with the following message: '{1}'.</param>
418         /// <param name="param1">Parameter 1 for event: The call to EndCommit on the CommittableTransaction with id = '{0}' threw a TransactionException with the following message: '{1}'.</param>
TransactedReceiveScopeEndCommitFailed(string param0, string param1)419         internal static void TransactedReceiveScopeEndCommitFailed(string param0, string param1)
420         {
421             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
422             if (TD.IsEtwEventEnabled(12))
423             {
424                 TD.WriteEtwEvent(12, null, param0, param1, payload.AppDomainFriendlyName);
425             }
426             if (FxTrace.ShouldTraceInformationToTraceSource)
427             {
428                 string description = string.Format(Culture, ResourceManager.GetString("TransactedReceiveScopeEndCommitFailed", Culture), param0, param1);
429                 TD.WriteTraceSource(12, description, payload);
430             }
431         }
432 
433         /// <summary>
434         /// Check if trace definition is enabled
435         /// Event description ID=3508, Level=verbose, Channel=Analytic
436         /// </summary>
TrackingProfileNotFoundIsEnabled()437         internal static bool TrackingProfileNotFoundIsEnabled()
438         {
439             return (FxTrace.ShouldTraceVerbose
440                         && (FxTrace.ShouldTraceVerboseToTraceSource || TD.IsEtwEventEnabled(13)));
441         }
442 
443         /// <summary>
444         /// Gets trace definition like: TrackingProfile '{0}' for the ActivityDefinitionId '{1}' not found. Either the TrackingProfile is not found in the config file or the ActivityDefinitionId does not match.
445         /// Event description ID=3508, Level=verbose, Channel=Analytic
446         /// </summary>
447         /// <param name="TrackingProfile">Parameter 0 for event: TrackingProfile '{0}' for the ActivityDefinitionId '{1}' not found. Either the TrackingProfile is not found in the config file or the ActivityDefinitionId does not match.</param>
448         /// <param name="ActivityDefinitionId">Parameter 1 for event: TrackingProfile '{0}' for the ActivityDefinitionId '{1}' not found. Either the TrackingProfile is not found in the config file or the ActivityDefinitionId does not match.</param>
TrackingProfileNotFound(string TrackingProfile, string ActivityDefinitionId)449         internal static void TrackingProfileNotFound(string TrackingProfile, string ActivityDefinitionId)
450         {
451             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
452             if (TD.IsEtwEventEnabled(13))
453             {
454                 TD.WriteEtwEvent(13, null, TrackingProfile, ActivityDefinitionId, payload.AppDomainFriendlyName);
455             }
456             if (FxTrace.ShouldTraceVerboseToTraceSource)
457             {
458                 string description = string.Format(Culture, ResourceManager.GetString("TrackingProfileNotFound", Culture), TrackingProfile, ActivityDefinitionId);
459                 TD.WriteTraceSource(13, description, payload);
460             }
461         }
462 
463         /// <summary>
464         /// Check if trace definition is enabled
465         /// Event description ID=225, Level=informational, Channel=Analytic
466         /// </summary>
TraceCorrelationKeysIsEnabled()467         internal static bool TraceCorrelationKeysIsEnabled()
468         {
469             return (FxTrace.ShouldTraceInformation
470                         && (FxTrace.ShouldTraceInformationToTraceSource || TD.IsEtwEventEnabled(14)));
471         }
472 
473         /// <summary>
474         /// Gets trace definition like: Calculated correlation key '{0}' using values '{1}' in parent scope '{2}'.
475         /// Event description ID=225, Level=informational, Channel=Analytic
476         /// </summary>
477         /// <param name="InstanceKey">Parameter 0 for event: Calculated correlation key '{0}' using values '{1}' in parent scope '{2}'.</param>
478         /// <param name="Values">Parameter 1 for event: Calculated correlation key '{0}' using values '{1}' in parent scope '{2}'.</param>
479         /// <param name="ParentScope">Parameter 2 for event: Calculated correlation key '{0}' using values '{1}' in parent scope '{2}'.</param>
TraceCorrelationKeys(System.Guid InstanceKey, string Values, string ParentScope)480         internal static void TraceCorrelationKeys(System.Guid InstanceKey, string Values, string ParentScope)
481         {
482             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
483             if (TD.IsEtwEventEnabled(14))
484             {
485                 TD.WriteEtwEvent(14, null, InstanceKey, Values, ParentScope, payload.HostReference, payload.AppDomainFriendlyName);
486             }
487             if (FxTrace.ShouldTraceInformationToTraceSource)
488             {
489                 string description = string.Format(Culture, ResourceManager.GetString("TraceCorrelationKeys", Culture), InstanceKey, Values, ParentScope);
490                 TD.WriteTraceSource(14, description, payload);
491             }
492         }
493 
494         /// <summary>
495         /// Check if trace definition is enabled
496         /// Event description ID=2023, Level=Verbose, Channel=Debug
497         /// </summary>
SendMessageChannelCacheMissIsEnabled()498         internal static bool SendMessageChannelCacheMissIsEnabled()
499         {
500             return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(15));
501         }
502 
503         /// <summary>
504         /// Gets trace definition like: SendMessageChannelCache miss
505         /// Event description ID=2023, Level=Verbose, Channel=Debug
506         /// </summary>
SendMessageChannelCacheMiss()507         internal static void SendMessageChannelCacheMiss()
508         {
509             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
510             if (TD.IsEtwEventEnabled(15))
511             {
512                 TD.WriteEtwEvent(15, null, payload.AppDomainFriendlyName);
513             }
514         }
515 
516         /// <summary>
517         /// Check if trace definition is enabled
518         /// Event description ID=1450, Level=Informational, Channel=Debug
519         /// </summary>
WfMessageSentIsEnabled()520         internal static bool WfMessageSentIsEnabled()
521         {
522             return (FxTrace.ShouldTraceInformation && TD.IsEtwEventEnabled(16));
523         }
524 
525         /// <summary>
526         /// Gets trace definition like: Message sent from workflow
527         /// Event description ID=1450, Level=Informational, Channel=Debug
528         /// </summary>
529         /// <param name="eventTraceActivity">The event trace activity</param>
530         /// <param name="relatedActivityId">The related event activity Id</param>
WfMessageSent(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, System.Guid relatedActivityId)531         internal static void WfMessageSent(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, System.Guid relatedActivityId)
532         {
533             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
534             if (TD.IsEtwEventEnabled(16))
535             {
536                 TD.WriteEtwTransferEvent(16, eventTraceActivity, relatedActivityId, payload.AppDomainFriendlyName);
537             }
538         }
539 
540         /// <summary>
541         /// Check if trace definition is enabled
542         /// Event description ID=1449, Level=Informational, Channel=Debug
543         /// </summary>
WfMessageReceivedIsEnabled()544         internal static bool WfMessageReceivedIsEnabled()
545         {
546             return (FxTrace.ShouldTraceInformation && TD.IsEtwEventEnabled(17));
547         }
548 
549         /// <summary>
550         /// Gets trace definition like: Message received by workflow
551         /// Event description ID=1449, Level=Informational, Channel=Debug
552         /// </summary>
553         /// <param name="eventTraceActivity">The event trace activity</param>
554         /// <param name="relatedActivityId">The related event activity Id</param>
WfMessageReceived(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, System.Guid relatedActivityId)555         internal static void WfMessageReceived(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, System.Guid relatedActivityId)
556         {
557             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
558             if (TD.IsEtwEventEnabled(17))
559             {
560                 TD.WriteEtwTransferEvent(17, eventTraceActivity, relatedActivityId, payload.AppDomainFriendlyName);
561             }
562         }
563 
564         /// <summary>
565         /// Check if trace definition is enabled
566         /// Event description ID=1436, Level=verbose, Channel=analytic
567         /// </summary>
PendingMessagesPerChannelRatioIsEnabled()568         internal static bool PendingMessagesPerChannelRatioIsEnabled()
569         {
570             return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(18));
571         }
572 
573         /// <summary>
574         /// Gets trace definition like: Pending messages per channel ratio: {0}/{1}
575         /// Event description ID=1436, Level=verbose, Channel=analytic
576         /// </summary>
577         /// <param name="cur">Parameter 0 for event: Pending messages per channel ratio: {0}/{1}</param>
578         /// <param name="max">Parameter 1 for event: Pending messages per channel ratio: {0}/{1}</param>
PendingMessagesPerChannelRatio(int cur, int max)579         internal static void PendingMessagesPerChannelRatio(int cur, int max)
580         {
581             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null);
582             if (TD.IsEtwEventEnabled(18))
583             {
584                 TD.WriteEtwEvent(18, null, cur, max, payload.AppDomainFriendlyName);
585             }
586         }
587 
588         /// <summary>
589         /// Creates the event descriptors array
590         /// </summary>
591         // Critical = Sets the SecurityCritical member eventDescriptors
592         // Safe = We control what the event descriptors contain
593         [System.Security.SecuritySafeCriticalAttribute()]
CreateEventDescriptors()594         static void CreateEventDescriptors()
595         {
596             System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
597                     new System.Runtime.Diagnostics.EventDescriptor(57398, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa22, 0x2000000004000000),
598                     new System.Runtime.Diagnostics.EventDescriptor(3501, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)69, 0x9f4, 0x2000000004000000),
599                     new System.Runtime.Diagnostics.EventDescriptor(3502, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)70, 0x9f4, 0x2000000004000000),
600                     new System.Runtime.Diagnostics.EventDescriptor(3503, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)28, 0x9db, 0x2000000004000000),
601                     new System.Runtime.Diagnostics.EventDescriptor(3507, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9cb, 0x2000000004000000),
602                     new System.Runtime.Diagnostics.EventDescriptor(440, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa1c, 0x2000000004080000),
603                     new System.Runtime.Diagnostics.EventDescriptor(441, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa1c, 0x2000000004080000),
604                     new System.Runtime.Diagnostics.EventDescriptor(3550, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)11, 0x9cc, 0x2000000004000000),
605                     new System.Runtime.Diagnostics.EventDescriptor(3551, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)10, 0x9cc, 0x2000000004000000),
606                     new System.Runtime.Diagnostics.EventDescriptor(3552, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa00, 0x2000000004400000),
607                     new System.Runtime.Diagnostics.EventDescriptor(3555, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0x9de, 0x1000000000000080),
608                     new System.Runtime.Diagnostics.EventDescriptor(3556, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0x9de, 0x1000000000000080),
609                     new System.Runtime.Diagnostics.EventDescriptor(3557, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa08, 0x2000000004000000),
610                     new System.Runtime.Diagnostics.EventDescriptor(3508, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)124, 0xa25, 0x2000000004000000),
611                     new System.Runtime.Diagnostics.EventDescriptor(225, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9db, 0x2000000004080000),
612                     new System.Runtime.Diagnostics.EventDescriptor(2023, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)76, 0x9fa, 0x1000000001000000),
613                     new System.Runtime.Diagnostics.EventDescriptor(1450, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Send, 0xa2e, 0x1000000004000000),
614                     new System.Runtime.Diagnostics.EventDescriptor(1449, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Receive, 0xa2e, 0x1000000004000000),
615                     new System.Runtime.Diagnostics.EventDescriptor(1436, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa00, 0x2000000000400000)};
616             // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
617             // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
618             // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
619             // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
620             // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
621             System.Collections.Generic.List<ushort> e2eEvents = new System.Collections.Generic.List<ushort>(3);
622             e2eEvents.Add(1449);
623             e2eEvents.Add(1450);
624             e2eEvents.Add(3551);
625             FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
626             eventDescriptors = descriptors;
627         }
628 
629         /// <summary>
630         /// Ensures that the event descriptors array is initialized
631         /// </summary>
EnsureEventDescriptors()632         static void EnsureEventDescriptors()
633         {
634             if (eventDescriptorsCreated)
635             {
636                 return;
637             }
638             System.Threading.Monitor.Enter(syncLock);
639             try
640             {
641                 if (eventDescriptorsCreated)
642                 {
643                     return;
644                 }
645                 CreateEventDescriptors();
646                 eventDescriptorsCreated = true;
647             }
648             finally
649             {
650                 System.Threading.Monitor.Exit(syncLock);
651             }
652         }
653 
654         /// <summary>
655         /// Check if ETW tracing is enabled for the particular event
656         /// </summary>
657         /// <param name="eventIndex">The index of the event descriptor</param>
IsEtwEventEnabled(int eventIndex)658         static bool IsEtwEventEnabled(int eventIndex)
659         {
660             if (FxTrace.Trace.IsEtwProviderEnabled)
661             {
662                 EnsureEventDescriptors();
663                 return FxTrace.IsEventEnabled(eventIndex);
664             }
665             return false;
666         }
667 
668         /// <summary>
669         /// Writes ETW trace event
670         ///</summary>
671         /// <param name="eventIndex">The index of the event descriptor</param>>
672         /// <param name="eventParam0">A parameter of the ETW event</param>>
673         /// <param name="eventParam1">A parameter of the ETW event</param>>
674         /// <param name="eventParam2">A parameter of the ETW event</param>>
675         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
676         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
677         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, int eventParam1, string eventParam2)678         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, int eventParam1, string eventParam2)
679         {
680             EnsureEventDescriptors();
681             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2);
682         }
683 
684         /// <summary>
685         /// Writes ETW trace event
686         ///</summary>
687         /// <param name="eventIndex">The index of the event descriptor</param>>
688         /// <param name="eventParam0">A parameter of the ETW event</param>>
689         /// <param name="eventParam1">A parameter of the ETW event</param>>
690         /// <param name="eventParam2">A parameter of the ETW event</param>>
691         /// <param name="eventParam3">A parameter of the ETW event</param>>
692         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
693         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
694         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3)695         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3)
696         {
697             EnsureEventDescriptors();
698             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3);
699         }
700 
701         /// <summary>
702         /// Writes ETW trace event
703         ///</summary>
704         /// <param name="eventIndex">The index of the event descriptor</param>>
705         /// <param name="eventParam0">A parameter of the ETW event</param>>
706         /// <param name="eventParam1">A parameter of the ETW event</param>>
707         /// <param name="eventParam2">A parameter of the ETW event</param>>
708         /// <param name="eventParam3">A parameter of the ETW event</param>>
709         /// <param name="eventParam4">A parameter of the ETW event</param>>
710         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
711         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
712         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3, string eventParam4)713         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3, string eventParam4)
714         {
715             EnsureEventDescriptors();
716             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3, eventParam4);
717         }
718 
719         /// <summary>
720         /// Writes ETW trace event
721         ///</summary>
722         /// <param name="eventIndex">The index of the event descriptor</param>>
723         /// <param name="eventParam0">A parameter of the ETW event</param>>
724         /// <param name="eventParam1">A parameter of the ETW event</param>>
725         /// <param name="eventParam2">A parameter of the ETW event</param>>
726         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
727         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
728         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2)729         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2)
730         {
731             EnsureEventDescriptors();
732             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2);
733         }
734 
735         /// <summary>
736         /// Writes ETW trace event
737         ///</summary>
738         /// <param name="eventIndex">The index of the event descriptor</param>>
739         /// <param name="eventParam0">A parameter of the ETW event</param>>
740         /// <param name="eventParam1">A parameter of the ETW event</param>>
741         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
742         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
743         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1)744         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1)
745         {
746             EnsureEventDescriptors();
747             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1);
748         }
749 
750         /// <summary>
751         /// Writes ETW trace event
752         ///</summary>
753         /// <param name="eventIndex">The index of the event descriptor</param>>
754         /// <param name="eventParam0">A parameter of the ETW event</param>>
755         /// <param name="eventParam1">A parameter of the ETW event</param>>
756         /// <param name="eventParam2">A parameter of the ETW event</param>>
757         /// <param name="eventParam3">A parameter of the ETW event</param>>
758         /// <param name="eventParam4">A parameter of the ETW event</param>>
759         /// <param name="eventParam5">A parameter of the ETW event</param>>
760         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
761         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
762         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, System.Guid eventParam1, string eventParam2, string eventParam3, string eventParam4, string eventParam5)763         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, System.Guid eventParam1, string eventParam2, string eventParam3, string eventParam4, string eventParam5)
764         {
765             EnsureEventDescriptors();
766             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3, eventParam4, eventParam5);
767         }
768 
769         /// <summary>
770         /// Writes ETW trace event
771         ///</summary>
772         /// <param name="eventIndex">The index of the event descriptor</param>>
773         /// <param name="eventParam0">A parameter of the ETW event</param>>
774         /// <param name="eventParam1">A parameter of the ETW event</param>>
775         /// <param name="eventParam2">A parameter of the ETW event</param>>
776         /// <param name="eventParam3">A parameter of the ETW event</param>>
777         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
778         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
779         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, int eventParam1, int eventParam2, string eventParam3)780         static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, int eventParam1, int eventParam2, string eventParam3)
781         {
782             EnsureEventDescriptors();
783             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3);
784         }
785 
786         /// <summary>
787         /// Writes ETW trace event
788         ///</summary>
789         /// <param name="eventIndex">The index of the event descriptor</param>>
790         /// <param name="eventParam0">A parameter of the ETW event</param>>
791         /// <param name="eventParam1">A parameter of the ETW event</param>>
792         /// <param name="eventParam2">A parameter of the ETW event</param>>
793         // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
794         // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
795         [System.Security.SecuritySafeCriticalAttribute()]
WriteEtwTransferEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, System.Guid eventParam1, string eventParam2)796         static bool WriteEtwTransferEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, System.Guid eventParam1, string eventParam2)
797         {
798             EnsureEventDescriptors();
799             return FxTrace.Trace.EtwProvider.WriteTransferEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2);
800         }
801 
802         /// <summary>
803         /// write a trace source into the diagnostic trace
804         /// </summary>
805         /// <param name="eventIndex">The index of the event descriptor</param>
806         /// <param name="description">The description to write</param>
807         /// <param name="payload">The trace payload</param>
808         // Critical = Calls SecurityCritical method EtwDiagnosticTrace.WriteTraceSource
809         // Safe = We only allow setting of provider id from SecurityCritical code
810         [System.Security.SecuritySafeCriticalAttribute()]
WriteTraceSource(int eventIndex, string description, TracePayload payload)811         static void WriteTraceSource(int eventIndex, string description, TracePayload payload)
812         {
813             EnsureEventDescriptors();
814             FxTrace.Trace.WriteTraceSource(ref eventDescriptors[eventIndex], description, payload);
815         }
816     }
817 }
818 
819