Merge pull request #2964 from ludovic-henry/sgen-monocontext
[mono.git] / mcs / class / referencesource / System.IdentityModel / 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.IdentityModel.Diagnostics.Application
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.IdentityModel.Diagnostics.Application.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=5406, Level=Error, Channel=Debug
65         /// </summary>
66         internal static bool GetIssuerNameFailureIsEnabled()
67         {
68             return (FxTrace.ShouldTraceError && TD.IsEtwEventEnabled(0));
69         }
70         
71         /// <summary>
72         /// Gets trace definition like: Retrieval of issuer name from tokenId:{0} failed.
73         /// Event description ID=5406, Level=Error, Channel=Debug
74         /// </summary>
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)
78         {
79             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
80             if (TD.IsEtwEventEnabled(0))
81             {
82                 TD.WriteEtwEvent(0, eventTraceActivity, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
83             }
84         }
85         
86         /// <summary>
87         /// Check if trace definition is enabled
88         /// Event description ID=5405, Level=Verbose, Channel=Debug
89         /// </summary>
90         internal static bool GetIssuerNameSuccessIsEnabled()
91         {
92             return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(1));
93         }
94         
95         /// <summary>
96         /// Gets trace definition like: Retrieval of issuer name:{0} from tokenId:{1} succeeded.
97         /// Event description ID=5405, Level=Verbose, Channel=Debug
98         /// </summary>
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)
103         {
104             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
105             if (TD.IsEtwEventEnabled(1))
106             {
107                 TD.WriteEtwEvent(1, eventTraceActivity, issuerName, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
108             }
109         }
110         
111         /// <summary>
112         /// Check if trace definition is enabled
113         /// Event description ID=5404, Level=Error, Channel=Debug
114         /// </summary>
115         internal static bool TokenValidationFailureIsEnabled()
116         {
117             return (FxTrace.ShouldTraceError && TD.IsEtwEventEnabled(2));
118         }
119         
120         /// <summary>
121         /// Gets trace definition like: SecurityToken (type '{0}' and id '{1}') validation failed. {2}
122         /// Event description ID=5404, Level=Error, Channel=Debug
123         /// </summary>
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)
129         {
130             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
131             if (TD.IsEtwEventEnabled(2))
132             {
133                 TD.WriteEtwEvent(2, eventTraceActivity, tokenType, tokenID, errorMessage, payload.HostReference, payload.AppDomainFriendlyName);
134             }
135         }
136         
137         /// <summary>
138         /// Check if trace definition is enabled
139         /// Event description ID=5402, Level=Verbose, Channel=Debug
140         /// </summary>
141         internal static bool TokenValidationStartedIsEnabled()
142         {
143             return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(3));
144         }
145         
146         /// <summary>
147         /// Gets trace definition like: SecurityToken (type '{0}' and id '{1}') validation started.
148         /// Event description ID=5402, Level=Verbose, Channel=Debug
149         /// </summary>
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)
154         {
155             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
156             if (TD.IsEtwEventEnabled(3))
157             {
158                 TD.WriteEtwEvent(3, eventTraceActivity, tokenType, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
159             }
160         }
161         
162         /// <summary>
163         /// Check if trace definition is enabled
164         /// Event description ID=5403, Level=Verbose, Channel=Debug
165         /// </summary>
166         internal static bool TokenValidationSuccessIsEnabled()
167         {
168             return (FxTrace.ShouldTraceVerbose && TD.IsEtwEventEnabled(4));
169         }
170         
171         /// <summary>
172         /// Gets trace definition like: SecurityToken (type '{0}' and id '{1}') validation succeeded.
173         /// Event description ID=5403, Level=Verbose, Channel=Debug
174         /// </summary>
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)
179         {
180             TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, null, null, true);
181             if (TD.IsEtwEventEnabled(4))
182             {
183                 TD.WriteEtwEvent(4, eventTraceActivity, tokenType, tokenID, payload.HostReference, payload.AppDomainFriendlyName);
184             }
185         }
186         
187         /// <summary>
188         /// Creates the event descriptors array
189         /// </summary>
190         // Critical = Sets the SecurityCritical member eventDescriptors
191         // Safe = We control what the event descriptors contain
192         [System.Security.SecuritySafeCriticalAttribute()]
193         static void CreateEventDescriptors()
194         {
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);
207             e2eEvents.Add(5402);
208             e2eEvents.Add(5403);
209             e2eEvents.Add(5404);
210             e2eEvents.Add(5405);
211             e2eEvents.Add(5406);
212             FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
213             eventDescriptors = descriptors;
214         }
215         
216         /// <summary>
217         /// Ensures that the event descriptors array is initialized
218         /// </summary>
219         static void EnsureEventDescriptors()
220         {
221             if (eventDescriptorsCreated)
222             {
223                 return;
224             }
225             System.Threading.Monitor.Enter(syncLock);
226             try
227             {
228                 if (eventDescriptorsCreated)
229                 {
230                     return;
231                 }
232                 CreateEventDescriptors();
233                 eventDescriptorsCreated = true;
234             }
235             finally
236             {
237                 System.Threading.Monitor.Exit(syncLock);
238             }
239         }
240         
241         /// <summary>
242         /// Check if ETW tracing is enabled for the particular event
243         /// </summary>
244         /// <param name="eventIndex">The index of the event descriptor</param>
245         static bool IsEtwEventEnabled(int eventIndex)
246         {
247             if (FxTrace.Trace.IsEtwProviderEnabled)
248             {
249                 EnsureEventDescriptors();
250                 return FxTrace.IsEventEnabled(eventIndex);
251             }
252             return false;
253         }
254         
255         /// <summary>
256         /// Writes ETW trace event
257         ///</summary>
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)
267         {
268             EnsureEventDescriptors();
269             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3);
270         }
271         
272         /// <summary>
273         /// Writes ETW trace event
274         ///</summary>
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)
285         {
286             EnsureEventDescriptors();
287             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3, eventParam4);
288         }
289         
290         /// <summary>
291         /// Writes ETW trace event
292         ///</summary>
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)
304         {
305             EnsureEventDescriptors();
306             return FxTrace.Trace.EtwProvider.WriteEvent(ref eventDescriptors[eventIndex], eventParam0, eventParam1, eventParam2, eventParam3, eventParam4, eventParam5);
307         }
308     }
309 }
310