1 // ==++== 2 // 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // 5 // ==--== 6 /*============================================================ 7 ** 8 ** Class: DebuggerAttributes 9 ** 10 ** 11 ** Purpose: Attributes for debugger 12 ** 13 ** 14 ===========================================================*/ 15 16 17 namespace System.Diagnostics { 18 using System; 19 using System.Runtime.InteropServices; 20 using System.Diagnostics.Contracts; 21 22 [Serializable] 23 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)] 24 [ComVisible(true)] 25 public sealed class DebuggerStepThroughAttribute : Attribute 26 { DebuggerStepThroughAttribute()27 public DebuggerStepThroughAttribute () {} 28 } 29 30 [Serializable] 31 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)] 32 [ComVisible(true)] 33 public sealed class DebuggerStepperBoundaryAttribute : Attribute 34 { DebuggerStepperBoundaryAttribute()35 public DebuggerStepperBoundaryAttribute () {} 36 } 37 38 [Serializable] 39 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)] 40 [ComVisible(true)] 41 public sealed class DebuggerHiddenAttribute : Attribute 42 { DebuggerHiddenAttribute()43 public DebuggerHiddenAttribute () {} 44 } 45 46 [Serializable] 47 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor |AttributeTargets.Struct, Inherited = false)] 48 [ComVisible(true)] 49 public sealed class DebuggerNonUserCodeAttribute : Attribute 50 { DebuggerNonUserCodeAttribute()51 public DebuggerNonUserCodeAttribute () {} 52 } 53 54 // Attribute class used by the compiler to mark modules. 55 // If present, then debugging information for everything in the 56 // assembly was generated by the compiler, and will be preserved 57 // by the Runtime so that the debugger can provide full functionality 58 // in the case of JIT attach. If not present, then the compiler may 59 // or may not have included debugging information, and the Runtime 60 // won't preserve the debugging info, which will make debugging after 61 // a JIT attach difficult. 62 [AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Module, AllowMultiple = false)] 63 [ComVisible(true)] 64 public sealed class DebuggableAttribute : Attribute 65 { 66 [Flags] 67 [ComVisible(true)] 68 public enum DebuggingModes 69 { 70 None = 0x0, 71 Default = 0x1, 72 DisableOptimizations = 0x100, 73 IgnoreSymbolStoreSequencePoints = 0x2, 74 EnableEditAndContinue = 0x4 75 } 76 77 private DebuggingModes m_debuggingModes; 78 DebuggableAttribute(bool isJITTrackingEnabled, bool isJITOptimizerDisabled)79 public DebuggableAttribute(bool isJITTrackingEnabled, 80 bool isJITOptimizerDisabled) 81 { 82 m_debuggingModes = 0; 83 84 if (isJITTrackingEnabled) 85 { 86 m_debuggingModes |= DebuggingModes.Default; 87 } 88 89 if (isJITOptimizerDisabled) 90 { 91 m_debuggingModes |= DebuggingModes.DisableOptimizations; 92 } 93 } 94 DebuggableAttribute(DebuggingModes modes)95 public DebuggableAttribute(DebuggingModes modes) 96 { 97 m_debuggingModes = modes; 98 } 99 100 public bool IsJITTrackingEnabled 101 { 102 get { return ((m_debuggingModes & DebuggingModes.Default) != 0); } 103 } 104 105 public bool IsJITOptimizerDisabled 106 { 107 get { return ((m_debuggingModes & DebuggingModes.DisableOptimizations) != 0); } 108 } 109 110 public DebuggingModes DebuggingFlags 111 { 112 get { return m_debuggingModes; } 113 } 114 } 115 116 // DebuggerBrowsableState states are defined as follows: 117 // Never never show this element 118 // Expanded expansion of the class is done, so that all visible internal members are shown 119 // Collapsed expansion of the class is not performed. Internal visible members are hidden 120 // RootHidden The target element itself should not be shown, but should instead be 121 // automatically expanded to have its members displayed. 122 // Default value is collapsed 123 124 // Please also change the code which validates DebuggerBrowsableState variable (in this file) 125 // if you change this enum. 126 [ComVisible(true)] 127 public enum DebuggerBrowsableState 128 { 129 Never = 0, 130 //Expanded is not supported in this release 131 //Expanded = 1, 132 Collapsed = 2, 133 RootHidden = 3 134 } 135 136 137 // the one currently supported with the csee.dat 138 // (mcee.dat, autoexp.dat) file. 139 [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] 140 [ComVisible(true)] 141 public sealed class DebuggerBrowsableAttribute: Attribute 142 { 143 private DebuggerBrowsableState state; DebuggerBrowsableAttribute(DebuggerBrowsableState state)144 public DebuggerBrowsableAttribute(DebuggerBrowsableState state) 145 { 146 if( state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden) 147 throw new ArgumentOutOfRangeException("state"); 148 Contract.EndContractBlock(); 149 150 this.state = state; 151 } 152 public DebuggerBrowsableState State 153 { 154 get { return state; } 155 } 156 } 157 158 159 // DebuggerTypeProxyAttribute 160 [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] 161 [ComVisible(true)] 162 public sealed class DebuggerTypeProxyAttribute: Attribute 163 { 164 private string typeName; 165 private string targetName; 166 private Type target; 167 DebuggerTypeProxyAttribute(Type type)168 public DebuggerTypeProxyAttribute(Type type) 169 { 170 if (type == null) { 171 throw new ArgumentNullException("type"); 172 } 173 Contract.EndContractBlock(); 174 175 this.typeName = type.AssemblyQualifiedName; 176 } 177 DebuggerTypeProxyAttribute(string typeName)178 public DebuggerTypeProxyAttribute(string typeName) 179 { 180 this.typeName = typeName; 181 } 182 public string ProxyTypeName 183 { 184 get { return typeName; } 185 } 186 187 public Type Target 188 { 189 set { 190 if( value == null) { 191 throw new ArgumentNullException("value"); 192 } 193 Contract.EndContractBlock(); 194 195 targetName = value.AssemblyQualifiedName; 196 target = value; 197 } 198 199 get { return target; } 200 } 201 202 public string TargetTypeName 203 { 204 get { return targetName; } 205 set { targetName = value; } 206 207 } 208 } 209 210 // This attribute is used to control what is displayed for the given class or field 211 // in the data windows in the debugger. The single argument to this attribute is 212 // the string that will be displayed in the value column for instances of the type. 213 // This string can include text between { and } which can be either a field, 214 // property or method (as will be documented in mscorlib). In the C# case, 215 // a general expression will be allowed which only has implicit access to the this pointer 216 // for the current instance of the target type. The expression will be limited, 217 // however: there is no access to aliases, locals, or pointers. 218 // In addition, attributes on properties referenced in the expression are not processed. 219 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Assembly, AllowMultiple = true)] 220 [ComVisible(true)] 221 public sealed class DebuggerDisplayAttribute : Attribute 222 { 223 private string name; 224 private string value; 225 private string type; 226 private string targetName; 227 private Type target; 228 DebuggerDisplayAttribute(string value)229 public DebuggerDisplayAttribute(string value) 230 { 231 if( value == null ) { 232 this.value = ""; 233 } 234 else { 235 this.value = value; 236 } 237 name = ""; 238 type = ""; 239 } 240 241 public string Value 242 { 243 get { return this.value; } 244 } 245 246 public string Name 247 { 248 get { return name; } 249 set { name = value; } 250 } 251 252 public string Type 253 { 254 get { return type; } 255 set { type = value; } 256 } 257 258 public Type Target 259 { 260 set { 261 if( value == null) { 262 throw new ArgumentNullException("value"); 263 } 264 Contract.EndContractBlock(); 265 266 targetName = value.AssemblyQualifiedName; 267 target = value; 268 } 269 get { return target; } 270 } 271 272 public string TargetTypeName 273 { 274 get { return targetName; } 275 set { targetName = value; } 276 277 } 278 } 279 280 281 /// <summary> 282 /// Signifies that the attributed type has a visualizer which is pointed 283 /// to by the parameter type name strings. 284 /// </summary> 285 [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] 286 [ComVisible(true)] 287 public sealed class DebuggerVisualizerAttribute: Attribute 288 { 289 private string visualizerObjectSourceName; 290 private string visualizerName; 291 private string description; 292 private string targetName; 293 private Type target; 294 DebuggerVisualizerAttribute(string visualizerTypeName)295 public DebuggerVisualizerAttribute(string visualizerTypeName) 296 { 297 this.visualizerName = visualizerTypeName; 298 } DebuggerVisualizerAttribute(string visualizerTypeName, string visualizerObjectSourceTypeName)299 public DebuggerVisualizerAttribute(string visualizerTypeName, string visualizerObjectSourceTypeName) 300 { 301 this.visualizerName = visualizerTypeName; 302 this.visualizerObjectSourceName = visualizerObjectSourceTypeName; 303 } DebuggerVisualizerAttribute(string visualizerTypeName, Type visualizerObjectSource)304 public DebuggerVisualizerAttribute(string visualizerTypeName, Type visualizerObjectSource) 305 { 306 if (visualizerObjectSource == null) { 307 throw new ArgumentNullException("visualizerObjectSource"); 308 } 309 Contract.EndContractBlock(); 310 this.visualizerName = visualizerTypeName; 311 this.visualizerObjectSourceName = visualizerObjectSource.AssemblyQualifiedName; 312 } DebuggerVisualizerAttribute(Type visualizer)313 public DebuggerVisualizerAttribute(Type visualizer) 314 { 315 if (visualizer == null) { 316 throw new ArgumentNullException("visualizer"); 317 } 318 Contract.EndContractBlock(); 319 this.visualizerName = visualizer.AssemblyQualifiedName; 320 } DebuggerVisualizerAttribute(Type visualizer, Type visualizerObjectSource)321 public DebuggerVisualizerAttribute(Type visualizer, Type visualizerObjectSource) 322 { 323 if (visualizer == null) { 324 throw new ArgumentNullException("visualizer"); 325 } 326 if (visualizerObjectSource == null) { 327 throw new ArgumentNullException("visualizerObjectSource"); 328 } 329 Contract.EndContractBlock(); 330 this.visualizerName = visualizer.AssemblyQualifiedName; 331 this.visualizerObjectSourceName = visualizerObjectSource.AssemblyQualifiedName; 332 } DebuggerVisualizerAttribute(Type visualizer, string visualizerObjectSourceTypeName)333 public DebuggerVisualizerAttribute(Type visualizer, string visualizerObjectSourceTypeName) 334 { 335 if (visualizer == null) { 336 throw new ArgumentNullException("visualizer"); 337 } 338 Contract.EndContractBlock(); 339 this.visualizerName = visualizer.AssemblyQualifiedName; 340 this.visualizerObjectSourceName = visualizerObjectSourceTypeName; 341 } 342 343 public string VisualizerObjectSourceTypeName 344 { 345 get { return visualizerObjectSourceName; } 346 } 347 public string VisualizerTypeName 348 { 349 get { return visualizerName; } 350 } 351 public string Description 352 { 353 get { return description; } 354 set { description = value; } 355 } 356 357 public Type Target 358 { 359 set { 360 if( value == null) { 361 throw new ArgumentNullException("value"); 362 } 363 Contract.EndContractBlock(); 364 365 targetName = value.AssemblyQualifiedName; 366 target = value; 367 } 368 369 get { return target; } 370 } 371 372 public string TargetTypeName 373 { 374 set { targetName = value; } 375 get { return targetName; } 376 } 377 } 378 } 379 380 381