<Configurations>netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release;netstandard1.1-Debug;netstandard1.1-Release</Configurations>
</PropertyGroup>
<ItemGroup>
+ <Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
+ <Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
+ </Compile>
+ <Compile Include="$(CommonPath)\CoreLib\Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs">
+ <Link>Common\CoreLib\Interop\Windows\kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs</Link>
+ </Compile>
<Compile Include="System\Reflection\Internal\Utilities\PinnedObject.cs" />
<Compile Include="System\Reflection\Internal\Utilities\CriticalDisposableObject.cs" Condition="'$(TargetFramework)' != 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\CriticalDisposableObject.netstandard1.1.cs" Condition="'$(TargetFramework)' == 'netstandard1.1'" />
return false;
}
- bool result = false;
- int bytesRead = 0;
+ int result;
+ int bytesRead;
try
{
- result = ReadFile(handle, buffer, size, out bytesRead, IntPtr.Zero);
+ result = Interop.Kernel32.ReadFile(handle, buffer, size, out bytesRead, IntPtr.Zero);
}
catch
{
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.
return true;
}
-
- [DllImport(@"kernel32.dll", EntryPoint = "ReadFile", ExactSpelling = true, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern unsafe bool ReadFile(
- SafeHandle fileHandle,
- byte* buffer,
- int byteCount,
- out int bytesRead,
- IntPtr overlapped
- );
}
}
return false;
}
- bool result = false;
- int bytesRead = 0;
+ int result;
+ int bytesRead;
try
{
- result = ReadFile(handle, buffer, size, out bytesRead, IntPtr.Zero);
+ result = Interop.Kernel32.ReadFile(handle, buffer, size, out bytesRead, IntPtr.Zero);
}
catch
{
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.
return true;
}
-
- [DllImport(@"kernel32.dll", EntryPoint = "ReadFile", ExactSpelling = true, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern unsafe bool ReadFile(
- SafeHandle fileHandle,
- byte* buffer,
- int byteCount,
- out int bytesRead,
- IntPtr overlapped
- );
}
}
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ExternallyShipping>false</ExternallyShipping>
+ <NoWarn>436</NoWarn> <!-- Type conflicts on "Interop" due to InternalsVisibleTo access -->
<Configurations>netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release</Configurations>
</PropertyGroup>
<ItemGroup>