mscorlib(4.0.0.0) API with additions
Debugger.cs
3 using System.Security;
5 
6 namespace System.Diagnostics
7 {
9  [ComVisible(true)]
10  [__DynamicallyInvokable]
11  public sealed class Debugger
12  {
13  private class CrossThreadDependencyNotification : ICustomDebuggerNotification
14  {
15  }
16 
18  public static readonly string DefaultCategory;
19 
23  [__DynamicallyInvokable]
24  public static bool IsAttached
25  {
26  [MethodImpl(MethodImplOptions.InternalCall)]
27  [SecuritySafeCritical]
28  [__DynamicallyInvokable]
29  get;
30  }
31 
33  [Obsolete("Do not create instances of the Debugger class. Call the static methods directly on this type instead", true)]
34  public Debugger()
35  {
36  }
37 
40  [SecuritySafeCritical]
41  [__DynamicallyInvokable]
42  public static void Break()
43  {
44  if (!IsAttached)
45  {
46  try
47  {
49  }
50  catch (SecurityException)
51  {
52  return;
53  }
54  }
55  BreakInternal();
56  }
57 
58  [SecuritySafeCritical]
59  private static void BreakCanThrow()
60  {
61  if (!IsAttached)
62  {
64  }
65  BreakInternal();
66  }
67 
68  [MethodImpl(MethodImplOptions.InternalCall)]
69  [SecurityCritical]
70  private static extern void BreakInternal();
71 
76  [SecuritySafeCritical]
77  [__DynamicallyInvokable]
78  public static bool Launch()
79  {
80  if (IsAttached)
81  {
82  return true;
83  }
84  try
85  {
87  }
88  catch (SecurityException)
89  {
90  return false;
91  }
92  return LaunchInternal();
93  }
94 
95  [MethodImpl(MethodImplOptions.NoInlining)]
96  private static void NotifyOfCrossThreadDependencySlow()
97  {
98  CrossThreadDependencyNotification data = new CrossThreadDependencyNotification();
99  CustomNotification(data);
100  }
101 
103  [ComVisible(false)]
104  public static void NotifyOfCrossThreadDependency()
105  {
106  if (IsAttached)
107  {
108  NotifyOfCrossThreadDependencySlow();
109  }
110  }
111 
112  [MethodImpl(MethodImplOptions.InternalCall)]
113  [SecurityCritical]
114  private static extern bool LaunchInternal();
115 
120  [MethodImpl(MethodImplOptions.InternalCall)]
121  [SecuritySafeCritical]
122  public static extern void Log(int level, string category, string message);
123 
127  [MethodImpl(MethodImplOptions.InternalCall)]
128  [SecuritySafeCritical]
129  public static extern bool IsLogging();
130 
131  [MethodImpl(MethodImplOptions.InternalCall)]
132  [SecuritySafeCritical]
133  private static extern void CustomNotification(ICustomDebuggerNotification data);
134  }
135 }
Describes a set of security permissions applied to code. This class cannot be inherited.
Definition: __Canon.cs:3
static void Log(int level, string category, string message)
Posts a message for the attached debugger.
Debugger()
Initializes a new instance of the T:System.Diagnostics.Debugger class.
Definition: Debugger.cs:34
static bool IsLogging()
Checks to see if logging is enabled by an attached debugger.
static bool IsAttached
Gets a value that indicates whether a debugger is attached to the process.
Definition: Debugger.cs:25
static bool Launch()
Launches and attaches a debugger to the process.
Definition: Debugger.cs:78
static readonly string DefaultCategory
Represents the default category of message with a constant.
Definition: Debugger.cs:18
MethodImplOptions
Defines the details of how a method is implemented.
Enables communication with a debugger. This class cannot be inherited.
Definition: Debugger.cs:11
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
static void NotifyOfCrossThreadDependency()
Notifies a debugger that execution is about to enter a path that involves a cross-thread dependency.
Definition: Debugger.cs:104
SecurityPermissionFlag
Specifies access flags for the security permission object.
static void Break()
Signals a breakpoint to an attached debugger.
Definition: Debugger.cs:42
The exception that is thrown when a security error is detected.