@@ -0,0 +1,8 | |||
|
1 | using System; | |
|
2 | ||
|
3 | namespace Implab.Diagnostics { | |
|
4 | public interface ILogWriter<in TEvent> { | |
|
5 | void Write(LogEventArgs args, TEvent entry); | |
|
6 | } | |
|
7 | } | |
|
8 |
@@ -0,0 +1,87 | |||
|
1 | using System; | |
|
2 | using System.Collections.Generic; | |
|
3 | using System.Linq; | |
|
4 | using System.Text; | |
|
5 | ||
|
6 | namespace Implab.Diagnostics { | |
|
7 | public abstract class ListenerBase : ServiceLocator, ILogWriter<object>, ILogWriter<TraceEvent> { | |
|
8 | ||
|
9 | readonly Dictionary<object, Action> m_subscriptions = new Dictionary<object, Action>(); | |
|
10 | ||
|
11 | protected ListenerBase() { | |
|
12 | Register(this); | |
|
13 | } | |
|
14 | ||
|
15 | public void Subscribe(Type eventType) { | |
|
16 | if (eventType == null) | |
|
17 | throw new ArgumentNullException("eventType"); | |
|
18 | GetType().GetMethod("Subscribe", new Type[0]).MakeGenericMethod(eventType).Invoke(this, null); | |
|
19 | } | |
|
20 | ||
|
21 | public void Subscribe<TEvent>() { | |
|
22 | Subscribe<TEvent>(LogChannel<TEvent>.Default); | |
|
23 | } | |
|
24 | ||
|
25 | public void Subscribe<TEvent>(LogChannel<TEvent> channel) { | |
|
26 | if (channel == null) | |
|
27 | throw new ArgumentNullException("channel"); | |
|
28 | ||
|
29 | lock (m_subscriptions) { | |
|
30 | AssertNotDisposed(); | |
|
31 | if (m_subscriptions.ContainsKey(channel)) | |
|
32 | return; | |
|
33 | ||
|
34 | var writer = GetService<ILogWriter<TEvent>>(); | |
|
35 | ||
|
36 | EventHandler<LogEventArgs<TEvent>> handler = (sender, args) => writer.Write(args,args.Value); | |
|
37 | ||
|
38 | channel.Events += handler; | |
|
39 | ||
|
40 | Action unsubscribe = () => { | |
|
41 | channel.Events -= handler; | |
|
42 | }; | |
|
43 | ||
|
44 | m_subscriptions.Add(channel, unsubscribe); | |
|
45 | } | |
|
46 | } | |
|
47 | ||
|
48 | public void Unsubscribe<TEvent>(LogChannel<TEvent> channel) { | |
|
49 | if (channel == null) | |
|
50 | throw new ArgumentNullException("channel"); | |
|
51 | ||
|
52 | lock (m_subscriptions) { | |
|
53 | Action subscription; | |
|
54 | if (m_subscriptions.TryGetValue(channel, out subscription)) { | |
|
55 | subscription(); | |
|
56 | m_subscriptions.Remove(channel); | |
|
57 | } | |
|
58 | } | |
|
59 | } | |
|
60 | ||
|
61 | public void UnsubscribeAll() { | |
|
62 | lock (m_subscriptions) { | |
|
63 | foreach (var subscription in m_subscriptions.Values) | |
|
64 | subscription(); | |
|
65 | m_subscriptions.Clear(); | |
|
66 | } | |
|
67 | } | |
|
68 | ||
|
69 | #region ILogWriter implementation | |
|
70 | public abstract void Write(LogEventArgs args, object entry); | |
|
71 | #endregion | |
|
72 | ||
|
73 | #region ILogWriter implementation | |
|
74 | public virtual void Write(LogEventArgs args, TraceEvent entry) { | |
|
75 | Write(args, (object)entry); | |
|
76 | } | |
|
77 | #endregion | |
|
78 | ||
|
79 | ||
|
80 | protected override void Dispose(bool disposing) { | |
|
81 | base.Dispose(disposing); | |
|
82 | if (disposing) { | |
|
83 | UnsubscribeAll(); | |
|
84 | } | |
|
85 | } | |
|
86 | } | |
|
87 | } |
@@ -1,122 +1,122 | |||
|
1 | 1 | using Implab.Parallels; |
|
2 | 2 | using System; |
|
3 | 3 | using System.Collections.Generic; |
|
4 | 4 | using System.Linq; |
|
5 | 5 | using System.Text; |
|
6 | 6 | using System.Threading; |
|
7 | 7 | using System.Threading.Tasks; |
|
8 | 8 | using System.Windows.Forms; |
|
9 | 9 | |
|
10 | 10 | namespace Implab.Diagnostics.Interactive |
|
11 | 11 | { |
|
12 |
public class InteractiveListener: |
|
|
12 | public class InteractiveListener: ListenerBase | |
|
13 | 13 | { |
|
14 | 14 | TraceForm m_form; |
|
15 | 15 | |
|
16 | 16 | SynchronizationContext m_syncGuiThread; |
|
17 | 17 | readonly Promise m_guiStarted = new Promise(); |
|
18 | 18 | |
|
19 | 19 | readonly IPromise m_guiFinished; |
|
20 | 20 | // readonly IPromise m_workerFinished = new Promise<object>(); |
|
21 | 21 | |
|
22 | 22 | readonly MTQueue<TraceViewItem> m_queue = new MTQueue<TraceViewItem>(); |
|
23 | 23 | readonly AutoResetEvent m_queueEvent = new AutoResetEvent(false); |
|
24 | 24 | |
|
25 | 25 | int m_queueLength; |
|
26 | 26 | bool m_exitPending; |
|
27 | 27 | |
|
28 | 28 | readonly object m_pauseLock = new object(); |
|
29 | 29 | bool m_paused; |
|
30 | 30 | readonly ManualResetEvent m_pauseEvent = new ManualResetEvent(true); |
|
31 | 31 | |
|
32 |
public InteractiveListener( |
|
|
32 | public InteractiveListener() { | |
|
33 | 33 | m_guiFinished = AsyncPool.RunThread(GuiThread); |
|
34 | 34 | /*m_workerFinished = */AsyncPool.RunThread(QueueThread); |
|
35 | 35 | |
|
36 | 36 | m_guiStarted.Join(); |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | void GuiThread() { |
|
40 | 40 | m_form = new TraceForm(); // will create SynchronizationContext |
|
41 | 41 | |
|
42 | 42 | m_form.PauseEvents += (s,a) => Pause(); |
|
43 | 43 | m_form.ResumeEvents += (s, a) => Resume(); |
|
44 | 44 | |
|
45 | 45 | m_syncGuiThread = SynchronizationContext.Current; |
|
46 | 46 | m_guiStarted.Resolve(); |
|
47 | 47 | Application.Run(); |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | void QueueThread() { |
|
51 | 51 | while (!m_exitPending) { |
|
52 | 52 | if (m_paused) |
|
53 | 53 | m_pauseEvent.WaitOne(); |
|
54 | 54 | |
|
55 | 55 | TraceViewItem item; |
|
56 | 56 | if (m_queue.TryDequeue(out item)) { |
|
57 | 57 | Interlocked.Decrement(ref m_queueLength); |
|
58 | 58 | |
|
59 | 59 | m_syncGuiThread.Send(x => m_form.AddTraceEvent(item),null); |
|
60 | 60 | } else { |
|
61 | 61 | m_queueEvent.WaitOne(); |
|
62 | 62 | } |
|
63 | 63 | } |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | public void Pause() { |
|
67 | 67 | // for consistency we need to set this properties atomically |
|
68 | 68 | lock (m_pauseLock) { |
|
69 | 69 | m_pauseEvent.Reset(); |
|
70 | 70 | m_paused = true; |
|
71 | 71 | } |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | 74 | public void Resume() { |
|
75 | 75 | // for consistency we need to set this properties atomically |
|
76 | 76 | lock (m_pauseLock) { |
|
77 | 77 | m_paused = false; |
|
78 | 78 | m_pauseEvent.Set(); |
|
79 | 79 | } |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | void Enqueue(TraceViewItem item) { |
|
83 | 83 | m_queue.Enqueue(item); |
|
84 | 84 | if (Interlocked.Increment(ref m_queueLength) == 1) |
|
85 | 85 | m_queueEvent.Set(); |
|
86 | 86 | } |
|
87 | 87 | |
|
88 | 88 | public void ShowForm() { |
|
89 | 89 | m_syncGuiThread.Post(x => m_form.Show(), null); |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | public void HideForm() { |
|
93 | 93 | m_syncGuiThread.Post(x => m_form.Hide(), null); |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | void Terminate() { |
|
97 | 97 | m_exitPending = true; |
|
98 | 98 | Resume(); |
|
99 | 99 | m_syncGuiThread.Post(x => Application.ExitThread(), null); |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | protected override void Dispose(bool disposing) { |
|
103 | 103 | if (disposing) { |
|
104 | 104 | Terminate(); |
|
105 | 105 | m_guiFinished.Join(); |
|
106 | 106 | } |
|
107 | 107 | base.Dispose(disposing); |
|
108 | 108 | } |
|
109 | 109 | |
|
110 |
p |
|
|
110 | public override void Write(LogEventArgs args, object entry) { | |
|
111 | 111 | var item = new TraceViewItem { |
|
112 |
Indent = |
|
|
113 |
Message = |
|
|
112 | Indent = args.Operation.Level, | |
|
113 | Message = entry.ToString(), | |
|
114 | 114 | Thread = args.ThreadId, |
|
115 |
Channel = |
|
|
115 | Channel = args.ChannelName, | |
|
116 | 116 | Timestamp = Environment.TickCount |
|
117 | 117 | }; |
|
118 | 118 | |
|
119 | 119 | Enqueue(item); |
|
120 | 120 | } |
|
121 | 121 | } |
|
122 | 122 | } |
@@ -1,34 +1,22 | |||
|
1 | 1 | using System; |
|
2 | using System.Collections.Generic; | |
|
3 | using System.Linq; | |
|
4 | 2 | using System.Text; |
|
5 | 3 | |
|
6 | 4 | namespace Implab.Diagnostics { |
|
7 |
public class ConsoleTraceListener: |
|
|
5 | public class ConsoleTraceListener: ListenerBase { | |
|
8 | 6 | |
|
9 | 7 | static readonly object _consoleLock = new object(); |
|
10 | 8 | |
|
11 | public ConsoleTraceListener() | |
|
12 | : base(true) { | |
|
13 | ||
|
14 | } | |
|
15 | ||
|
16 | public ConsoleTraceListener(bool global) | |
|
17 | : base(global) { | |
|
18 | ||
|
19 | } | |
|
20 | ||
|
21 | protected override void WriteEntry(LogEventArgs args, EventText text, string channel) { | |
|
9 | public override void Write(LogEventArgs args, object entry) { | |
|
22 | 10 | var msg = new StringBuilder(); |
|
23 | 11 | |
|
24 |
for (int i = 0; i < |
|
|
12 | for (int i = 0; i < args.Operation.Level; i++) | |
|
25 | 13 | msg.Append(" "); |
|
26 |
msg.AppendFormat("[{0}]: {1}", args.ThreadId, |
|
|
14 | msg.AppendFormat("[{0}]: {1}", args.ThreadId, entry); | |
|
27 | 15 | |
|
28 | 16 | lock (_consoleLock) { |
|
29 | 17 | Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); |
|
30 | 18 | Console.WriteLine(msg); |
|
31 | 19 | } |
|
32 | 20 | } |
|
33 | 21 | } |
|
34 | 22 | } |
@@ -1,43 +1,41 | |||
|
1 | using System; | |
|
2 | ||
|
3 | namespace Implab.Diagnostics { | |
|
1 | namespace Implab.Diagnostics { | |
|
4 | 2 | public static class Extensions { |
|
5 | 3 | public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) { |
|
6 | 4 | Safe.ArgumentNotNull(promise, "promise"); |
|
7 | 5 | var op = TraceContext.Instance.DetachLogicalOperation(); |
|
8 | 6 | |
|
9 | 7 | return promise.On( |
|
10 | 8 | x => { |
|
11 | 9 | TraceContext.Instance.EnterLogicalOperation(op,true); |
|
12 | 10 | TraceLog.TraceInformation("promise = {0}", x); |
|
13 | 11 | TraceLog.EndLogicalOperation(); |
|
14 | 12 | TraceContext.Instance.Leave(); |
|
15 | 13 | }, |
|
16 | 14 | err =>{ |
|
17 | 15 | TraceContext.Instance.EnterLogicalOperation(op,true); |
|
18 | 16 | TraceLog.TraceError("promise died {0}", err); |
|
19 | 17 | TraceLog.EndLogicalOperation(); |
|
20 | 18 | TraceContext.Instance.Leave(); |
|
21 | 19 | }, |
|
22 | 20 | () => { |
|
23 | 21 | TraceContext.Instance.EnterLogicalOperation(op,true); |
|
24 | 22 | TraceLog.TraceInformation("promise cancelled"); |
|
25 | 23 | TraceLog.EndLogicalOperation(); |
|
26 | 24 | TraceContext.Instance.Leave(); |
|
27 | 25 | } |
|
28 | 26 | ); |
|
29 | 27 | } |
|
30 | 28 | |
|
31 | 29 | public static IPromise EndLogicalOperation(this IPromise promise) { |
|
32 | 30 | Safe.ArgumentNotNull(promise, "promise"); |
|
33 | 31 | var op = TraceContext.Instance.DetachLogicalOperation(); |
|
34 | 32 | |
|
35 | 33 | return promise.On(() => { |
|
36 | 34 | TraceContext.Instance.EnterLogicalOperation(op,true); |
|
37 | 35 | TraceLog.EndLogicalOperation(); |
|
38 | 36 | TraceContext.Instance.Leave(); |
|
39 | 37 | }, PromiseEventType.All); |
|
40 | 38 | } |
|
41 | 39 | } |
|
42 | 40 | } |
|
43 | 41 |
@@ -1,80 +1,81 | |||
|
1 | 1 | using System; |
|
2 | 2 | using System.Collections.Generic; |
|
3 | 3 | using System.Linq; |
|
4 | 4 | using System.Text; |
|
5 | 5 | |
|
6 | 6 | namespace Implab.Diagnostics { |
|
7 | 7 | /// <summary> |
|
8 | 8 | /// Канал, через который публикуются события журнала. |
|
9 | 9 | /// </summary> |
|
10 | 10 | /// <typeparam name="TEvent">Тип событий в канале</typeparam> |
|
11 | 11 | /// <remarks> |
|
12 | 12 | /// Событиями журнала могут быть любые типы, например строки, в которых будет передаваться |
|
13 | 13 | /// информация, или структуры с набором полей, описывающих важность, текст и другую информацию. |
|
14 | 14 | /// </remarks> |
|
15 | 15 | public class LogChannel<TEvent> { |
|
16 | 16 | static LogChannel<TEvent> _default = new LogChannel<TEvent>(); |
|
17 | 17 | |
|
18 | 18 | /// <summary> |
|
19 | 19 | /// Канал по-умолчанию для событий типа <typeparam name="TEvent"/>. |
|
20 | 20 | /// </summary> |
|
21 | 21 | public static LogChannel<TEvent> Default { |
|
22 | 22 | get { |
|
23 | 23 | return _default; |
|
24 | 24 | } |
|
25 | 25 | } |
|
26 | 26 | |
|
27 | 27 | /// <summary> |
|
28 | 28 | /// Событие появление новой записи в журнале, на это событие подписываются слушатели. |
|
29 | 29 | /// </summary> |
|
30 | 30 | public event EventHandler<LogEventArgs<TEvent>> Events; |
|
31 | 31 | |
|
32 | 32 | /// <summary> |
|
33 | 33 | /// Имя канала, полезно для отображения в журнале |
|
34 | 34 | /// </summary> |
|
35 | 35 | public string Name { |
|
36 | 36 | get; |
|
37 | 37 | private set; |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | /// <summary> |
|
41 | 41 | /// Создает журнал, имя типа событий назначается в качетве имени канала. |
|
42 | 42 | /// </summary> |
|
43 | 43 | public LogChannel() |
|
44 | 44 | : this(null) { |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | /// <summary> |
|
48 | 48 | /// Содает канал с указанным именем. |
|
49 | 49 | /// </summary> |
|
50 | 50 | /// <param name="name">Имя канала.</param> |
|
51 | 51 | public LogChannel(string name) { |
|
52 | 52 | if (String.IsNullOrEmpty(name)) |
|
53 | 53 | name = typeof(TEvent).Name; |
|
54 | 54 | Name = name; |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | /// <summary> |
|
58 | 58 | /// Отправляет запись журнала через канал подписчикам. |
|
59 | 59 | /// </summary> |
|
60 | 60 | /// <param name="data">Запись журнала.</param> |
|
61 | 61 | /// <remarks> |
|
62 | 62 | /// Контекст трассировки от которого рассылается сообщение определяется автоматически из текущего потока. |
|
63 | 63 | /// </remarks> |
|
64 | 64 | public void LogEvent(TEvent data) { |
|
65 | 65 | var t = Events; |
|
66 | 66 | if (t != null) { |
|
67 | 67 | var traceContext = TraceContext.Instance; |
|
68 | 68 | t( |
|
69 | 69 | this, |
|
70 | 70 | new LogEventArgs<TEvent>( |
|
71 | 71 | data, |
|
72 | Name, | |
|
72 | 73 | traceContext.ThreadId, |
|
73 | 74 | traceContext.CurrentOperation, |
|
74 | 75 | traceContext.CurrentOperation.Duration |
|
75 | 76 | ) |
|
76 | 77 | ); |
|
77 | 78 | } |
|
78 | 79 | } |
|
79 | 80 | } |
|
80 | 81 | } |
@@ -1,24 +1,29 | |||
|
1 | 1 | using System; |
|
2 | 2 | |
|
3 | 3 | namespace Implab.Diagnostics { |
|
4 | 4 | public class LogEventArgs : EventArgs { |
|
5 | public string ChannelName { | |
|
6 | get; | |
|
7 | private set; | |
|
8 | } | |
|
5 | 9 | public int ThreadId { |
|
6 | 10 | get; |
|
7 | 11 | private set; |
|
8 | 12 | } |
|
9 | 13 | public LogicalOperation Operation { |
|
10 | 14 | get; |
|
11 | 15 | private set; |
|
12 | 16 | } |
|
13 | 17 | public int OperationTimeOffset { |
|
14 | 18 | get; |
|
15 | 19 | private set; |
|
16 | 20 | } |
|
17 | public LogEventArgs(int threadId, LogicalOperation operation, int timeOffset) { | |
|
21 | public LogEventArgs(string channelName, int threadId, LogicalOperation operation, int timeOffset) { | |
|
22 | ChannelName = channelName; | |
|
18 | 23 | ThreadId = threadId; |
|
19 | 24 | Operation = operation; |
|
20 | 25 | OperationTimeOffset = timeOffset; |
|
21 | 26 | } |
|
22 | 27 | } |
|
23 | 28 | } |
|
24 | 29 |
@@ -1,13 +1,13 | |||
|
1 | 1 | namespace Implab.Diagnostics { |
|
2 | 2 | public class LogEventArgs<TEvent> : LogEventArgs { |
|
3 | 3 | public TEvent Value { |
|
4 | 4 | get; |
|
5 | 5 | private set; |
|
6 | 6 | } |
|
7 | 7 | |
|
8 | public LogEventArgs(TEvent value, int threadId, LogicalOperation operation, int timeOffset) : base(threadId, operation, timeOffset) { | |
|
8 | public LogEventArgs(TEvent value,string channelName, int threadId, LogicalOperation operation, int timeOffset) : base(channelName, threadId, operation, timeOffset) { | |
|
9 | 9 | Value = value; |
|
10 | 10 | } |
|
11 | 11 | } |
|
12 | 12 | } |
|
13 | 13 |
@@ -1,59 +1,65 | |||
|
1 | 1 | namespace Implab.Diagnostics { |
|
2 | 2 | struct OperationContext { |
|
3 | readonly LogicalOperation m_initial; | |
|
4 | 3 | public readonly static OperationContext EMPTY = new OperationContext(LogicalOperation.EMPTY, false); |
|
4 | ||
|
5 | LogicalOperation m_initial; | |
|
5 | 6 | LogicalOperation m_current; |
|
6 |
|
|
|
7 | bool m_ownership; | |
|
7 | 8 | |
|
8 | 9 | public OperationContext(LogicalOperation operation, bool ownership) { |
|
9 | 10 | Safe.ArgumentNotNull(operation, "operation"); |
|
10 | 11 | |
|
11 | 12 | m_initial = operation; |
|
12 | 13 | m_current = operation; |
|
13 | 14 | m_ownership = ownership; |
|
14 | 15 | } |
|
15 | 16 | |
|
16 | 17 | public LogicalOperation CurrentOperation { |
|
17 | 18 | get { return m_current; } |
|
18 | 19 | } |
|
19 | 20 | |
|
20 | 21 | public void BeginLogicalOperation(string name) { |
|
21 | 22 | m_current = new LogicalOperation(name, m_current); |
|
22 | 23 | } |
|
23 | 24 | |
|
24 | 25 | public LogicalOperation DetachLogicalOperation() { |
|
25 | 26 | var detached = m_current; |
|
26 | 27 | if (m_current != LogicalOperation.EMPTY) { |
|
27 | 28 | if (m_current != m_initial) |
|
28 | 29 | m_current = m_current.Parent; |
|
29 | 30 | else if (m_ownership) |
|
30 | 31 | m_current = LogicalOperation.EMPTY; |
|
31 | 32 | else { |
|
32 | 33 | TraceLog.TraceWarning("DetachLogicalOperation can't be applied in the current context"); |
|
33 | 34 | detached = LogicalOperation.EMPTY; |
|
34 | 35 | } |
|
35 | 36 | } else { |
|
36 | 37 | TraceLog.TraceWarning("DetachLogicalOperation can't be applied in the current context"); |
|
37 | 38 | } |
|
38 | 39 | |
|
39 | 40 | return detached; |
|
40 | 41 | } |
|
41 | 42 | |
|
42 |
public |
|
|
43 | if (m_current != m_initial) { | |
|
43 | public LogicalOperation EndLogicalOperation() { | |
|
44 | var current = m_current; | |
|
45 | if (m_current != LogicalOperation.EMPTY && (m_current != m_initial || m_ownership)) { | |
|
44 | 46 | m_current = m_current.Parent; |
|
45 | } else if (m_current != LogicalOperation.EMPTY && m_ownership) { | |
|
46 | m_current = LogicalOperation.EMPTY; | |
|
47 | if (current == m_initial) { | |
|
48 | // we have complete the owned operation | |
|
49 | m_initial = m_current; | |
|
50 | m_ownership = false; | |
|
51 | } | |
|
47 | 52 | } else { |
|
48 | 53 | TraceLog.TraceWarning("EndLogicalOperation can't be applied in the current context"); |
|
49 | 54 | } |
|
55 | return current; | |
|
50 | 56 | } |
|
51 | 57 | |
|
52 | 58 | public void Leave() { |
|
53 | 59 | |
|
54 | 60 | if ((m_ownership && m_current != LogicalOperation.EMPTY) || (!m_ownership && m_current != m_initial) ) |
|
55 | 61 | TraceLog.TraceWarning("Trying to leave unfinished logical operation {0}", m_current.Name); |
|
56 | 62 | } |
|
57 | 63 | } |
|
58 | 64 | } |
|
59 | 65 |
@@ -1,45 +1,46 | |||
|
1 | 1 | using System; |
|
2 | 2 | using System.IO; |
|
3 | 3 | using System.Text; |
|
4 | 4 | |
|
5 | 5 | namespace Implab.Diagnostics { |
|
6 |
public class TextFileListener: |
|
|
6 | public class TextFileListener: ListenerBase { | |
|
7 | 7 | readonly TextWriter m_textWriter; |
|
8 | 8 | |
|
9 |
public TextFileListener(string fileName |
|
|
10 | : base(global) { | |
|
9 | public TextFileListener(string fileName) { | |
|
11 | 10 | m_textWriter = File.CreateText(fileName); |
|
12 | 11 | |
|
13 | 12 | m_textWriter.WriteLine("LOG {0}", DateTime.Now); |
|
14 | Register(this); | |
|
15 | 13 | } |
|
16 | 14 | |
|
17 | protected override void WriteEntry(LogEventArgs args, EventText text, string channel) { | |
|
15 | #region implemented abstract members of ListenerBase | |
|
16 | ||
|
17 | public override void Write(LogEventArgs args, object entry) { | |
|
18 | 18 | var msg = new StringBuilder(); |
|
19 |
for (int i = 0; i < |
|
|
19 | for (int i = 0; i < args.Operation.Level; i++) | |
|
20 | 20 | msg.Append(" "); |
|
21 |
msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, |
|
|
21 | msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.ChannelName, entry); | |
|
22 | 22 | |
|
23 | 23 | lock (m_textWriter) { |
|
24 | 24 | if (!IsDisposed) { |
|
25 | 25 | // тут гарантировано еще не освобожден m_textWriter |
|
26 | 26 | m_textWriter.WriteLine(msg); |
|
27 | 27 | m_textWriter.Flush(); |
|
28 | 28 | } |
|
29 | 29 | } |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | ||
|
32 | #endregion | |
|
33 | ||
|
33 | 34 | protected override void Dispose(bool disposing) { |
|
34 | 35 | base.Dispose(disposing); |
|
35 | 36 | if (disposing) { |
|
36 | 37 | // IsDisposed = true |
|
37 | 38 | lock (m_textWriter) { |
|
38 | 39 | Safe.Dispose(m_textWriter); |
|
39 | 40 | } |
|
40 | 41 | } |
|
41 | 42 | } |
|
42 | 43 | |
|
43 | 44 | |
|
44 | 45 | } |
|
45 | 46 | } |
@@ -1,83 +1,83 | |||
|
1 | 1 | using System; |
|
2 | 2 | using System.Collections.Generic; |
|
3 | 3 | using System.Threading; |
|
4 | 4 | |
|
5 | 5 | namespace Implab.Diagnostics { |
|
6 | 6 | /// <summary> |
|
7 | 7 | /// Trace context is bound to the specific thread, each thread has it's own ThreadContext. |
|
8 | 8 | /// </summary> |
|
9 | 9 | /// <remarks> |
|
10 | 10 | /// ThreadContext manages relations between logical operations and threads. |
|
11 | 11 | /// </remarks> |
|
12 | 12 | public class TraceContext { |
|
13 | 13 | |
|
14 | 14 | [ThreadStatic] |
|
15 | 15 | static TraceContext _instance; |
|
16 | 16 | |
|
17 | 17 | OperationContext m_current = OperationContext.EMPTY; |
|
18 | 18 | readonly Stack<OperationContext> m_stack = new Stack<OperationContext>(); |
|
19 | 19 | readonly int m_threadId; |
|
20 | 20 | |
|
21 | 21 | public static TraceContext Instance { |
|
22 | 22 | get { |
|
23 | 23 | if (_instance == null) |
|
24 | 24 | _instance = new TraceContext(); |
|
25 | 25 | return _instance; |
|
26 | 26 | } |
|
27 | 27 | } |
|
28 | 28 | |
|
29 | 29 | public TraceContext() { |
|
30 | 30 | m_threadId = Thread.CurrentThread.ManagedThreadId; |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | public int ThreadId { |
|
34 | 34 | get { return m_threadId; } |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | public LogicalOperation CurrentOperation { |
|
38 | 38 | get { |
|
39 | 39 | return m_current.CurrentOperation; |
|
40 | 40 | } |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) { |
|
44 | 44 | //var prev = CurrentOperation; |
|
45 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); | |
|
45 | 46 | m_stack.Push(m_current); |
|
46 | 47 | m_current = new OperationContext(operation, takeOwnership); |
|
47 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); | |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | public void StartLogicalOperation(string name) { |
|
51 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationStarted, name)); | |
|
51 | 52 | m_current.BeginLogicalOperation(name); |
|
52 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationStarted, String.Format("+{0}",CurrentOperation.Name))); | |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | public void StartLogicalOperation() { |
|
56 | 56 | StartLogicalOperation(String.Empty); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | public void EndLogicalOperation() { |
|
60 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",CurrentOperation.Name, CurrentOperation.Duration))); | |
|
61 | m_current.EndLogicalOperation(); | |
|
60 | var op = m_current.EndLogicalOperation(); | |
|
61 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",op.Name, op.Duration))); | |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | public LogicalOperation DetachLogicalOperation() { |
|
65 | 65 | var prev = m_current.DetachLogicalOperation(); |
|
66 | 66 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); |
|
67 | 67 | return prev; |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | public void Leave() { |
|
71 | 71 | if (m_stack.Count > 0) { |
|
72 | 72 | m_current.Leave(); |
|
73 | 73 | //var prev = CurrentOperation; |
|
74 | 74 | m_current = m_stack.Pop(); |
|
75 | 75 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name))); |
|
76 | 76 | } else { |
|
77 | 77 | TraceLog.TraceWarning("Attempt to leave the last operation context"); |
|
78 | 78 | m_current = OperationContext.EMPTY; |
|
79 | 79 | } |
|
80 | 80 | } |
|
81 | 81 | } |
|
82 | 82 | } |
|
83 | 83 |
@@ -1,230 +1,230 | |||
|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
|
2 | 2 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
3 | 3 | <PropertyGroup> |
|
4 | 4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
5 | 5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
6 | 6 | <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid> |
|
7 | 7 | <OutputType>Library</OutputType> |
|
8 | 8 | <RootNamespace>Implab</RootNamespace> |
|
9 | 9 | <AssemblyName>Implab</AssemblyName> |
|
10 | 10 | </PropertyGroup> |
|
11 | 11 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
12 | 12 | <DebugSymbols>true</DebugSymbols> |
|
13 | 13 | <DebugType>full</DebugType> |
|
14 | 14 | <Optimize>false</Optimize> |
|
15 | 15 | <OutputPath>bin\Debug</OutputPath> |
|
16 | 16 | <DefineConstants>TRACE;DEBUG;</DefineConstants> |
|
17 | 17 | <ErrorReport>prompt</ErrorReport> |
|
18 | 18 | <WarningLevel>4</WarningLevel> |
|
19 | 19 | <ConsolePause>false</ConsolePause> |
|
20 | 20 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
21 | 21 | </PropertyGroup> |
|
22 | 22 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
23 | 23 | <DebugType>full</DebugType> |
|
24 | 24 | <Optimize>true</Optimize> |
|
25 | 25 | <OutputPath>bin\Release</OutputPath> |
|
26 | 26 | <ErrorReport>prompt</ErrorReport> |
|
27 | 27 | <WarningLevel>4</WarningLevel> |
|
28 | 28 | <ConsolePause>false</ConsolePause> |
|
29 | 29 | </PropertyGroup> |
|
30 | 30 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> |
|
31 | 31 | <DebugSymbols>true</DebugSymbols> |
|
32 | 32 | <DebugType>full</DebugType> |
|
33 | 33 | <Optimize>false</Optimize> |
|
34 | 34 | <OutputPath>bin\Debug</OutputPath> |
|
35 | 35 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> |
|
36 | 36 | <ErrorReport>prompt</ErrorReport> |
|
37 | 37 | <WarningLevel>4</WarningLevel> |
|
38 | 38 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
39 | 39 | <ConsolePause>false</ConsolePause> |
|
40 | 40 | </PropertyGroup> |
|
41 | 41 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> |
|
42 | 42 | <Optimize>true</Optimize> |
|
43 | 43 | <OutputPath>bin\Release</OutputPath> |
|
44 | 44 | <ErrorReport>prompt</ErrorReport> |
|
45 | 45 | <WarningLevel>4</WarningLevel> |
|
46 | 46 | <ConsolePause>false</ConsolePause> |
|
47 | 47 | <DefineConstants>NET_4_5</DefineConstants> |
|
48 | 48 | </PropertyGroup> |
|
49 | 49 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' "> |
|
50 | 50 | <DebugSymbols>true</DebugSymbols> |
|
51 | 51 | <DebugType>full</DebugType> |
|
52 | 52 | <Optimize>false</Optimize> |
|
53 | 53 | <OutputPath>bin\Debug</OutputPath> |
|
54 | 54 | <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants> |
|
55 | 55 | <ErrorReport>prompt</ErrorReport> |
|
56 | 56 | <WarningLevel>4</WarningLevel> |
|
57 | 57 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
58 | 58 | <ConsolePause>false</ConsolePause> |
|
59 | 59 | </PropertyGroup> |
|
60 | 60 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' "> |
|
61 | 61 | <Optimize>true</Optimize> |
|
62 | 62 | <OutputPath>bin\Release</OutputPath> |
|
63 | 63 | <DefineConstants>NET_4_5;MONO;</DefineConstants> |
|
64 | 64 | <ErrorReport>prompt</ErrorReport> |
|
65 | 65 | <WarningLevel>4</WarningLevel> |
|
66 | 66 | <ConsolePause>false</ConsolePause> |
|
67 | 67 | </PropertyGroup> |
|
68 | 68 | <ItemGroup> |
|
69 | 69 | <Reference Include="System" /> |
|
70 | 70 | <Reference Include="System.Xml" /> |
|
71 | 71 | </ItemGroup> |
|
72 | 72 | <ItemGroup> |
|
73 | 73 | <Compile Include="Component.cs" /> |
|
74 | 74 | <Compile Include="CustomEqualityComparer.cs" /> |
|
75 | 75 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> |
|
76 | 76 | <Compile Include="Diagnostics\EventText.cs" /> |
|
77 | <Compile Include="Diagnostics\IEventTextFormatter.cs" /> | |
|
78 | 77 | <Compile Include="Diagnostics\LogChannel.cs" /> |
|
79 | 78 | <Compile Include="Diagnostics\LogicalOperation.cs" /> |
|
80 | 79 | <Compile Include="Diagnostics\TextFileListener.cs" /> |
|
81 | <Compile Include="Diagnostics\TextListenerBase.cs" /> | |
|
82 | 80 | <Compile Include="Diagnostics\TraceLog.cs" /> |
|
83 | 81 | <Compile Include="Diagnostics\TraceEvent.cs" /> |
|
84 | 82 | <Compile Include="Diagnostics\TraceEventType.cs" /> |
|
85 | 83 | <Compile Include="Disposable.cs" /> |
|
86 | 84 | <Compile Include="ICancellable.cs" /> |
|
87 | 85 | <Compile Include="IProgressHandler.cs" /> |
|
88 | 86 | <Compile Include="IProgressNotifier.cs" /> |
|
89 | 87 | <Compile Include="IPromiseT.cs" /> |
|
90 | 88 | <Compile Include="IPromise.cs" /> |
|
91 | 89 | <Compile Include="IServiceLocator.cs" /> |
|
92 | 90 | <Compile Include="ITaskController.cs" /> |
|
93 | 91 | <Compile Include="JSON\JSONElementContext.cs" /> |
|
94 | 92 | <Compile Include="JSON\JSONElementType.cs" /> |
|
95 | 93 | <Compile Include="JSON\JSONGrammar.cs" /> |
|
96 | 94 | <Compile Include="JSON\JSONParser.cs" /> |
|
97 | 95 | <Compile Include="JSON\JSONScanner.cs" /> |
|
98 | 96 | <Compile Include="JSON\JsonTokenType.cs" /> |
|
99 | 97 | <Compile Include="JSON\JSONWriter.cs" /> |
|
100 | 98 | <Compile Include="JSON\JSONXmlReader.cs" /> |
|
101 | 99 | <Compile Include="JSON\JSONXmlReaderOptions.cs" /> |
|
102 | 100 | <Compile Include="JSON\StringTranslator.cs" /> |
|
103 | 101 | <Compile Include="Parallels\DispatchPool.cs" /> |
|
104 | 102 | <Compile Include="Parallels\ArrayTraits.cs" /> |
|
105 | 103 | <Compile Include="Parallels\MTQueue.cs" /> |
|
106 | 104 | <Compile Include="Parallels\WorkerPool.cs" /> |
|
107 | 105 | <Compile Include="Parsing\Alphabet.cs" /> |
|
108 | 106 | <Compile Include="Parsing\AlphabetBase.cs" /> |
|
109 | 107 | <Compile Include="Parsing\AltToken.cs" /> |
|
110 | 108 | <Compile Include="Parsing\BinaryToken.cs" /> |
|
111 | 109 | <Compile Include="Parsing\CatToken.cs" /> |
|
112 | 110 | <Compile Include="Parsing\CDFADefinition.cs" /> |
|
113 | 111 | <Compile Include="Parsing\DFABuilder.cs" /> |
|
114 | 112 | <Compile Include="Parsing\DFADefinitionBase.cs" /> |
|
115 | 113 | <Compile Include="Parsing\DFAStateDescriptor.cs" /> |
|
116 | 114 | <Compile Include="Parsing\DFAutomaton.cs" /> |
|
117 | 115 | <Compile Include="Parsing\EDFADefinition.cs" /> |
|
118 | 116 | <Compile Include="Parsing\EmptyToken.cs" /> |
|
119 | 117 | <Compile Include="Parsing\EndToken.cs" /> |
|
120 | 118 | <Compile Include="Parsing\EnumAlphabet.cs" /> |
|
121 | 119 | <Compile Include="Parsing\Grammar.cs" /> |
|
122 | 120 | <Compile Include="Parsing\IAlphabet.cs" /> |
|
123 | 121 | <Compile Include="Parsing\IDFADefinition.cs" /> |
|
124 | 122 | <Compile Include="Parsing\IVisitor.cs" /> |
|
125 | 123 | <Compile Include="Parsing\ParserException.cs" /> |
|
126 | 124 | <Compile Include="Parsing\Scanner.cs" /> |
|
127 | 125 | <Compile Include="Parsing\StarToken.cs" /> |
|
128 | 126 | <Compile Include="Parsing\SymbolToken.cs" /> |
|
129 | 127 | <Compile Include="Parsing\Token.cs" /> |
|
130 | 128 | <Compile Include="ServiceLocator.cs" /> |
|
131 | 129 | <Compile Include="TaskController.cs" /> |
|
132 | 130 | <Compile Include="ProgressInitEventArgs.cs" /> |
|
133 | 131 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
134 | 132 | <Compile Include="Parallels\AsyncPool.cs" /> |
|
135 | 133 | <Compile Include="Safe.cs" /> |
|
136 | 134 | <Compile Include="ValueEventArgs.cs" /> |
|
137 | 135 | <Compile Include="PromiseExtensions.cs" /> |
|
138 | 136 | <Compile Include="SyncContextPromise.cs" /> |
|
139 | 137 | <Compile Include="Diagnostics\OperationContext.cs" /> |
|
140 | 138 | <Compile Include="Diagnostics\TraceContext.cs" /> |
|
141 | 139 | <Compile Include="Diagnostics\LogEventArgs.cs" /> |
|
142 | 140 | <Compile Include="Diagnostics\LogEventArgsT.cs" /> |
|
143 | 141 | <Compile Include="Diagnostics\Extensions.cs" /> |
|
144 | 142 | <Compile Include="IComponentContainer.cs" /> |
|
145 | 143 | <Compile Include="PromiseEventType.cs" /> |
|
146 | 144 | <Compile Include="ComponentContainer.cs" /> |
|
147 | 145 | <Compile Include="DisposablePool.cs" /> |
|
148 | 146 | <Compile Include="ObjectPool.cs" /> |
|
149 | 147 | <Compile Include="Parallels\AsyncQueue.cs" /> |
|
150 | 148 | <Compile Include="PromiseT.cs" /> |
|
151 | 149 | <Compile Include="IDeferred.cs" /> |
|
152 | 150 | <Compile Include="IDeferredT.cs" /> |
|
153 | 151 | <Compile Include="AbstractPromise.cs" /> |
|
154 | 152 | <Compile Include="Promise.cs" /> |
|
155 | 153 | <Compile Include="PromiseTransientException.cs" /> |
|
156 | 154 | <Compile Include="Parallels\Signal.cs" /> |
|
157 | 155 | <Compile Include="Parallels\SharedLock.cs" /> |
|
156 | <Compile Include="Diagnostics\ILogWriter.cs" /> | |
|
157 | <Compile Include="Diagnostics\ListenerBase.cs" /> | |
|
158 | 158 | </ItemGroup> |
|
159 | 159 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
160 | 160 | <ItemGroup /> |
|
161 | 161 | <ProjectExtensions> |
|
162 | 162 | <MonoDevelop> |
|
163 | 163 | <Properties> |
|
164 | 164 | <Policies> |
|
165 | 165 | <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> |
|
166 | 166 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> |
|
167 | 167 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> |
|
168 | 168 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> |
|
169 | 169 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> |
|
170 | 170 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> |
|
171 | 171 | <NameConventionPolicy> |
|
172 | 172 | <Rules> |
|
173 | 173 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
174 | 174 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
175 | 175 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
176 | 176 | <RequiredPrefixes> |
|
177 | 177 | <String>I</String> |
|
178 | 178 | </RequiredPrefixes> |
|
179 | 179 | </NamingRule> |
|
180 | 180 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
181 | 181 | <RequiredSuffixes> |
|
182 | 182 | <String>Attribute</String> |
|
183 | 183 | </RequiredSuffixes> |
|
184 | 184 | </NamingRule> |
|
185 | 185 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
186 | 186 | <RequiredSuffixes> |
|
187 | 187 | <String>EventArgs</String> |
|
188 | 188 | </RequiredSuffixes> |
|
189 | 189 | </NamingRule> |
|
190 | 190 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
191 | 191 | <RequiredSuffixes> |
|
192 | 192 | <String>Exception</String> |
|
193 | 193 | </RequiredSuffixes> |
|
194 | 194 | </NamingRule> |
|
195 | 195 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
196 | 196 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> |
|
197 | 197 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
198 | 198 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> |
|
199 | 199 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
200 | 200 | <RequiredPrefixes> |
|
201 | 201 | <String>m_</String> |
|
202 | 202 | </RequiredPrefixes> |
|
203 | 203 | </NamingRule> |
|
204 | 204 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> |
|
205 | 205 | <RequiredPrefixes> |
|
206 | 206 | <String>_</String> |
|
207 | 207 | </RequiredPrefixes> |
|
208 | 208 | </NamingRule> |
|
209 | 209 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
210 | 210 | <RequiredPrefixes> |
|
211 | 211 | <String>m_</String> |
|
212 | 212 | </RequiredPrefixes> |
|
213 | 213 | </NamingRule> |
|
214 | 214 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
215 | 215 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
216 | 216 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
217 | 217 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
218 | 218 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
219 | 219 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
220 | 220 | <RequiredPrefixes> |
|
221 | 221 | <String>T</String> |
|
222 | 222 | </RequiredPrefixes> |
|
223 | 223 | </NamingRule> |
|
224 | 224 | </Rules> |
|
225 | 225 | </NameConventionPolicy> |
|
226 | 226 | </Policies> |
|
227 | 227 | </Properties> |
|
228 | 228 | </MonoDevelop> |
|
229 | 229 | </ProjectExtensions> |
|
230 | 230 | </Project> No newline at end of file |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now