Skip to content

Commit

Permalink
Replace PrintF with Console.WriteLine and cleanups (dotnet/corefx#41540)
Browse files Browse the repository at this point in the history
* Replace PrintF with Console.WriteLine and cleanups

* PR feedback: simplify WriteLine arguments


Commit migrated from dotnet/corefx@c28a9e6
  • Loading branch information
am11 authored and stephentoub committed Oct 4, 2019
1 parent 6cfca20 commit d65600b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ internal sealed class SafeX509Handle : SafeHandle
{
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
Expand Down
11 changes: 0 additions & 11 deletions src/libraries/Native/Unix/System.Native/pal_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

int32_t SystemNative_SNPrintF(char* string, int32_t size, const char* format, ...)
{
Expand All @@ -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;
}
9 changes: 0 additions & 9 deletions src/libraries/Native/Unix/System.Native/pal_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...);
4 changes: 1 addition & 3 deletions src/libraries/System.Net.Http/src/System.Net.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,6 @@
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Poll.cs">
<Link>Common\Interop\Unix\libc\Interop.Poll.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.PrintF.cs">
<Link>Common\Interop\Unix\libc\Interop.PrintF.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\CoreLib\Interop\Unix\System.Native\Interop.Read.cs">
<Link>Common\Interop\Unix\libc\Interop.Read.cs</Link>
</Compile>
Expand Down Expand Up @@ -693,6 +690,7 @@
<Reference Include="System.IO.Compression.Brotli" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Reference Include="System.Console" Condition="'$(ConfigurationGroup)' == 'Debug'" />
<Reference Include="System.Diagnostics.StackTrace" />
<Reference Include="System.IO.FileSystem" />
<Reference Include="System.Security.Cryptography.Algorithms" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@
<Compile Include="$(CommonPath)\CoreLib\Interop\Unix\Interop.Errors.cs">
<Link>Common\CoreLib\Interop\Unix\Interop.Errors.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.PrintF.cs">
<Link>Common\Interop\Unix\System.Native\Interop.PrintF.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Net.Security.Native\Interop.Initialization.cs">
<Link>Common\Interop\Unix\System.Net.Security.Native\Interop.Initialization.cs</Link>
</Compile>
Expand Down Expand Up @@ -469,6 +466,7 @@
<Reference Include="System.Threading.ThreadPool" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Reference Include="System.Console" Condition="'$(ConfigurationGroup)' == 'Debug'" />
<Reference Include="System.Diagnostics.StackTrace" />
<Reference Include="System.Security.Cryptography.Algorithms" />
<Reference Include="System.Security.Cryptography.OpenSsl" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,6 @@
<Compile Include="Microsoft\Win32\SafeHandles\SafePasswordHandle.Unix.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' AND '$(TargetsOSX)' != 'true' ">
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.PrintF.cs">
<Link>Common\Interop\Unix\System.Native\Interop.PrintF.cs</Link>
</Compile>
<AsnXml Include="System\Security\Cryptography\X509Certificates\Asn1\DistributionPointAsn.xml" />
<Compile Include="System\Security\Cryptography\X509Certificates\Asn1\DistributionPointAsn.xml.cs">
<DependentUpon>System\Security\Cryptography\X509Certificates\Asn1\DistributionPointAsn.xml</DependentUpon>
Expand Down Expand Up @@ -712,6 +709,9 @@
<Reference Include="System.Diagnostics.StackTrace" />
<Reference Include="System.Security.Cryptography.OpenSsl" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Reference Include="System.Console" Condition="'$(ConfigurationGroup)' == 'Debug'" />
</ItemGroup>
<ItemGroup>
<None Include="@(AsnXml)" />
</ItemGroup>
Expand Down

0 comments on commit d65600b

Please sign in to comment.