moved to shared (#19419)
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Sat, 11 Aug 2018 07:31:01 +0000 (00:31 -0700)
committerGitHub <noreply@github.com>
Sat, 11 Aug 2018 07:31:01 +0000 (00:31 -0700)
src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegCloseKey.cs [new file with mode: 0644]
src/System.Private.CoreLib/shared/Interop/Windows/Interop.Libraries.cs
src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs [moved from src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs with 59% similarity]
src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs

index 73819e1..70c5749 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Collections\ObjectModel\ReadOnlyDictionary.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Condition="'$(FeatureWin32Registry)' == 'true'" Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs" />
-  </ItemGroup>
-  <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Numerics\Hashing\HashHelpers.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetsUnix)' == 'true'">
diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegCloseKey.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegCloseKey.cs
new file mode 100644 (file)
index 0000000..375376d
--- /dev/null
@@ -0,0 +1,15 @@
+// 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 Advapi32
+    {
+        [DllImport(Libraries.Advapi32)]
+        internal static extern int RegCloseKey(IntPtr hKey);
+    }
+}
index 45d910b..7b77d2d 100644 (file)
@@ -6,6 +6,7 @@ internal static partial class Interop
 {
     internal static partial class Libraries
     {
+        internal const string Advapi32 = "advapi32.dll";
         internal const string BCrypt = "BCrypt.dll";
         internal const string Crypt32 = "crypt32.dll";
         internal const string Kernel32 = "kernel32.dll";
@@ -2,13 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-//
-//
-// Implements Microsoft.Win32.SafeHandles.SafeRegistryHandle
-//
-// ======================================================================================
-
 using System;
 using System.Security;
 using System.Runtime.InteropServices;
@@ -18,7 +11,12 @@ using System.Runtime.Versioning;
 
 namespace Microsoft.Win32.SafeHandles
 {
-    internal sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid
+#if REGISTRY_ASSEMBLY
+    public
+#else
+    internal
+#endif
+    sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid
     {
         internal SafeRegistryHandle() : base(true) { }
 
@@ -27,13 +25,9 @@ namespace Microsoft.Win32.SafeHandles
             SetHandle(preexistingHandle);
         }
 
-        override protected bool ReleaseHandle()
+        protected override bool ReleaseHandle()
         {
-            return (RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS);
+            return (Interop.Advapi32.RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS);
         }
-
-        [DllImport(Win32Native.ADVAPI32)]
-        internal static extern int RegCloseKey(IntPtr hKey);
     }
 }
-
index 1133ce5..e002a35 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Win32.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\TimeZoneInfo.Win32.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.LoadLibraryEx.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FreeLibrary.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CreateFile.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.MUI.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCloseKey.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.TimeZone.Registry.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\User32\Interop.Constants.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\User32\Interop.SendMessageTimeout.cs" />
index 28f86f3..69ac1cd 100644 (file)
@@ -248,7 +248,7 @@ namespace Microsoft.Win32
                     // the dispose below and usage elsewhere (other threads). This is By Design. 
                     // This is less of an issue when OS > NT5 (i.e Vista & higher), we can close the perfkey  
                     // (to release & refresh PERFLIB resources) and the OS will rebuild PERFLIB as necessary. 
-                    SafeRegistryHandle.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
+                    Interop.Advapi32.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
                 }
             }
         }