Merge pull request #4434 from BrzVlad/fix-unload-hang
[mono.git] / mcs / class / corlib / System.Diagnostics.Tracing / EventSource.cs
1 //
2 // EventSource.cs
3 //
4 // Authors:
5 //      Marek Safar  <marek.safar@gmail.com>
6 //      Frederik Carlier <frederik.carlier@quamotion.mobi>
7 //
8 // Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)
9 // Copyrithg (C) 2015 Quamotion (http://quamotion.mobi)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System.Collections.Generic;
32
33 namespace System.Diagnostics.Tracing
34 {
35         public class EventSource : IDisposable
36         {
37                 protected internal struct EventData
38                 {
39                         public IntPtr DataPointer { get; set; }
40                         public int Size { get; set; }
41                 }
42
43                 protected EventSource ()
44                 {
45                         this.Name = this.GetType().Name;
46                 }
47
48                 protected EventSource (bool throwOnEventWriteErrors)
49                         : this ()
50                 {
51                 }
52
53                 protected EventSource (EventSourceSettings settings)
54                         : this ()
55                 {
56                         this.Settings = settings;
57                 }
58
59                 protected EventSource (EventSourceSettings settings, params string[] traits)
60                         : this (settings)
61                 {
62                 }
63
64                 public EventSource (string eventSourceName)
65                 {
66                         this.Name = eventSourceName;
67                 }
68
69                 public EventSource (string eventSourceName, EventSourceSettings config)
70                         : this (eventSourceName)
71                 {
72                         this.Settings = config;
73                 }
74
75                 public EventSource (string eventSourceName, EventSourceSettings config, params string[] traits)
76                         : this (eventSourceName, config)
77                 {
78                 }
79
80                 ~EventSource ()
81                 {
82                         Dispose (false);
83                 }
84
85                 public Exception ConstructionException
86                 {
87                         get { return null; }
88                 }
89
90                 public static Guid CurrentThreadActivityId
91                 {
92                         get { return Guid.Empty; }
93                 }
94
95                 public Guid Guid
96                 {
97                         get { return Guid.Empty; }
98                 }
99
100                 public string Name
101                 {
102                         get;
103                         private set;
104                 }
105
106                 public EventSourceSettings Settings
107                 {
108                         get;
109                         private set;
110                 }
111
112                 public bool IsEnabled ()
113                 {
114                         return false;
115                 }
116
117                 public bool IsEnabled (EventLevel level, EventKeywords keywords)
118                 {
119                         return false;
120                 }
121
122                 public bool IsEnabled (EventLevel level, EventKeywords keywords, EventChannel channel)
123                 {
124                         return false;
125                 }
126
127                 public void Dispose ()
128                 {
129                         Dispose (true);
130                         GC.SuppressFinalize (this);
131                 }
132
133                 public string GetTrait (string key)
134                 {
135                         return null;
136                 }
137
138                 public void Write (string eventName)
139                 {
140                 }
141
142                 public void Write (string eventName, EventSourceOptions options)
143                 {
144                 }
145
146                 public void Write<T> (string eventName, T data)
147                 {
148                 }
149
150                 public void Write<T> (string eventName, EventSourceOptions options, T data)
151                 {
152                 }
153
154                 [CLSCompliant (false)]
155                 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
156                 {
157                 }
158
159                 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
160                 {
161                 }
162
163                 protected virtual void Dispose (bool disposing)
164                 {
165                 }
166
167                 protected virtual void OnEventCommand (EventCommandEventArgs command)
168                 {
169                 }
170
171                 protected void WriteEvent (int eventId)
172                 {
173                         WriteEvent (eventId, new object[] { } );
174                 }
175
176                 protected void WriteEvent (int eventId, byte[] arg1)
177                 {
178                         WriteEvent (eventId, new object[] { arg1 } );
179                 }
180
181                 protected void WriteEvent (int eventId, int arg1)
182                 {
183                         WriteEvent (eventId, new object[] { arg1 } );
184                 }
185
186                 protected void WriteEvent (int eventId, string arg1)
187                 {
188                         WriteEvent (eventId, new object[] { arg1 } );
189                 }
190
191                 protected void WriteEvent (int eventId, int arg1, int arg2)
192                 {
193                         WriteEvent (eventId, new object[] { arg1, arg2 } );
194                 }
195
196                 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
197                 {
198                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
199                 }
200
201                 protected void WriteEvent (int eventId, int arg1, string arg2)
202                 {
203                         WriteEvent (eventId, new object[] { arg1, arg2 } );
204                 }
205
206                 protected void WriteEvent (int eventId, long arg1)
207                 {
208                         WriteEvent (eventId, new object[] { arg1 } );
209                 }
210
211                 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
212                 {
213                         WriteEvent (eventId, new object[] { arg1, arg2 } );
214                 }
215
216                 protected void WriteEvent (int eventId, long arg1, long arg2)
217                 {
218                         WriteEvent (eventId, new object[] { arg1, arg2 } );
219                 }
220
221                 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
222                 {
223                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
224                 }
225
226                 protected void WriteEvent (int eventId, long arg1, string arg2)
227                 {
228                         WriteEvent (eventId, new object[] { arg1, arg2 } );
229                 }
230
231                 protected void WriteEvent (int eventId, params object[] args)
232                 {
233                 }
234
235                 protected void WriteEvent (int eventId, string arg1, int arg2)
236                 {
237                         WriteEvent (eventId, new object[] { arg1, arg2 } );
238                 }
239
240                 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
241                 {
242                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
243                 }
244
245                 protected void WriteEvent (int eventId, string arg1, long arg2)
246                 {
247                         WriteEvent (eventId, new object[] { arg1, arg2 } );
248                 }
249
250                 protected void WriteEvent (int eventId, string arg1, string arg2)
251                 {
252                         WriteEvent (eventId, new object[] { arg1, arg2 } );
253                 }
254
255                 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
256                 {
257                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
258                 }
259
260                 [CLSCompliant (false)]
261                 protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
262                 {
263                 }
264
265                 protected unsafe void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object[] args)
266                 {
267                 }
268
269                 [CLSCompliant (false)]
270                 protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
271                 {
272                 }
273
274                 [MonoTODO]
275                 public event EventHandler<EventCommandEventArgs> EventCommandExecuted
276                 {
277                         add { throw new NotImplementedException (); }
278                         remove { throw new NotImplementedException (); }
279                 }
280
281                 [MonoTODO]
282                 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest)
283                 {
284                         throw new NotImplementedException ();
285                 }
286
287                 [MonoTODO]
288                 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest, EventManifestOptions flags)
289                 {
290                         throw new NotImplementedException ();
291                 }
292
293                 [MonoTODO]
294                 public static Guid GetGuid (Type eventSourceType)
295                 {
296                         throw new NotImplementedException ();
297                 }
298
299                 [MonoTODO]
300                 public static string GetName (Type eventSourceType)
301                 {
302                         throw new NotImplementedException ();
303                 }
304
305                 [MonoTODO]
306                 public static IEnumerable<EventSource> GetSources ()
307                 {
308                         throw new NotImplementedException ();
309                 }
310
311                 [MonoTODO]
312                 public static void SendCommand (EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
313                 {
314                         throw new NotImplementedException ();
315                 }
316
317                 [MonoTODO]
318                 public static void SetCurrentThreadActivityId (Guid activityId)
319                 {
320                         throw new NotImplementedException ();
321                 }
322
323                 [MonoTODO]
324                 public static void SetCurrentThreadActivityId (Guid activityId, out Guid oldActivityThatWillContinue)
325                 {
326                         throw new NotImplementedException ();
327                 }
328         }
329 }
330