1 //------------------------------------------------------------------------------
3 // This code was generated by a tool.
5 // Changes to this file may cause incorrect behavior and will be lost if
6 // the code is regenerated.
8 //------------------------------------------------------------------------------
10 namespace System.IdentityModel.Diagnostics.Application
13 using System.Runtime.Diagnostics;
14 using System.Security;
17 internal partial class TD
20 static System.Resources.ResourceManager resourceManager;
22 static System.Globalization.CultureInfo resourceCulture;
24 [System.Security.SecurityCriticalAttribute()]
25 static System.Runtime.Diagnostics.EventDescriptor[] eventDescriptors;
27 static object syncLock = new object();
29 // Double-checked locking pattern requires volatile for read/write synchronization
30 static volatile bool eventDescriptorsCreated;
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
41 if (object.ReferenceEquals(resourceManager, null))
43 resourceManager = new System.Resources.ResourceManager("System.IdentityModel.Diagnostics.Application.TD", typeof(TD).Assembly);
45 return resourceManager;
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
54 return resourceCulture;
58 resourceCulture = value;
63 /// Check if trace definition is enabled
64 /// Event description ID=5406, Level=Error, Channel=Debug
66 internal static bool GetIssuerNameFailureIsEnabled()
68 return (FxTrace.ShouldTraceError && TD.IsEtwEventEnabled(0));
72 /// Gets trace definition like: Retrieval of issuer name from tokenId:{0} failed.
73 /// Event description ID=5406, Level=Error, Channel=Debug
75 /// <param name="eventTraceActivity">The event trace activity</param>
76 /// <param name="tokenID">Parameter 0 for event: Retrieval of issuer name from tokenId:{0} failed.</param>
77 internal static void GetIssuerNameFailure(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string tokenID)
79 TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
80 if (TD.IsEtwEventEnabled(0))
82 TD.WriteEtwEvent(0, eventTraceActivity, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
87 /// Check if trace definition is enabled
88 /// Event description ID=5405, Level=Verbose, Channel=Debug
90 internal static bool GetIssuerNameSuccessIsEnabled()
92 return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(1));
96 /// Gets trace definition like: Retrieval of issuer name:{0} from tokenId:{1} succeeded.
97 /// Event description ID=5405, Level=Verbose, Channel=Debug
99 /// <param name="eventTraceActivity">The event trace activity</param>
100 /// <param name="issuerName">Parameter 0 for event: Retrieval of issuer name:{0} from tokenId:{1} succeeded.</param>
101 /// <param name="tokenID">Parameter 1 for event: Retrieval of issuer name:{0} from tokenId:{1} succeeded.</param>
102 internal static void GetIssuerNameSuccess(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string issuerName, string tokenID)
104 TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
105 if (TD.IsEtwEventEnabled(1))
107 TD.WriteEtwEvent(1, eventTraceActivity, issuerName, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
112 /// Check if trace definition is enabled
113 /// Event description ID=5404, Level=Error, Channel=Debug
115 internal static bool TokenValidationFailureIsEnabled()
117 return (FxTrace.ShouldTraceError && TD.IsEtwEventEnabled(2));
121 /// Gets trace definition like: SecurityToken (type '{0}' and id '{1}') validation failed. {2}
122 /// Event description ID=5404, Level=Error, Channel=Debug
124 /// <param name="eventTraceActivity">The event trace activity</param>
125 /// <param name="tokenType">Parameter 0 for event: SecurityToken (type '{0}' and id '{1}') validation failed. {2}</param>
126 /// <param name="tokenID">Parameter 1 for event: SecurityToken (type '{0}' and id '{1}') validation failed. {2}</param>
127 /// <param name="errorMessage">Parameter 2 for event: SecurityToken (type '{0}' and id '{1}') validation failed. {2}</param>
128 internal static void TokenValidationFailure(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string tokenType, string tokenID, string errorMessage)
130 TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
131 if (TD.IsEtwEventEnabled(2))
133 TD.WriteEtwEvent(2, eventTraceActivity, tokenType, tokenID, errorMessage, payload.HostReference, payload.AppDomainFriendlyName);
138 /// Check if trace definition is enabled
139 /// Event description ID=5402, Level=Verbose, Channel=Debug
141 internal static bool TokenValidationStartedIsEnabled()
143 return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(3));
147 /// Gets trace definition like: SecurityToken (type '{0}' and id '{1}') validation started.
148 /// Event description ID=5402, Level=Verbose, Channel=Debug
150 /// <param name="eventTraceActivity">The event trace activity</param>
151 /// <param name="tokenType">Parameter 0 for event: SecurityToken (type '{0}' and id '{1}') validation started.</param>
152 /// <param name="tokenID">Parameter 1 for event: SecurityToken (type '{0}' and id '{1}') validation started.</param>
153 internal static void TokenValidationStarted(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string tokenType, string tokenID)
155 TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
156 if (TD.IsEtwEventEnabled(3))
158 TD.WriteEtwEvent(3, eventTraceActivity, tokenType, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
163 /// Check if trace definition is enabled
164 /// Event description ID=5403, Level=Verbose, Channel=Debug
166 internal static bool TokenValidationSuccessIsEnabled()
168 return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(4));
172 /// Gets trace definition like: SecurityToken (type '{0}' and id '{1}') validation succeeded.
173 /// Event description ID=5403, Level=Verbose, Channel=Debug
175 /// <param name="eventTraceActivity">The event trace activity</param>
176 /// <param name="tokenType">Parameter 0 for event: SecurityToken (type '{0}' and id '{1}') validation succeeded.</param>
177 /// <param name="tokenID">Parameter 1 for event: SecurityToken (type '{0}' and id '{1}') validation succeeded.</param>
178 internal static void TokenValidationSuccess(System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity, string tokenType, string tokenID)
180 TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
181 if (TD.IsEtwEventEnabled(4))
183 TD.WriteEtwEvent(4, eventTraceActivity, tokenType, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
188 /// Creates the event descriptors array
190 // Critical = Sets the SecurityCritical member eventDescriptors
191 // Safe = We control what the event descriptors contain
192 [System.Security.SecuritySafeCriticalAttribute()]
193 static void CreateEventDescriptors()
195 System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
196 new System.Runtime.Diagnostics.EventDescriptor(5406, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa35, 0x1000000000000010),
197 new System.Runtime.Diagnostics.EventDescriptor(5405, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa35, 0x1000000000000010),
198 new System.Runtime.Diagnostics.EventDescriptor(5404, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa34, 0x1000000000000010),
199 new System.Runtime.Diagnostics.EventDescriptor(5402, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa34, 0x1000000000000010),
200 new System.Runtime.Diagnostics.EventDescriptor(5403, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa34, 0x1000000000000010)};
201 // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
202 // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
203 // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
204 // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
205 // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
206 System.Collections.Generic.List<ushort> e2eEvents = new System.Collections.Generic.List<ushort>(5);
212 FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
213 eventDescriptors = descriptors;
217 /// Ensures that the event descriptors array is initialized
219 static void EnsureEventDescriptors()
221 if (eventDescriptorsCreated)
225 System.Threading.Monitor.Enter(syncLock);
228 if (eventDescriptorsCreated)
232 CreateEventDescriptors();
233 eventDescriptorsCreated = true;
237 System.Threading.Monitor.Exit(syncLock);
242 /// Check if ETW tracing is enabled for the particular event
244 /// <param name="eventIndex">The index of the event descriptor</param>
245 static bool IsEtwEventEnabled(int eventIndex)
247 if (FxTrace.Trace.IsEtwProviderEnabled)
249 EnsureEventDescriptors();
250 return FxTrace.IsEventEnabled(eventIndex);
256 /// Writes ETW trace event
258 /// <param name="eventIndex">The index of the event descriptor</param>>
259 /// <param name="eventParam0">A parameter of the ETW event</param>>
260 /// <param name="eventParam1">A parameter of the ETW event</param>>
261 /// <param name="eventParam2">A parameter of the ETW event</param>>
262 /// <param name="eventParam3">A parameter of the ETW event</param>>
263 // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
264 // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
265 [System.Security.SecuritySafeCriticalAttribute()]
266 static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3)
268 EnsureEventDescriptors();
269 return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3);
273 /// Writes ETW trace event
275 /// <param name="eventIndex">The index of the event descriptor</param>>
276 /// <param name="eventParam0">A parameter of the ETW event</param>>
277 /// <param name="eventParam1">A parameter of the ETW event</param>>
278 /// <param name="eventParam2">A parameter of the ETW event</param>>
279 /// <param name="eventParam3">A parameter of the ETW event</param>>
280 /// <param name="eventParam4">A parameter of the ETW event</param>>
281 // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
282 // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
283 [System.Security.SecuritySafeCriticalAttribute()]
284 static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3, string eventParam4)
286 EnsureEventDescriptors();
287 return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3, eventParam4);
291 /// Writes ETW trace event
293 /// <param name="eventIndex">The index of the event descriptor</param>>
294 /// <param name="eventParam0">A parameter of the ETW event</param>>
295 /// <param name="eventParam1">A parameter of the ETW event</param>>
296 /// <param name="eventParam2">A parameter of the ETW event</param>>
297 /// <param name="eventParam3">A parameter of the ETW event</param>>
298 /// <param name="eventParam4">A parameter of the ETW event</param>>
299 /// <param name="eventParam5">A parameter of the ETW event</param>>
300 // Critical = Calls SecurityCritical method EtwProvider.WriteEvent
301 // Safe = We only allow setting of provider id from SecurityCritical code, access to EventDescriptors is SecurityCritical, and ETW limits buffer sizes.
302 [System.Security.SecuritySafeCriticalAttribute()]
303 static bool WriteEtwEvent(int eventIndex, System.Runtime.Diagnostics.EventTraceActivity eventParam0, string eventParam1, string eventParam2, string eventParam3, string eventParam4, string eventParam5)
305 EnsureEventDescriptors();
306 return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3, eventParam4, eventParam5);