Rename internal CoreLib Console to LowLevelConsole (dotnet/coreclr#9341)
authorJan Kotas <jkotas@microsoft.com>
Sun, 5 Feb 2017 11:56:42 +0000 (03:56 -0800)
committerGitHub <noreply@github.com>
Sun, 5 Feb 2017 11:56:42 +0000 (03:56 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/5a885fa087396974b728d8af6320da8a271dbbbc

src/coreclr/src/mscorlib/model.xml
src/coreclr/src/mscorlib/src/System/LowLevelConsole.cs
src/coreclr/src/mscorlib/src/System/Resources/ResourceReader.cs
src/coreclr/tests/src/managed/Compilation/HelloWorld.cs

index 102e5e5..a9b3777 100644 (file)
       <Member Name="get_TraceLevel" />
     </Type>
     <!--End of PFX types -->
-    <Type Name="System.Console">
+    <Type Name="System.LowLevelConsole">
       <Member Name="Write(System.String)" />
       <Member Name="WriteLine(System.String)" />
       <Member Name="WriteLine" />
index 316583e..29e6918 100644 (file)
@@ -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();
+        }
+    }
 }
index 8b81e2b..c520112 100644 (file)
@@ -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
index 67e0148..bbf92a3 100644 (file)
@@ -8,7 +8,7 @@ class C
 {
     static int Main()
     {
-        Console.WriteLine("Hello " + "world");
+        LowLevelConsole.WriteLine("Hello " + "world");
         return 100;
     }
 }