Avoid random failure in CountdownEvent unit test
[mono.git] / mcs / class / corlib / System.Diagnostics / DebuggerVisualizerAttribute.cs
1 //
2 // System.Diagnostics.DebuggerVisualizerAttribute.cs
3 //
4 // Author:
5 //   Chris Toshok (toshok@novell.com)
6 //
7
8 //
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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;
32 using System.Runtime.InteropServices;
33
34 namespace System.Diagnostics
35 {
36         [AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple=true)]
37         [ComVisible (true)]
38         public sealed class DebuggerVisualizerAttribute : Attribute
39         {
40                 private string description;
41                 private string visualizerSourceName;
42                 private string visualizerName;
43                 private string targetTypeName;
44                 private Type target;
45
46                 public DebuggerVisualizerAttribute (string visualizerTypeName)
47                 {
48                         this.visualizerName = visualizerTypeName;
49                 }
50
51                 public DebuggerVisualizerAttribute (Type visualizer)
52                 {
53                         if (visualizer == null)
54                                 throw new ArgumentNullException ("visualizer");
55
56                         this.visualizerName = visualizer.AssemblyQualifiedName;
57                 }
58
59                 public DebuggerVisualizerAttribute (string visualizerTypeName, string visualizerObjectSourceTypeName)
60                 {
61                         this.visualizerName = visualizerTypeName;
62                         this.visualizerSourceName = visualizerObjectSourceTypeName;
63                 }
64
65                 public DebuggerVisualizerAttribute (string visualizerTypeName, Type visualizerObjectSource)
66                 {
67                         if (visualizerObjectSource == null)
68                                 throw new ArgumentNullException ("visualizerObjectSource");
69
70                         this.visualizerName = visualizerTypeName;
71                         this.visualizerSourceName = visualizerObjectSource.AssemblyQualifiedName;
72                 }
73
74                 public DebuggerVisualizerAttribute (Type visualizer, string visualizerObjectSourceTypeName)
75                 {
76                         if (visualizer == null)
77                                 throw new ArgumentNullException ("visualizer");
78
79                         this.visualizerName = visualizer.AssemblyQualifiedName;
80                         this.visualizerSourceName = visualizerObjectSourceTypeName;
81                 }
82
83                 public DebuggerVisualizerAttribute (Type visualizer, Type visualizerObjectSource)
84                 {
85                         if (visualizer == null)
86                                 throw new ArgumentNullException ("visualizer");
87                         if (visualizerObjectSource == null)
88                                 throw new ArgumentNullException ("visualizerObjectSource");
89
90                         this.visualizerName = visualizer.AssemblyQualifiedName;
91                         this.visualizerSourceName = visualizerObjectSource.AssemblyQualifiedName;
92                 }
93
94                 public string Description {
95                         get {
96                                 return description;
97                         }
98                         set {
99                                 description = value;
100                         }
101                 }
102
103                 public Type Target {
104                         get {
105                                 return target;
106                         }
107                         set {
108                                 target = value;
109                                 targetTypeName = target.AssemblyQualifiedName;
110                         }
111                 }
112
113                 public string TargetTypeName {
114                         get {
115                                 return targetTypeName;
116                         }
117                         set {
118                                 targetTypeName = value;
119                         }
120                 }
121
122                 // Debugged program-side type
123                 public string VisualizerObjectSourceTypeName {
124                         get {
125                                 return visualizerSourceName;
126                         }
127                 }
128
129                 // Debugger-side type
130                 public string VisualizerTypeName {
131                         get {
132                                 return visualizerName;
133                         }
134                 }
135         }
136 }