blob: 621bc41b4bff6bb42ed58a720329148df64d94bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#if _DEBUG
// This class writes to wherever OutputDebugString writes to. If you don't have
// a Windows app (ie, something hosted in IE), you can use this to redirect Console
// output for some good old-fashioned console spew in MSDEV's debug output window.
using System;
using System.IO;
using System.Text;
using System.Security;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Microsoft.Win32;
using System.Globalization;
namespace System.IO {
internal class __DebugOutputTextWriter : TextWriter {
private readonly String _consoleType;
internal __DebugOutputTextWriter(String consoleType): base(CultureInfo.InvariantCulture)
{
_consoleType = consoleType;
}
public override Encoding Encoding {
#if FEATURE_CORECLR
[System.Security.SecuritySafeCritical]
#endif
get {
if (Marshal.SystemDefaultCharSize == 1)
return Encoding.Default;
else
return new UnicodeEncoding(false, false);
}
}
[System.Security.SecuritySafeCritical] // auto-generated
public override void Write(char c)
{
OutputDebugString(c.ToString());
}
[System.Security.SecuritySafeCritical] // auto-generated
public override void Write(String str)
{
OutputDebugString(str);
}
[System.Security.SecuritySafeCritical] // auto-generated
public override void Write(char[] array)
{
if (array != null)
OutputDebugString(new String(array));
}
[System.Security.SecuritySafeCritical] // auto-generated
public override void WriteLine(String str)
{
if (str != null)
OutputDebugString(_consoleType + str);
else
OutputDebugString("<null>");
OutputDebugString(new String(CoreNewLine));
}
[System.Security.SecurityCritical] // auto-generated
[DllImport(Win32Native.KERNEL32, CharSet=CharSet.Auto)]
[SuppressUnmanagedCodeSecurityAttribute()]
private static extern void OutputDebugString(String output);
}
}
#endif // _DEBUG
|