The Labs \ Source Viewer \ SSCLI \ System.Diagnostics \ DebuggerDisplayAttribute

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

Developer Fusion