Beautify code
authorManuel Pfemeter <manne@users.noreply.github.com>
Wed, 29 Jan 2020 21:21:46 +0000 (22:21 +0100)
committerManuel Pfemeter <m>
Tue, 11 Feb 2020 19:28:21 +0000 (20:28 +0100)
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/Registry.cs
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.Windows.cs
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKeyPermissionCheck.cs
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryOptions.cs
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryView.cs
src/libraries/Microsoft.Win32.Registry/src/System/Security/AccessControl/RegistryRights.cs

index 5e0a74c..b5cad61 100644 (file)
@@ -70,8 +70,7 @@ namespace Microsoft.Win32
 
         public static object? GetValue(string keyName, string valueName, object defaultValue)
         {
-            string subKeyName;
-            RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName);
+            RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out string subKeyName);
 
             using (RegistryKey? key = basekey.OpenSubKey(subKeyName))
             {
@@ -86,8 +85,7 @@ namespace Microsoft.Win32
 
         public static void SetValue(string keyName, string valueName, object value, RegistryValueKind valueKind)
         {
-            string subKeyName;
-            RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName);
+            RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out string subKeyName);
 
             using (RegistryKey key = basekey.CreateSubKey(subKeyName))
             {
index dda39d1..6c80edd 100644 (file)
@@ -9,7 +9,6 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Security;
-using System.Security.AccessControl;
 
 /*
   Note on transaction support:
@@ -85,8 +84,7 @@ namespace Microsoft.Win32
 
         private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
         {
-            Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
-            int disposition = 0;
+            Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default;
 
             // By default, the new key will be writable.
             int ret = Interop.Advapi32.RegCreateKeyEx(_hkey,
@@ -97,7 +95,7 @@ namespace Microsoft.Win32
                 GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)_regView,
                 ref secAttrs,
                 out SafeRegistryHandle result,
-                out disposition);
+                out int _);
 
             if (ret == 0 && !result.IsInvalid)
             {
@@ -335,12 +333,11 @@ namespace Microsoft.Win32
                 }
 
                 // open the base key so that RegistryKey.Handle will return a valid handle
-                SafeRegistryHandle result;
                 ret = Interop.Advapi32.RegOpenKeyEx(baseKey,
                     null,
                     0,
                     GetRegistryKeyAccess(IsWritable()) | (int)_regView,
-                    out result);
+                    out SafeRegistryHandle result);
 
                 if (ret == 0 && !result.IsInvalid)
                 {
index 92b8b01..f69b6ee 100644 (file)
@@ -2,8 +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.
 
-using System;
-
 namespace Microsoft.Win32
 {
     public enum RegistryKeyPermissionCheck
@@ -11,5 +9,5 @@ namespace Microsoft.Win32
         Default = 0,
         ReadSubTree = 1,
         ReadWriteSubTree = 2,
-    };
+    }
 }
index 112efd2..e288412 100644 (file)
@@ -11,5 +11,5 @@ namespace Microsoft.Win32
     {
         None = Interop.Advapi32.RegistryOptions.REG_OPTION_NON_VOLATILE,       // 0x0000
         Volatile = Interop.Advapi32.RegistryOptions.REG_OPTION_VOLATILE,      // 0x0001
-    };
+    }
 }
index 0bfe1a5..22b153c 100644 (file)
@@ -2,8 +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.
 
-using System;
-
 namespace Microsoft.Win32
 {
     public enum RegistryView
@@ -11,5 +9,5 @@ namespace Microsoft.Win32
         Default = 0, // 0x0000 operate on the default registry view
         Registry64 = Interop.Advapi32.RegistryView.KEY_WOW64_64KEY, // 0x0100 operate on the 64-bit registry view
         Registry32 = Interop.Advapi32.RegistryView.KEY_WOW64_32KEY, // 0x0200 operate on the 32-bit registry view
-    };
+    }
 }
index 61e5371..4e5de44 100644 (file)
@@ -2,8 +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.
 
-using Microsoft.Win32;
-
 namespace System.Security.AccessControl
 {
     // We derived this enum from the definitions of KEY_READ and such from