Delete Uap quirks from CoreLib (dotnet/coreclr#27356)
authorJan Kotas <jkotas@microsoft.com>
Tue, 22 Oct 2019 06:59:58 +0000 (23:59 -0700)
committerGitHub <noreply@github.com>
Tue, 22 Oct 2019 06:59:58 +0000 (23:59 -0700)
This matches cleanup done in CoreFX.

Commit migrated from https://github.com/dotnet/coreclr/commit/111b71a65bce77e63d2463a972fe78aa042c5c0a

13 files changed:
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CREATEFILE2_EXTENDED_PARAMETERS.cs [deleted file]
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CreateFile2.cs [deleted file]
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetProcessInformation.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/DateTime.WinRT.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Environment.WinRT.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/HijriCalendar.WinRT.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.WinRT.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/IO/FileStream.WinRT.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs

index d2b47a0..d88f025 100644 (file)
@@ -318,16 +318,6 @@ namespace System.Reflection
 
         internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
         {
-#if FEATURE_APPX
-            if (ApplicationModel.IsUap)
-            {
-                if (assemblyRef.CodeBase != null)
-                {
-                    throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFrom"));
-                }
-            }
-#endif
-
             assemblyRef = (AssemblyName)assemblyRef.Clone();
             if (assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None)
             {
diff --git a/src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CREATEFILE2_EXTENDED_PARAMETERS.cs b/src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CREATEFILE2_EXTENDED_PARAMETERS.cs
deleted file mode 100644 (file)
index eee8b84..0000000
+++ /dev/null
@@ -1,24 +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 Microsoft.Win32.SafeHandles;
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
-    internal static partial class Kernel32
-    {
-        internal unsafe struct CREATEFILE2_EXTENDED_PARAMETERS
-        {
-            internal uint dwSize;
-            internal uint dwFileAttributes;
-            internal uint dwFileFlags;
-            internal uint dwSecurityQosFlags;
-            internal SECURITY_ATTRIBUTES* lpSecurityAttributes;
-            internal IntPtr hTemplateFile;
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CreateFile2.cs b/src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CreateFile2.cs
deleted file mode 100644 (file)
index 000b978..0000000
+++ /dev/null
@@ -1,33 +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 Microsoft.Win32.SafeHandles;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
-    internal static partial class Kernel32
-    {
-        [DllImport(Libraries.Kernel32, EntryPoint = "CreateFile2", SetLastError = true, CharSet = CharSet.Unicode)]
-        private static extern SafeFileHandle CreateFile2Private(
-            string lpFileName,
-            int dwDesiredAccess,
-            FileShare dwShareMode,
-            FileMode dwCreationDisposition,
-            ref Kernel32.CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams);
-
-        internal static SafeFileHandle CreateFile2(
-            string lpFileName,
-            int dwDesiredAccess,
-            FileShare dwShareMode,
-            FileMode dwCreationDisposition,
-            ref Kernel32.CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams)
-        {
-            lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName);
-            return CreateFile2Private(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref pCreateExParams);
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetProcessInformation.cs b/src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetProcessInformation.cs
deleted file mode 100644 (file)
index 9860266..0000000
+++ /dev/null
@@ -1,23 +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 static partial class Interop
-{
-    internal static partial class Kernel32
-    {
-        internal const int ProcessLeapSecondInfo = 8;
-
-        internal struct PROCESS_LEAP_SECOND_INFO
-        {
-            public uint Flags;
-            public uint Reserved;
-        }
-
-        [DllImport(Libraries.Kernel32)]
-        internal static extern unsafe Interop.BOOL GetProcessInformation(IntPtr hProcess, int ProcessInformationClass, void* ProcessInformation, int ProcessInformationSize);
-    }
-}
index 34846bb..709ad5f 100644 (file)
   <ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\WindowsRuntime\EventRegistrationToken.cs" />
   </ItemGroup>
-  <ItemGroup Condition="$(TargetsWindows) and '$(EnableWinRT)' != 'true'">
+  <ItemGroup Condition="$(TargetsWindows)">
     <Compile Include="$(MSBuildThisFileDirectory)Internal\Win32\RegistryKey.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCloseKey.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCreateKeyEx.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Win32.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\TimeZoneInfo.Win32.cs" />
   </ItemGroup>
-  <ItemGroup Condition="$(TargetsWindows) and '$(EnableWinRT)' == 'true'">
-    <Compile Include="$(MSBuildThisFileDirectory)System\DateTime.WinRT.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Environment.WinRT.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.WinRT.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\JapaneseCalendar.WinRT.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.WinRT.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CreateFile2.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CREATEFILE2_EXTENDED_PARAMETERS.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetProcessInformation.cs" />
-  </ItemGroup>
   <ItemGroup Condition="$(TargetsWindows) or '$(FeaturePal)'=='true'">
     <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeWaitHandle.Windows.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Interop.Errors.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Semaphore.Windows.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventWaitHandle.Windows.cs" />
   </ItemGroup>
-  <ItemGroup Condition="'$(FeatureAppX)' == 'true' or '$(EnableWinRT)' == 'true'">
+  <ItemGroup Condition="'$(FeatureAppX)' == 'true'">
     <Compile Include="$(MSBuildThisFileDirectory)Internal\Resources\PRIExceptionInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Internal\Resources\WindowsRuntimeResourceManagerBase.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceManager.Uap.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Buffer.Unix.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\DateTime.Unix.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebugProvider.Unix.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Environment.NoRegistry.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Environment.Unix.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.Unix.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.Unix.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\TimerQueue.Unix.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\TimeZoneInfo.Unix.cs" />
   </ItemGroup>
-  <ItemGroup Condition="$(TargetsUnix) or '$(EnableWinRT)'=='true'">
-    <Compile Include="$(MSBuildThisFileDirectory)System\Environment.NoRegistry.cs" />
-  </ItemGroup>
   <ItemGroup Condition="'$(FeatureHardwareIntrinsics)' == 'true' AND ('$(Platform)' == 'x64' OR ('$(Platform)' == 'x86' AND '$(TargetsUnix)' != 'true'))">
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\X86\Aes.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\X86\Avx.cs" />
diff --git a/src/libraries/System.Private.CoreLib/src/System/DateTime.WinRT.cs b/src/libraries/System.Private.CoreLib/src/System/DateTime.WinRT.cs
deleted file mode 100644 (file)
index 30a9a61..0000000
+++ /dev/null
@@ -1,27 +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.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace System
-{
-    public readonly partial struct DateTime
-    {
-        private static unsafe bool SystemSupportsLeapSeconds()
-        {
-            Interop.Kernel32.PROCESS_LEAP_SECOND_INFO info;
-
-            // Store apps don't have access to an API that would let us find out whether leap seconds have been
-            // disabled by policy: this implementation will produce slightly different results from what
-            // we have for Win32. If GetProcessInformation succeeds, we have to act as if leap seconds existed.
-            // They could still have been disabled by policy, but we have no way to check for that.
-            return Interop.Kernel32.GetProcessInformation(
-                Interop.Kernel32.GetCurrentProcess(),
-                Interop.Kernel32.ProcessLeapSecondInfo,
-                &info,
-                sizeof(Interop.Kernel32.PROCESS_LEAP_SECOND_INFO)) != Interop.BOOL.FALSE;
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.WinRT.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.WinRT.cs
deleted file mode 100644 (file)
index 9a4bb86..0000000
+++ /dev/null
@@ -1,26 +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.IO;
-using Internal.Runtime.Augments;
-
-namespace System
-{
-    public static partial class Environment
-    {
-        public static string UserName => "Windows User";
-
-        public static string UserDomainName => "Windows Domain";
-
-        internal static readonly bool IsWindows8OrAbove = true;
-
-        private static string GetFolderPathCore(SpecialFolder folder, SpecialFolderOption option)
-        {
-            WinRTInteropCallbacks callbacks = WinRTInterop.UnsafeCallbacks;
-            return callbacks != null && callbacks.IsAppxModel() ?
-                callbacks.GetFolderPath(folder, option) :
-                string.Empty;
-        }
-    }
-}
index e401cf1..1a8e8e8 100644 (file)
@@ -2,23 +2,10 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-#if FEATURE_APPX
-using System.Resources;
-using Internal.Resources;
-#endif
-
 namespace System.Globalization
 {
     public partial class CultureInfo : IFormatProvider
     {
-#if FEATURE_APPX
-        // When running under AppX, we use this to get some information about the language list
-        private static volatile WindowsRuntimeResourceManagerBase? s_WindowsRuntimeResourceManager;
-
-        [ThreadStatic]
-        private static bool ts_IsDoingAppXCultureInfoLookup;
-#endif
-
         internal static CultureInfo GetUserDefaultCulture()
         {
             if (GlobalizationMode.Invariant)
@@ -68,50 +55,5 @@ namespace System.Globalization
 
             return InitializeUserDefaultCulture();
         }
-
-#if FEATURE_APPX
-        internal static CultureInfo? GetCultureInfoForUserPreferredLanguageInAppX()
-        {
-            // If a call to GetCultureInfoForUserPreferredLanguageInAppX() generated a recursive
-            // call to itself, return null, since we don't want to stack overflow.  For example,
-            // this can happen if some code in this method ends up calling CultureInfo.CurrentCulture.
-            // In this case, returning null will mean CultureInfo.CurrentCulture gets the default Win32
-            // value, which should be fine.
-            if (ts_IsDoingAppXCultureInfoLookup)
-            {
-                return null;
-            }
-
-            CultureInfo? toReturn;
-
-            try
-            {
-                ts_IsDoingAppXCultureInfoLookup = true;
-
-                if (s_WindowsRuntimeResourceManager == null)
-                {
-                    s_WindowsRuntimeResourceManager = ResourceManager.GetWinRTResourceManager();
-                }
-
-                toReturn = s_WindowsRuntimeResourceManager.GlobalResourceContextBestFitCultureInfo;
-            }
-            finally
-            {
-                ts_IsDoingAppXCultureInfoLookup = false;
-            }
-
-            return toReturn;
-        }
-
-        internal static bool SetCultureInfoForUserPreferredLanguageInAppX(CultureInfo ci)
-        {
-            if (s_WindowsRuntimeResourceManager == null)
-            {
-                s_WindowsRuntimeResourceManager = ResourceManager.GetWinRTResourceManager();
-            }
-
-            return s_WindowsRuntimeResourceManager.SetGlobalResourceContextDefaultCulture(ci);
-        }
-#endif
     }
 }
index 0a2e2e7..bc276e2 100644 (file)
@@ -389,15 +389,6 @@ namespace System.Globalization
         {
             get
             {
-#if FEATURE_APPX
-                if (ApplicationModel.IsUap)
-                {
-                    CultureInfo? culture = GetCultureInfoForUserPreferredLanguageInAppX();
-                    if (culture != null)
-                        return culture;
-                }
-#endif
-
                 return s_currentThreadCulture ??
                     s_DefaultThreadCurrentCulture ??
                     s_userDefaultCulture ??
@@ -410,17 +401,6 @@ namespace System.Globalization
                     throw new ArgumentNullException(nameof(value));
                 }
 
-#if FEATURE_APPX
-                if (ApplicationModel.IsUap)
-                {
-                    if (SetCultureInfoForUserPreferredLanguageInAppX(value))
-                    {
-                        // successfully set the culture, otherwise fallback to legacy path
-                        return;
-                    }
-                }
-#endif
-
                 if (s_asyncLocalCurrentCulture == null)
                 {
                     Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null);
@@ -433,15 +413,6 @@ namespace System.Globalization
         {
             get
             {
-#if FEATURE_APPX
-                if (ApplicationModel.IsUap)
-                {
-                    CultureInfo? culture = GetCultureInfoForUserPreferredLanguageInAppX();
-                    if (culture != null)
-                        return culture;
-                }
-#endif
-
                 return s_currentThreadUICulture ??
                     s_DefaultThreadCurrentUICulture ??
                     UserDefaultUICulture;
@@ -455,17 +426,6 @@ namespace System.Globalization
 
                 CultureInfo.VerifyCultureName(value, true);
 
-#if FEATURE_APPX
-                if (ApplicationModel.IsUap)
-                {
-                    if (SetCultureInfoForUserPreferredLanguageInAppX(value))
-                    {
-                        // successfully set the culture, otherwise fallback to legacy path
-                        return;
-                    }
-                }
-#endif
-
                 if (s_asyncLocalCurrentUICulture == null)
                 {
                     Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null);
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/HijriCalendar.WinRT.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/HijriCalendar.WinRT.cs
deleted file mode 100644 (file)
index fb91c27..0000000
+++ /dev/null
@@ -1,16 +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 Internal.Runtime.Augments;
-
-namespace System.Globalization
-{
-    public partial class HijriCalendar : Calendar
-    {
-        private static int GetHijriDateAdjustment()
-        {
-            return WinRTInterop.Callbacks.GetHijriDateAdjustment();
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.WinRT.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.WinRT.cs
deleted file mode 100644 (file)
index 15fe898..0000000
+++ /dev/null
@@ -1,62 +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.Diagnostics;
-
-using Internal.Runtime.Augments;
-
-namespace System.Globalization
-{
-    public partial class JapaneseCalendar : Calendar
-    {
-        private static EraInfo[]? GetJapaneseEras()
-        {
-            int erasCount = WinRTInterop.Callbacks.GetJapaneseEraCount();
-            if (erasCount < 4)
-            {
-                return null;
-            }
-
-            EraInfo[] eras = new EraInfo[erasCount];
-            int lastMaxYear = GregorianCalendar.MaxYear;
-
-            for (int i = erasCount; i > 0; i--)
-            {
-                DateTimeOffset dateOffset;
-
-                string? eraName;
-                string? abbreviatedEraName;
-
-                if (!GetJapaneseEraInfo(i, out dateOffset, out eraName, out abbreviatedEraName))
-                {
-                    return null;
-                }
-
-                DateTime dt = new DateTime(dateOffset.Ticks);
-
-                eras[erasCount - i] = new EraInfo(i, dt.Year, dt.Month, dt.Day, dt.Year - 1, 1, lastMaxYear - dt.Year + 1,
-                                                   eraName!, abbreviatedEraName!, GetJapaneseEnglishEraName(i));    // era #4 start year/month/day, yearOffset, minEraYear
-
-                lastMaxYear = dt.Year;
-            }
-
-            return eras;
-        }
-
-        // PAL Layer ends here
-
-        private static readonly string[] s_JapaneseErasEnglishNames = new string[] { "M", "T", "S", "H", "R" };
-
-        private static string GetJapaneseEnglishEraName(int era)
-        {
-            Debug.Assert(era > 0);
-            return era <= s_JapaneseErasEnglishNames.Length ? s_JapaneseErasEnglishNames[era - 1] : " ";
-        }
-
-        private static bool GetJapaneseEraInfo(int era, out DateTimeOffset dateOffset, out string? eraName, out string? abbreviatedEraName)
-        {
-            return WinRTInterop.Callbacks.GetJapaneseEraInfo(era, out dateOffset, out eraName, out abbreviatedEraName);
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.WinRT.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.WinRT.cs
deleted file mode 100644 (file)
index f6838f7..0000000
+++ /dev/null
@@ -1,99 +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 Microsoft.Win32.SafeHandles;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace System.IO
-{
-    public partial class FileStream : Stream
-    {
-        private unsafe SafeFileHandle OpenHandle(FileMode mode, FileShare share, FileOptions options)
-        {
-            Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share);
-
-            int access =
-                ((_access & FileAccess.Read) == FileAccess.Read ? GENERIC_READ : 0) |
-                ((_access & FileAccess.Write) == FileAccess.Write ? GENERIC_WRITE : 0);
-
-            // Our Inheritable bit was stolen from Windows, but should be set in
-            // the security attributes class.  Don't leave this bit set.
-            share &= ~FileShare.Inheritable;
-
-            // Must use a valid Win32 constant here...
-            if (mode == FileMode.Append)
-                mode = FileMode.OpenOrCreate;
-
-            Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS parameters = new Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS();
-            parameters.dwSize = (uint)sizeof(Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS);
-            parameters.dwFileFlags = (uint)options;
-            parameters.lpSecurityAttributes = &secAttrs;
-
-            using (DisableMediaInsertionPrompt.Create())
-            {
-                Debug.Assert(_path != null);
-                return ValidateFileHandle(Interop.Kernel32.CreateFile2(
-                    lpFileName: _path,
-                    dwDesiredAccess: access,
-                    dwShareMode: share,
-                    dwCreationDisposition: mode,
-                    pCreateExParams: ref parameters));
-            }
-        }
-
-        private static bool GetDefaultIsAsync(SafeFileHandle handle) => handle.IsAsync ?? DefaultIsAsync;
-
-        private static unsafe bool? IsHandleSynchronous(SafeFileHandle handle, FileAccess access)
-        {
-            // Do NOT use this method on any type other than DISK. Reading or writing to a pipe may
-            // cause an app to block incorrectly, introducing a deadlock (depending on whether a write
-            // will wake up an already-blocked thread or this Win32FileStream's thread).
-
-            byte* bytes = stackalloc byte[1];
-            int numBytesReadWritten;
-            int r = -1;
-
-            // If the handle is a pipe, ReadFile will block until there
-            // has been a write on the other end.  We'll just have to deal with it,
-            // For the read end of a pipe, you can mess up and
-            // accidentally read synchronously from an async pipe.
-            if ((access & FileAccess.Read) != 0)
-            {
-                r = Interop.Kernel32.ReadFile(handle, bytes, 0, out numBytesReadWritten, IntPtr.Zero);
-            }
-            else if ((access & FileAccess.Write) != 0)
-            {
-                r = Interop.Kernel32.WriteFile(handle, bytes, 0, out numBytesReadWritten, IntPtr.Zero);
-            }
-
-            if (r == 0)
-            {
-                int errorCode = Marshal.GetLastWin32Error();
-                switch (errorCode)
-                {
-                    case Interop.Errors.ERROR_INVALID_PARAMETER:
-                        return false;
-                    case Interop.Errors.ERROR_INVALID_HANDLE:
-                        throw Win32Marshal.GetExceptionForWin32Error(errorCode);
-                }
-            }
-
-            return true;
-        }
-
-        private static void VerifyHandleIsSync(SafeFileHandle handle, int fileType, FileAccess access)
-        {
-            // The technique here only really works for FILE_TYPE_DISK. FileMode is the right thing to check, but it currently
-            // isn't available in WinRT.
-
-            if (fileType == Interop.Kernel32.FileTypes.FILE_TYPE_DISK)
-            {
-                // If we can't check the handle, just assume it is ok.
-                if (!(IsHandleSynchronous(handle, access) ?? true))
-                    throw new ArgumentException(SR.Arg_HandleNotSync, nameof(handle));
-            }
-        }
-    }
-}
index 9cd971e..a841c82 100644 (file)
@@ -203,11 +203,6 @@ namespace System.Reflection
             if (rawAssembly.Length == 0)
                 throw new BadImageFormatException(SR.BadImageFormat_BadILFormat);
 
-#if FEATURE_APPX
-            if (ApplicationModel.IsUap)
-                throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.Load(byte[], ...)"));
-#endif
-
             SerializationInfo.ThrowIfDeserializationInProgress("AllowAssembliesFromByteArrays",
                 ref s_cachedSerializationSwitch);
 
@@ -220,11 +215,6 @@ namespace System.Reflection
             if (path == null)
                 throw new ArgumentNullException(nameof(path));
 
-#if FEATURE_APPX
-            if (ApplicationModel.IsUap)
-                throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFile"));
-#endif
-
             if (PathInternal.IsPartiallyQualified(path))
             {
                 throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path));