From d65600b4b0d08bd151f1c981add0ba08c4d12a67 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid Date: Fri, 4 Oct 2019 21:48:15 +0300 Subject: [PATCH] Replace PrintF with Console.WriteLine and cleanups (dotnet/corefx#41540) * Replace PrintF with Console.WriteLine and cleanups * PR feedback: simplify WriteLine arguments Commit migrated from https://github.com/dotnet/corefx/commit/c28a9e69902bcbc0d742732630bd6e82ac922d5b --- .../src/Microsoft/Win32/SafeHandles/SafeX509Handles.Unix.cs | 4 +--- src/libraries/Native/Unix/System.Native/pal_string.c | 11 ----------- src/libraries/Native/Unix/System.Native/pal_string.h | 9 --------- src/libraries/System.Net.Http/src/System.Net.Http.csproj | 4 +--- .../System.Net.Security/src/System.Net.Security.csproj | 4 +--- .../src/System.Security.Cryptography.X509Certificates.csproj | 6 +++--- 6 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeX509Handles.Unix.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeX509Handles.Unix.cs index 60d3e12..984ad13 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeX509Handles.Unix.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/SafeX509Handles.Unix.cs @@ -21,9 +21,7 @@ namespace Microsoft.Win32.SafeHandles { if (s_captureTrace) { - Interop.Sys.PrintF( - "%s\n\n", - $"0x{handle.ToInt64():x} {_stacktrace?.ToString() ?? "no stacktrace..."}"); + Console.WriteLine($"0x{handle.ToInt64():x} {_stacktrace?.ToString() ?? "no stacktrace..."}"); } } #endif diff --git a/src/libraries/Native/Unix/System.Native/pal_string.c b/src/libraries/Native/Unix/System.Native/pal_string.c index 6562816..48d2e84 100644 --- a/src/libraries/Native/Unix/System.Native/pal_string.c +++ b/src/libraries/Native/Unix/System.Native/pal_string.c @@ -2,14 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "pal_config.h" #include "pal_string.h" #include "pal_utilities.h" #include #include #include -#include int32_t SystemNative_SNPrintF(char* string, int32_t size, const char* format, ...) { @@ -26,12 +24,3 @@ int32_t SystemNative_SNPrintF(char* string, int32_t size, const char* format, .. va_end(arguments); return result; } - -int32_t SystemNative_PrintF(const char* format, ...) -{ - va_list arguments; - va_start(arguments, format); - int result = vprintf(format, arguments); - va_end(arguments); - return result; -} diff --git a/src/libraries/Native/Unix/System.Native/pal_string.h b/src/libraries/Native/Unix/System.Native/pal_string.h index 6b1c3b1..380c75e 100644 --- a/src/libraries/Native/Unix/System.Native/pal_string.h +++ b/src/libraries/Native/Unix/System.Native/pal_string.h @@ -16,12 +16,3 @@ * On failure, returns a negative value. */ DLLEXPORT int32_t SystemNative_SNPrintF(char* string, int32_t size, const char* format, ...); - -/** - * printf is difficult to represent in C# due to the argument list, so the C# PInvoke - * layer will have multiple overloads pointing to this function. - * - * Returns the number of characters written to the output stream on success; otherwise, returns - * a negative number and errno and ferror are both set. - */ -DLLEXPORT int32_t SystemNative_PrintF(const char* format, ...); diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 9c35bf0..00202df 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -485,9 +485,6 @@ Common\Interop\Unix\libc\Interop.Poll.cs - - Common\Interop\Unix\libc\Interop.PrintF.cs - Common\Interop\Unix\libc\Interop.Read.cs @@ -693,6 +690,7 @@ + diff --git a/src/libraries/System.Net.Security/src/System.Net.Security.csproj b/src/libraries/System.Net.Security/src/System.Net.Security.csproj index 8228956..e41f160 100644 --- a/src/libraries/System.Net.Security/src/System.Net.Security.csproj +++ b/src/libraries/System.Net.Security/src/System.Net.Security.csproj @@ -266,9 +266,6 @@ Common\CoreLib\Interop\Unix\Interop.Errors.cs - - Common\Interop\Unix\System.Native\Interop.PrintF.cs - Common\Interop\Unix\System.Net.Security.Native\Interop.Initialization.cs @@ -469,6 +466,7 @@ + diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj b/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj index b73b107..56efaeb 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj @@ -300,9 +300,6 @@ - - Common\Interop\Unix\System.Native\Interop.PrintF.cs - System\Security\Cryptography\X509Certificates\Asn1\DistributionPointAsn.xml @@ -712,6 +709,9 @@ + + + -- 2.7.4