From c16900c369fd6cddc896022ff1fd521c5a0dbabc Mon Sep 17 00:00:00 2001 From: madmir Date: Wed, 4 Sep 2019 23:55:09 +0200 Subject: [PATCH] Address PR feedback --- ...Interop.ReadFile_Bool_SafeHandle_IntPtr.cs | 21 ------------------- .../src/System.Reflection.Metadata.csproj | 4 ++-- .../Utilities/FileStreamReadLightUp.cs | 4 ++-- 3 files changed, 4 insertions(+), 25 deletions(-) delete mode 100644 src/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_Bool_SafeHandle_IntPtr.cs diff --git a/src/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_Bool_SafeHandle_IntPtr.cs b/src/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_Bool_SafeHandle_IntPtr.cs deleted file mode 100644 index 840734927923..000000000000 --- a/src/Common/src/Interop/Windows/Kernel32/Interop.ReadFile_Bool_SafeHandle_IntPtr.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal partial class Interop -{ - internal partial class Kernel32 - { - [DllImport(Libraries.Kernel32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern unsafe bool ReadFile( - SafeHandle handle, - byte* bytes, - int numBytesToRead, - out int numBytesRead, - IntPtr mustBeZero); - } -} diff --git a/src/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj b/src/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj index 1574ca0c00ba..51e0e6171338 100644 --- a/src/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj +++ b/src/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj @@ -15,8 +15,8 @@ Common\Interop\Windows\Interop.Libraries.cs - - Common\Interop\Windows\kernel32\Interop.ReadFile_Bool_SafeHandle_IntPtr.cs + + Common\CoreLib\Interop\Windows\kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs diff --git a/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs b/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs index 74fcd11baecd..2959175d3cb1 100644 --- a/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs +++ b/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs @@ -53,7 +53,7 @@ internal static unsafe bool TryReadFile(Stream stream, byte* buffer, long start, return false; } - bool result = false; + int result = 0; int bytesRead = 0; try @@ -66,7 +66,7 @@ internal static unsafe bool TryReadFile(Stream stream, byte* buffer, long start, return false; } - if (!result || bytesRead != size) + if (result == 0 || bytesRead != size) { // We used to throw here, but this is where we land if the FileStream was // opened with useAsync: true, which is currently the default on .NET Core.