Fix ProjectN build breaks (dotnet/corert#7343)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Wed, 24 Apr 2019 13:24:31 +0000 (15:24 +0200)
committerJan Kotas <jkotas@microsoft.com>
Wed, 24 Apr 2019 19:01:31 +0000 (12:01 -0700)
Porting changes from the non-WinRT files.

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.CreateFile2.cs
src/System.Private.CoreLib/shared/System/IO/FileStream.WinRT.cs

index fc98061..f6fde12 100644 (file)
@@ -4,6 +4,7 @@
 
 #nullable enable
 using Microsoft.Win32.SafeHandles;
+using System.Diagnostics;
 using System.IO;
 using System.Runtime.InteropServices;
 
@@ -26,8 +27,9 @@ internal partial class Interop
             FileMode dwCreationDisposition,
             ref Kernel32.CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams)
         {
-            lpFileName = PathInternal.EnsureExtendedPrefixOverMaxPath(lpFileName);
-            return CreateFile2Private(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref pCreateExParams);
+            string? lpFileNameWithPrefix = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName);
+            Debug.Assert(lpFileNameWithPrefix != null, "null not expected when non-null passed"); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
+            return CreateFile2Private(lpFileNameWithPrefix, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref pCreateExParams);
         }
     }
 }
index 752a6d9..9373165 100644 (file)
@@ -4,6 +4,7 @@
 
 #nullable enable
 using Microsoft.Win32.SafeHandles;
+using System.Diagnostics;
 using System.Runtime.InteropServices;
 
 namespace System.IO
@@ -33,6 +34,7 @@ namespace System.IO
 
             using (DisableMediaInsertionPrompt.Create())
             {
+                Debug.Assert(_path != null);
                 return ValidateFileHandle(Interop.Kernel32.CreateFile2(
                     lpFileName: _path,
                     dwDesiredAccess: access,