From 5a885fa087396974b728d8af6320da8a271dbbbc Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 5 Feb 2017 03:56:42 -0800 Subject: [PATCH] Rename internal CoreLib Console to LowLevelConsole (#9341) --- src/mscorlib/model.xml | 2 +- src/mscorlib/src/System/LowLevelConsole.cs | 36 ++++++++++++++++------ .../src/System/Resources/ResourceReader.cs | 4 +-- tests/src/managed/Compilation/HelloWorld.cs | 2 +- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/mscorlib/model.xml b/src/mscorlib/model.xml index 102e5e5..a9b3777 100644 --- a/src/mscorlib/model.xml +++ b/src/mscorlib/model.xml @@ -12588,7 +12588,7 @@ - + diff --git a/src/mscorlib/src/System/LowLevelConsole.cs b/src/mscorlib/src/System/LowLevelConsole.cs index 316583e..29e6918 100644 --- a/src/mscorlib/src/System/LowLevelConsole.cs +++ b/src/mscorlib/src/System/LowLevelConsole.cs @@ -10,18 +10,14 @@ using Microsoft.Win32.SafeHandles; namespace System { // - // Simple limited console class for internal printf-style debugging in mscorlib - // and low-level tests that just want to depend on mscorlib. + // Simple limited console class for internal printf-style debugging in System.Private.CoreLib + // and low-level tests that want to call System.Private.CoreLib directly // - public static class Console + public static class LowLevelConsole { - static SafeFileHandle _outputHandle; - - static Console() - { - _outputHandle = new SafeFileHandle(Win32Native.GetStdHandle(Win32Native.STD_OUTPUT_HANDLE), false); - } + private static readonly SafeFileHandle _outputHandle = + new SafeFileHandle(Win32Native.GetStdHandle(Win32Native.STD_OUTPUT_HANDLE), false); public static unsafe void Write(string s) { @@ -44,4 +40,26 @@ namespace System Write(Environment.NewLine); } } + + // + // Internal wrapper with the regular name for convenience. Note that it cannot be public to avoid colliding + // with the full Console type. + // + internal static class Console + { + public static void Write(string s) + { + LowLevelConsole.Write(s); + } + + public static void WriteLine(string s) + { + LowLevelConsole.WriteLine(s); + } + + public static void WriteLine() + { + LowLevelConsole.WriteLine(); + } + } } diff --git a/src/mscorlib/src/System/Resources/ResourceReader.cs b/src/mscorlib/src/System/Resources/ResourceReader.cs index 8b81e2b..c520112 100644 --- a/src/mscorlib/src/System/Resources/ResourceReader.cs +++ b/src/mscorlib/src/System/Resources/ResourceReader.cs @@ -813,7 +813,7 @@ namespace System.Resources { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); } BCLDebug.Log("RESMGRFILEFORMAT", "ReadResources: Expecting " + _numResources + " resources."); -#if _DEBUG +#if RESOURCE_FILE_FORMAT_DEBUG if (ResourceManager.DEBUG >= 4) Console.WriteLine("ResourceReader::ReadResources - Reading in "+_numResources+" resources"); #endif @@ -833,7 +833,7 @@ namespace System.Resources { SkipString(); } -#if _DEBUG +#if RESOURCE_FILE_FORMAT_DEBUG if (ResourceManager.DEBUG >= 5) Console.WriteLine("ResourceReader::ReadResources - Reading in "+numTypes+" type table entries"); #endif diff --git a/tests/src/managed/Compilation/HelloWorld.cs b/tests/src/managed/Compilation/HelloWorld.cs index 67e0148..bbf92a3 100644 --- a/tests/src/managed/Compilation/HelloWorld.cs +++ b/tests/src/managed/Compilation/HelloWorld.cs @@ -8,7 +8,7 @@ class C { static int Main() { - Console.WriteLine("Hello " + "world"); + LowLevelConsole.WriteLine("Hello " + "world"); return 100; } } -- 2.7.4