-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Internal.Console to shared CoreLib & port to Unix (#42983)
- Loading branch information
1 parent
61d444a
commit 58f28f6
Showing
18 changed files
with
125 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/coreclr/src/System.Private.CoreLib/src/Internal/Console.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
18 changes: 0 additions & 18 deletions
18
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PrintF.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#include "pal_config.h" | ||
#include "pal_log.h" | ||
|
||
#include <stdio.h> | ||
|
||
void SystemNative_Log(uint8_t* buffer, int32_t length) | ||
{ | ||
fwrite(buffer, 1, (size_t)length, stdout); | ||
fflush(stdout); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/libraries/System.Private.CoreLib/src/Internal/Console.Unix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Text; | ||
|
||
namespace Internal | ||
{ | ||
public static partial class Console | ||
{ | ||
public static unsafe void Write(string s) | ||
{ | ||
byte[] bytes = Encoding.UTF8.GetBytes(s); | ||
fixed (byte* pBytes = bytes) | ||
{ | ||
Interop.Sys.Log(pBytes, bytes.Length); | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/libraries/System.Private.CoreLib/src/Internal/Console.Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Text; | ||
|
||
namespace Internal | ||
{ | ||
public static partial class Console | ||
{ | ||
private static readonly IntPtr s_outputHandle = | ||
Interop.Kernel32.GetStdHandle(Interop.Kernel32.HandleTypes.STD_OUTPUT_HANDLE); | ||
|
||
public static unsafe void Write(string s) | ||
{ | ||
byte[] bytes = Encoding.UTF8.GetBytes(s); | ||
fixed (byte* pBytes = bytes) | ||
{ | ||
Interop.Kernel32.WriteFile(s_outputHandle, pBytes, bytes.Length, out _, IntPtr.Zero); | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/System.Private.CoreLib/src/Internal/Console.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Internal | ||
{ | ||
// | ||
// 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 partial class Console | ||
{ | ||
public static void WriteLine(string? s) => | ||
Write(s + Environment.NewLineConst); | ||
|
||
public static void WriteLine() => | ||
Write(Environment.NewLineConst); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
src/mono/netcore/System.Private.CoreLib/src/Mono/Console.Mono.cs
This file was deleted.
Oops, something went wrong.