System.Data.SQLite
Check-in [7529b275e1]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Maintainability improvements to registry handling in the design-time components installer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vs2017
Files: files | file ages | folders
SHA1: 7529b275e175fe5c3d20824c22f1eceae2c3961c
User & Date: mistachkin 2017-08-07 20:50:37
References
2017-11-01
12:59
In the design-time components installer, fix registry key name in GetAssemblyFoldersKeyName broken by check-in [7529b275e1]. check-in: 5010e3dca4 user: mistachkin tags: trunk
Context
2017-09-28
18:14
Merge updates from trunk. check-in: 37be32bdd4 user: mistachkin tags: vs2017
2017-08-07
20:50
Maintainability improvements to registry handling in the design-time components installer. check-in: 7529b275e1 user: mistachkin tags: vs2017
19:42
Merge updates from trunk. check-in: 3460b9641f user: mistachkin tags: vs2017
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tools/install/Installer.cs.

    19     19   
    20     20   using System.Security;
    21     21   
    22     22   #if NET_20 || NET_35
    23     23   using System.Security.Permissions;
    24     24   #endif
    25     25   
           26  +using System.Text;
    26     27   using System.Threading;
    27     28   using System.Windows.Forms;
    28     29   using System.Xml;
    29     30   using Microsoft.Win32;
    30     31   
    31     32   namespace System.Data.SQLite
    32     33   {
................................................................................
   767    768               public MockRegistryKey ClassesRoot
   768    769               {
   769    770                   get
   770    771                   {
   771    772                       CheckDisposed();
   772    773   
   773    774                       if (classesRoot == null)
          775  +                    {
   774    776                           classesRoot = new MockRegistryKey(
   775    777                               Registry.ClassesRoot, whatIf, readOnly, safe);
          778  +                    }
   776    779   
   777    780                       return classesRoot;
   778    781                   }
   779    782               }
   780    783   
   781    784               ///////////////////////////////////////////////////////////////////
   782    785   
................................................................................
   784    787               public MockRegistryKey CurrentConfig
   785    788               {
   786    789                   get
   787    790                   {
   788    791                       CheckDisposed();
   789    792   
   790    793                       if (currentConfig == null)
          794  +                    {
   791    795                           currentConfig = new MockRegistryKey(
   792    796                               Registry.CurrentConfig, whatIf, readOnly, safe);
          797  +                    }
   793    798   
   794    799                       return currentConfig;
   795    800                   }
   796    801               }
   797    802   
   798    803               ///////////////////////////////////////////////////////////////////
   799    804   
................................................................................
   801    806               public MockRegistryKey CurrentUser
   802    807               {
   803    808                   get
   804    809                   {
   805    810                       CheckDisposed();
   806    811   
   807    812                       if (currentUser == null)
          813  +                    {
   808    814                           currentUser = new MockRegistryKey(
   809    815                               Registry.CurrentUser, whatIf, readOnly, safe);
          816  +                    }
   810    817   
   811    818                       return currentUser;
   812    819                   }
   813    820               }
   814    821   
   815    822               ///////////////////////////////////////////////////////////////////
   816    823   
................................................................................
   818    825               public MockRegistryKey DynData
   819    826               {
   820    827                   get
   821    828                   {
   822    829                       CheckDisposed();
   823    830   
   824    831                       if (dynData == null)
          832  +                    {
   825    833                           dynData = new MockRegistryKey(
   826    834                               Registry.DynData, whatIf, readOnly, safe);
          835  +                    }
   827    836   
   828    837                       return dynData;
   829    838                   }
   830    839               }
   831    840   
   832    841               ///////////////////////////////////////////////////////////////////
   833    842   
................................................................................
   835    844               public MockRegistryKey LocalMachine
   836    845               {
   837    846                   get
   838    847                   {
   839    848                       CheckDisposed();
   840    849   
   841    850                       if (localMachine == null)
          851  +                    {
   842    852                           localMachine = new MockRegistryKey(
   843    853                               Registry.LocalMachine, whatIf, readOnly, safe);
          854  +                    }
   844    855   
   845    856                       return localMachine;
   846    857                   }
   847    858               }
   848    859   
   849    860               ///////////////////////////////////////////////////////////////////
   850    861   
................................................................................
   852    863               public MockRegistryKey PerformanceData
   853    864               {
   854    865                   get
   855    866                   {
   856    867                       CheckDisposed();
   857    868   
   858    869                       if (performanceData == null)
          870  +                    {
   859    871                           performanceData = new MockRegistryKey(
   860    872                               Registry.PerformanceData, whatIf, readOnly, safe);
          873  +                    }
   861    874   
   862    875                       return performanceData;
   863    876                   }
   864    877               }
   865    878   
   866    879               ///////////////////////////////////////////////////////////////////
   867    880   
................................................................................
   869    882               public MockRegistryKey Users
   870    883               {
   871    884                   get
   872    885                   {
   873    886                       CheckDisposed();
   874    887   
   875    888                       if (users == null)
          889  +                    {
   876    890                           users = new MockRegistryKey(
   877    891                               Registry.Users, whatIf, readOnly, safe);
          892  +                    }
   878    893   
   879    894                       return users;
   880    895                   }
   881    896               }
   882    897               #endregion
   883    898   
   884    899               ///////////////////////////////////////////////////////////////////
................................................................................
  1189   1204                       // HACK: Attempt to open the specified sub-key.  If this
  1190   1205                       //       fails, we will simply return the wrapped root key
  1191   1206                       //       itself since no writes are allowed in "what-if"
  1192   1207                       //       mode anyhow.
  1193   1208                       //
  1194   1209                       RegistryKey subKey = key.OpenSubKey(subKeyName);
  1195   1210   
  1196         -                    return (subKey != null) ?
  1197         -                        new MockRegistryKey(
  1198         -                                subKey, whatIf, readOnly, safe) :
  1199         -                        new MockRegistryKey(
  1200         -                                key, subKeyName, whatIf, readOnly, safe);
         1211  +                    if (subKey != null)
         1212  +                    {
         1213  +                        return new MockRegistryKey(
         1214  +                            subKey, whatIf, readOnly, safe);
         1215  +                    }
         1216  +                    else
         1217  +                    {
         1218  +                        return new MockRegistryKey(
         1219  +                            key, subKeyName, whatIf, readOnly, safe);
         1220  +                    }
  1201   1221                   }
  1202   1222                   else
  1203   1223                   {
  1204   1224                       return new MockRegistryKey(
  1205   1225                           key.CreateSubKey(subKeyName), whatIf, readOnly, safe);
  1206   1226                   }
  1207   1227               }
................................................................................
  1281   1301                       return null;
  1282   1302   
  1283   1303                   return key.GetValue(name, defaultValue);
  1284   1304               }
  1285   1305   
  1286   1306               ///////////////////////////////////////////////////////////////////
  1287   1307   
         1308  +            public string[] GetValueNames()
         1309  +            {
         1310  +                CheckDisposed();
         1311  +
         1312  +                if (key == null)
         1313  +                    return null;
         1314  +
         1315  +                return key.GetValueNames();
         1316  +            }
         1317  +
         1318  +            ///////////////////////////////////////////////////////////////////
         1319  +
  1288   1320               public MockRegistryKey OpenSubKey(
  1289   1321                   string subKeyName
  1290   1322                   )
  1291   1323               {
  1292   1324                   CheckDisposed();
  1293   1325   
  1294   1326                   return OpenSubKey(subKeyName, false);
................................................................................
  1308   1340   
  1309   1341                   if (key == null)
  1310   1342                       return null;
  1311   1343   
  1312   1344                   RegistryKey subKey = key.OpenSubKey(
  1313   1345                       subKeyName, whatIf ? false : writable);
  1314   1346   
  1315         -                return (subKey != null) ?
  1316         -                    new MockRegistryKey(subKey, whatIf, readOnly, safe) : null;
         1347  +                if (subKey == null)
         1348  +                    return null;
         1349  +
         1350  +                return new MockRegistryKey(subKey, whatIf, readOnly, safe);
  1317   1351               }
  1318   1352   
  1319   1353               ///////////////////////////////////////////////////////////////////
  1320   1354   
  1321   1355               public void SetValue(
  1322   1356                   string name,
  1323   1357                   object value
................................................................................
  1343   1377                   {
  1344   1378                       CheckDisposed();
  1345   1379   
  1346   1380                       if (key == null)
  1347   1381                           return null;
  1348   1382   
  1349   1383                       return !String.IsNullOrEmpty(subKeyName) ?
  1350         -                        String.Format("{0}\\{1}", key.Name, subKeyName) :
         1384  +                        RegistryHelper.JoinKeyNames(key.Name, subKeyName) :
  1351   1385                           key.Name;
  1352   1386                   }
  1353   1387               }
  1354   1388   
  1355   1389               ///////////////////////////////////////////////////////////////////
  1356   1390   
  1357   1391               private RegistryKey key;
................................................................................
  1513   1547               }
  1514   1548               #endregion
  1515   1549           }
  1516   1550           #endregion
  1517   1551   
  1518   1552           ///////////////////////////////////////////////////////////////////////
  1519   1553   
         1554  +        #region RegistryRootKeyNames Class
         1555  +        private static class RegistryRootKeyNames
         1556  +        {
         1557  +            public const string HKEY_CLASSES_ROOT = "HKEY_CLASSES_ROOT";
         1558  +            public const string HKCR = "HKCR";
         1559  +
         1560  +            ///////////////////////////////////////////////////////////////////
         1561  +
         1562  +            public const string HKEY_CURRENT_CONFIG = "HKEY_CURRENT_CONFIG";
         1563  +            public const string HKCC = "HKCC";
         1564  +
         1565  +            ///////////////////////////////////////////////////////////////////
         1566  +
         1567  +            public const string HKEY_CURRENT_USER = "HKEY_CURRENT_USER";
         1568  +            public const string HKCU = "HKCU";
         1569  +
         1570  +            ///////////////////////////////////////////////////////////////////
         1571  +
         1572  +            public const string HKEY_DYN_DATA = "HKEY_DYN_DATA";
         1573  +            public const string HKDD = "HKDD";
         1574  +
         1575  +            ///////////////////////////////////////////////////////////////////
         1576  +
         1577  +            public const string HKEY_LOCAL_MACHINE = "HKEY_LOCAL_MACHINE";
         1578  +            public const string HKLM = "HKLM";
         1579  +
         1580  +            ///////////////////////////////////////////////////////////////////
         1581  +
         1582  +            public const string HKEY_PERFORMANCE_DATA = "HKEY_PERFORMANCE_DATA";
         1583  +            public const string HKPD = "HKPD";
         1584  +
         1585  +            ///////////////////////////////////////////////////////////////////
         1586  +
         1587  +            public const string HKEY_USERS = "HKEY_USERS";
         1588  +            public const string HKU = "HKU";
         1589  +        }
         1590  +        #endregion
         1591  +
         1592  +        ///////////////////////////////////////////////////////////////////////
         1593  +
  1520   1594           #region RegistryHelper Class
         1595  +        #region Private Constants
         1596  +        private const char KeyNameSeparator = '\\';
         1597  +
         1598  +        ///////////////////////////////////////////////////////////////////////
         1599  +
         1600  +        private static readonly char[] KeyNameSeparators = {
         1601  +            KeyNameSeparator
         1602  +        };
         1603  +        #endregion
         1604  +
         1605  +        ///////////////////////////////////////////////////////////////////////
         1606  +
  1521   1607           private static class RegistryHelper
  1522   1608           {
  1523   1609               #region Public Static Properties
         1610  +            private static MockRegistry readOnlyRegistry;
         1611  +            public static MockRegistry ReadOnlyRegistry
         1612  +            {
         1613  +                get { return readOnlyRegistry; }
         1614  +            }
         1615  +
         1616  +            ///////////////////////////////////////////////////////////////////
         1617  +
         1618  +            private static MockRegistry readWriteRegistry;
         1619  +            public static MockRegistry ReadWriteRegistry
         1620  +            {
         1621  +                get { return readWriteRegistry; }
         1622  +            }
         1623  +
         1624  +            ///////////////////////////////////////////////////////////////////
         1625  +
  1524   1626               private static int subKeysCreated;
  1525   1627               public static int SubKeysCreated
  1526   1628               {
  1527   1629                   get { return subKeysCreated; }
  1528   1630               }
  1529   1631   
  1530   1632               ///////////////////////////////////////////////////////////////////
................................................................................
  1559   1661                   get { return keyValuesDeleted; }
  1560   1662               }
  1561   1663               #endregion
  1562   1664   
  1563   1665               ///////////////////////////////////////////////////////////////////
  1564   1666   
  1565   1667               #region Public Static Methods
         1668  +            public static void ReinitializeDefaultRegistries(
         1669  +                bool whatIf,
         1670  +                bool safe
         1671  +                )
         1672  +            {
         1673  +                if (readOnlyRegistry != null)
         1674  +                {
         1675  +                    readOnlyRegistry.Dispose();
         1676  +                    readOnlyRegistry = null;
         1677  +                }
         1678  +
         1679  +                if (readWriteRegistry != null)
         1680  +                {
         1681  +                    readWriteRegistry.Dispose();
         1682  +                    readWriteRegistry = null;
         1683  +                }
         1684  +
         1685  +                readOnlyRegistry = new MockRegistry(whatIf, true, safe);
         1686  +                readWriteRegistry = new MockRegistry(whatIf, false, safe);
         1687  +            }
         1688  +
         1689  +            ///////////////////////////////////////////////////////////////////
         1690  +
         1691  +            public static MockRegistryKey GetReadOnlyRootKey(
         1692  +                string name
         1693  +                )
         1694  +            {
         1695  +                return GetRootKey(readOnlyRegistry, name);
         1696  +            }
         1697  +
         1698  +            ///////////////////////////////////////////////////////////////////
         1699  +
         1700  +            public static MockRegistryKey GetReadWriteRootKey(
         1701  +                string name
         1702  +                )
         1703  +            {
         1704  +                return GetRootKey(readWriteRegistry, name);
         1705  +            }
         1706  +
         1707  +            ///////////////////////////////////////////////////////////////////
         1708  +
         1709  +            public static MockRegistryKey GetRootKey(
         1710  +                MockRegistry registry,
         1711  +                string name
         1712  +                )
         1713  +            {
         1714  +                if (registry == null)
         1715  +                    return null;
         1716  +
         1717  +                if (String.Equals(
         1718  +                        name, RegistryRootKeyNames.HKEY_CLASSES_ROOT,
         1719  +                        StringComparison.OrdinalIgnoreCase) ||
         1720  +                    String.Equals(
         1721  +                        name, RegistryRootKeyNames.HKCR,
         1722  +                        StringComparison.OrdinalIgnoreCase))
         1723  +                {
         1724  +                    return registry.ClassesRoot;
         1725  +                }
         1726  +                else if (String.Equals(
         1727  +                        name, RegistryRootKeyNames.HKEY_CURRENT_CONFIG,
         1728  +                        StringComparison.OrdinalIgnoreCase) ||
         1729  +                    String.Equals(
         1730  +                        name, RegistryRootKeyNames.HKCC,
         1731  +                        StringComparison.OrdinalIgnoreCase))
         1732  +                {
         1733  +                    return registry.CurrentConfig;
         1734  +                }
         1735  +                else if (String.Equals(
         1736  +                        name, RegistryRootKeyNames.HKEY_CURRENT_USER,
         1737  +                        StringComparison.OrdinalIgnoreCase) ||
         1738  +                    String.Equals(
         1739  +                        name, RegistryRootKeyNames.HKCU,
         1740  +                        StringComparison.OrdinalIgnoreCase))
         1741  +                {
         1742  +                    return registry.CurrentUser;
         1743  +                }
         1744  +                else if (String.Equals(
         1745  +                        name, RegistryRootKeyNames.HKEY_DYN_DATA,
         1746  +                        StringComparison.OrdinalIgnoreCase) ||
         1747  +                    String.Equals(
         1748  +                        name, RegistryRootKeyNames.HKDD,
         1749  +                        StringComparison.OrdinalIgnoreCase))
         1750  +                {
         1751  +                    return registry.DynData;
         1752  +                }
         1753  +                else if (String.Equals(
         1754  +                        name, RegistryRootKeyNames.HKEY_LOCAL_MACHINE,
         1755  +                        StringComparison.OrdinalIgnoreCase) ||
         1756  +                    String.Equals(
         1757  +                        name, RegistryRootKeyNames.HKLM,
         1758  +                        StringComparison.OrdinalIgnoreCase))
         1759  +                {
         1760  +                    return registry.LocalMachine;
         1761  +                }
         1762  +                else if (String.Equals(
         1763  +                        name, RegistryRootKeyNames.HKEY_PERFORMANCE_DATA,
         1764  +                        StringComparison.OrdinalIgnoreCase) ||
         1765  +                    String.Equals(
         1766  +                        name, RegistryRootKeyNames.HKPD,
         1767  +                        StringComparison.OrdinalIgnoreCase))
         1768  +                {
         1769  +                    return registry.PerformanceData;
         1770  +                }
         1771  +                else if (String.Equals(
         1772  +                        name, RegistryRootKeyNames.HKEY_USERS,
         1773  +                        StringComparison.OrdinalIgnoreCase) ||
         1774  +                    String.Equals(
         1775  +                        name, RegistryRootKeyNames.HKU,
         1776  +                        StringComparison.OrdinalIgnoreCase))
         1777  +                {
         1778  +                    return registry.Users;
         1779  +                }
         1780  +
         1781  +                return null;
         1782  +            }
         1783  +
         1784  +            ///////////////////////////////////////////////////////////////////
         1785  +
         1786  +            public static string JoinKeyNames(
         1787  +                params string[] names
         1788  +                )
         1789  +            {
         1790  +                if ((names == null) || (names.Length == 0))
         1791  +                    return null;
         1792  +
         1793  +                StringBuilder builder = new StringBuilder();
         1794  +
         1795  +                foreach (string name in names)
         1796  +                {
         1797  +                    if (name == null)
         1798  +                        continue;
         1799  +
         1800  +                    string newName = name.Trim(KeyNameSeparator);
         1801  +
         1802  +                    if (String.IsNullOrEmpty(newName))
         1803  +                        continue;
         1804  +
         1805  +                    if (builder.Length > 0)
         1806  +                        builder.Append(KeyNameSeparator);
         1807  +
         1808  +                    builder.Append(newName);
         1809  +                }
         1810  +
         1811  +                return builder.ToString();
         1812  +            }
         1813  +
         1814  +            ///////////////////////////////////////////////////////////////////
         1815  +
         1816  +            public static string JoinKeyNames(
         1817  +                MockRegistryKey key,
         1818  +                params string[] names
         1819  +                )
         1820  +            {
         1821  +                string result = JoinKeyNames(names);
         1822  +
         1823  +                if (key != null)
         1824  +                    result = JoinKeyNames(key.Name, result);
         1825  +
         1826  +                return result;
         1827  +            }
         1828  +
         1829  +            ///////////////////////////////////////////////////////////////////
         1830  +
         1831  +            public static string[] SplitKeyName(
         1832  +                string keyName
         1833  +                )
         1834  +            {
         1835  +                if (keyName == null)
         1836  +                    return null;
         1837  +
         1838  +                return keyName.Split(
         1839  +                    KeyNameSeparators, StringSplitOptions.RemoveEmptyEntries);
         1840  +            }
         1841  +
         1842  +            ///////////////////////////////////////////////////////////////////
         1843  +
         1844  +            public static string LastSubKeyName(
         1845  +                string keyName
         1846  +                )
         1847  +            {
         1848  +                string[] subKeyNames = SplitKeyName(keyName);
         1849  +
         1850  +                if ((subKeyNames == null) || (subKeyNames.Length == 0))
         1851  +                    return null;
         1852  +
         1853  +                return subKeyNames[subKeyNames.Length - 1];
         1854  +            }
         1855  +
         1856  +            ///////////////////////////////////////////////////////////////////
         1857  +
  1566   1858               [MethodImpl(MethodImplOptions.NoInlining)]
  1567   1859               public static MockRegistryKey OpenSubKey(
  1568   1860                   MockRegistryKey rootKey,
  1569   1861                   string subKeyName,
  1570   1862                   bool writable,
  1571   1863                   bool whatIf,
  1572   1864                   bool verbose
  1573   1865                   )
  1574   1866               {
  1575   1867                   if (verbose)
         1868  +                {
  1576   1869                       TraceOps.DebugAndTrace(writable ?
  1577   1870                           TracePriority.Highest : TracePriority.Higher,
  1578   1871                           debugCallback, traceCallback, String.Format(
  1579   1872                           "rootKey = {0}, subKeyName = {1}, writable = {2}",
  1580   1873                           ForDisplay(rootKey), ForDisplay(subKeyName),
  1581   1874                           ForDisplay(writable)), traceCategory);
         1875  +                }
  1582   1876   
  1583   1877                   if (rootKey == null)
  1584   1878                       return null;
  1585   1879   
  1586   1880                   //
  1587   1881                   // HACK: Always forbid writable access when operating in
  1588   1882                   //       "what-if" mode.
................................................................................
  1601   1895                   MockRegistryKey rootKey,
  1602   1896                   string subKeyName,
  1603   1897                   bool whatIf,
  1604   1898                   bool verbose
  1605   1899                   )
  1606   1900               {
  1607   1901                   if (verbose)
         1902  +                {
  1608   1903                       TraceOps.DebugAndTrace(TracePriority.Highest,
  1609   1904                           debugCallback, traceCallback, String.Format(
  1610   1905                           "rootKey = {0}, subKeyName = {1}",
  1611   1906                           ForDisplay(rootKey), ForDisplay(subKeyName)),
  1612   1907                           traceCategory);
         1908  +                }
  1613   1909   
  1614   1910                   if (rootKey == null)
  1615   1911                       return null;
  1616   1912   
  1617   1913                   try
  1618   1914                   {
  1619   1915                       //
................................................................................
  1655   1951                   string subKeyName,
  1656   1952                   bool throwOnMissing,
  1657   1953                   bool whatIf,
  1658   1954                   bool verbose
  1659   1955                   )
  1660   1956               {
  1661   1957                   if (verbose)
         1958  +                {
  1662   1959                       TraceOps.DebugAndTrace(TracePriority.Highest,
  1663   1960                           debugCallback, traceCallback, String.Format(
  1664   1961                           "rootKey = {0}, subKeyName = {1}",
  1665   1962                           ForDisplay(rootKey), ForDisplay(subKeyName)),
  1666   1963                           traceCategory);
         1964  +                }
  1667   1965   
  1668   1966                   if (rootKey == null)
  1669   1967                       return;
  1670   1968   
  1671   1969                   if (!whatIf)
  1672   1970                       rootKey.DeleteSubKey(subKeyName, throwOnMissing);
  1673   1971   
................................................................................
  1681   1979                   MockRegistryKey rootKey,
  1682   1980                   string subKeyName,
  1683   1981                   bool whatIf,
  1684   1982                   bool verbose
  1685   1983                   )
  1686   1984               {
  1687   1985                   if (verbose)
         1986  +                {
  1688   1987                       TraceOps.DebugAndTrace(TracePriority.Highest,
  1689   1988                           debugCallback, traceCallback, String.Format(
  1690   1989                           "rootKey = {0}, subKeyName = {1}",
  1691   1990                           ForDisplay(rootKey), ForDisplay(subKeyName)),
  1692   1991                           traceCategory);
         1992  +                }
  1693   1993   
  1694   1994                   if (rootKey == null)
  1695   1995                       return;
  1696   1996   
  1697   1997                   if (!whatIf)
  1698   1998                       rootKey.DeleteSubKeyTree(subKeyName);
  1699   1999   
................................................................................
  1706   2006               public static string[] GetSubKeyNames(
  1707   2007                   MockRegistryKey key,
  1708   2008                   bool whatIf,
  1709   2009                   bool verbose
  1710   2010                   )
  1711   2011               {
  1712   2012                   if (verbose)
         2013  +                {
  1713   2014                       TraceOps.DebugAndTrace(TracePriority.High,
  1714   2015                           debugCallback, traceCallback, String.Format(
  1715   2016                           "key = {0}", ForDisplay(key)), traceCategory);
         2017  +                }
  1716   2018   
  1717   2019                   if (key == null)
  1718   2020                       return null;
  1719   2021   
  1720   2022                   return key.GetSubKeyNames();
  1721   2023               }
  1722   2024   
................................................................................
  1728   2030                   string name,
  1729   2031                   object defaultValue,
  1730   2032                   bool whatIf,
  1731   2033                   bool verbose
  1732   2034                   )
  1733   2035               {
  1734   2036                   if (verbose)
         2037  +                {
  1735   2038                       TraceOps.DebugAndTrace(TracePriority.High,
  1736   2039                           debugCallback, traceCallback, String.Format(
  1737   2040                           "key = {0}, name = {1}, defaultValue = {2}",
  1738   2041                           ForDisplay(key), ForDisplay(name),
  1739   2042                           ForDisplay(defaultValue)), traceCategory);
         2043  +                }
  1740   2044   
  1741   2045                   if (key == null)
  1742   2046                       return null;
  1743   2047   
  1744   2048                   object value = key.GetValue(name, defaultValue);
  1745   2049   
  1746   2050                   keyValuesRead++;
................................................................................
  1756   2060                   string name,
  1757   2061                   object value,
  1758   2062                   bool whatIf,
  1759   2063                   bool verbose
  1760   2064                   )
  1761   2065               {
  1762   2066                   if (verbose)
         2067  +                {
  1763   2068                       TraceOps.DebugAndTrace(TracePriority.Highest,
  1764   2069                           debugCallback, traceCallback, String.Format(
  1765   2070                           "key = {0}, name = {1}, value = {2}",
  1766   2071                           ForDisplay(key), ForDisplay(name), ForDisplay(value)),
  1767   2072                           traceCategory);
         2073  +                }
  1768   2074   
  1769   2075                   if (key == null)
  1770   2076                       return;
  1771   2077   
  1772   2078                   if (!whatIf)
  1773   2079                       key.SetValue(name, value);
  1774   2080   
................................................................................
  1783   2089                   string name,
  1784   2090                   bool throwOnMissing,
  1785   2091                   bool whatIf,
  1786   2092                   bool verbose
  1787   2093                   )
  1788   2094               {
  1789   2095                   if (verbose)
         2096  +                {
  1790   2097                       TraceOps.DebugAndTrace(TracePriority.Highest,
  1791   2098                           debugCallback, traceCallback, String.Format(
  1792   2099                           "key = {0}, name = {1}", ForDisplay(key),
  1793   2100                           ForDisplay(name)), traceCategory);
         2101  +                }
  1794   2102   
  1795   2103                   if (key == null)
  1796   2104                       return;
  1797   2105   
  1798   2106                   if (!whatIf)
  1799   2107                       key.DeleteValue(name, throwOnMissing);
  1800   2108   
................................................................................
  3437   3745                       if (!configuration.whatIf)
  3438   3746                       {
  3439   3747                           //
  3440   3748                           // NOTE: If the debugger is attached and "what-if"
  3441   3749                           //       mode is [now] disabled, issue a warning.
  3442   3750                           //
  3443   3751                           if (Debugger.IsAttached)
         3752  +                        {
  3444   3753                               TraceOps.DebugAndTrace(TracePriority.MediumHigh,
  3445   3754                                   debugCallback, traceCallback,
  3446   3755                                   "Forced to disable \"what-if\" mode with " +
  3447   3756                                   "debugger attached.", traceCategory);
         3757  +                        }
  3448   3758                       }
  3449   3759                       else
  3450   3760                       {
  3451   3761                           TraceOps.DebugAndTrace(TracePriority.MediumHigh,
  3452   3762                               debugCallback, traceCallback,
  3453   3763                               "No actual changes will be made to this " +
  3454   3764                               "system because \"what-if\" mode is enabled.",
................................................................................
  5023   5333           {
  5024   5334               //
  5025   5335               // BUGFIX: Apparently, the per-user registry hive does not use
  5026   5336               //         the "Wow6432Node" node to store settings for 32-bit
  5027   5337               //         applications running on a 64-bit operating system.
  5028   5338               //         Ticket [a0677309f0] has further details.
  5029   5339               //
  5030         -            return String.Format("{0}{1}", RootKeyName,
         5340  +            return RegistryHelper.JoinKeyNames(RootKeyName,
  5031   5341                   !perUser && wow64 && Is64BitProcess() ?
  5032         -                    "\\" + Wow64SubKeyName : String.Empty);
         5342  +                    Wow64SubKeyName : String.Empty);
  5033   5343           }
  5034   5344   
  5035   5345           ///////////////////////////////////////////////////////////////////////
  5036   5346   
  5037   5347           private static string GetSystemDirectory(
  5038   5348               bool wow64
  5039   5349               )
................................................................................
  5200   5510   
  5201   5511           #region .NET Framework Handling
  5202   5512           private static string GetFrameworkRootKeyName(
  5203   5513               bool perUser,
  5204   5514               bool wow64
  5205   5515               )
  5206   5516           {
  5207         -            return String.Format("{0}\\Microsoft\\.NETFramework",
  5208         -                GetRootKeyName(perUser, wow64));
         5517  +            return RegistryHelper.JoinKeyNames(
         5518  +                GetRootKeyName(perUser, wow64),
         5519  +                "Microsoft", ".NETFramework");
  5209   5520           }
  5210   5521   
  5211   5522           ///////////////////////////////////////////////////////////////////////
  5212   5523   
  5213   5524           private static string GetFrameworkKeyName(
  5214   5525               string frameworkName,
  5215   5526               Version frameworkVersion,
  5216   5527               string platformName,
  5217   5528               bool perUser,
  5218   5529               bool wow64
  5219   5530               )
  5220   5531           {
  5221         -            string format = !String.IsNullOrEmpty(platformName) ?
  5222         -                "{0}\\Microsoft\\{1}\\v{2}\\{3}" :
  5223         -                "{0}\\Microsoft\\{1}\\v{2}";
         5532  +            string frameworkVersionString = (frameworkVersion != null) ?
         5533  +                "v" + frameworkVersion.ToString() : null;
  5224   5534   
  5225         -            return String.Format(format, GetRootKeyName(perUser, wow64),
  5226         -                frameworkName, frameworkVersion, platformName);
         5535  +            return RegistryHelper.JoinKeyNames(
         5536  +                GetRootKeyName(perUser, wow64), "Microsoft", frameworkName,
         5537  +                frameworkVersionString, platformName);
  5227   5538           }
  5228   5539   
  5229   5540           ///////////////////////////////////////////////////////////////////////
  5230   5541   
  5231   5542           private static string GetImageRuntimeVersion(
  5232   5543               string fileName
  5233   5544               )
................................................................................
  5701   6012                       }
  5702   6013                       else
  5703   6014                       {
  5704   6015                           if (localSaved && !saved)
  5705   6016                               saved = true;
  5706   6017   
  5707   6018                           if (verbose)
         6019  +                        {
  5708   6020                               TraceOps.DebugAndTrace(TracePriority.Lowest,
  5709   6021                                   debugCallback, traceCallback, String.Format(
  5710   6022                                   "localSaved = {0}, saved = {1}",
  5711   6023                                   ForDisplay(localSaved), ForDisplay(saved)),
  5712   6024                                   traceCategory);
         6025  +                        }
  5713   6026                       }
  5714   6027                   }
  5715   6028               }
  5716   6029   
  5717   6030               return true;
  5718   6031           }
  5719   6032   
................................................................................
  6128   6441                   addElement.SetAttribute("type", fullTypeName);
  6129   6442                   dirty = true;
  6130   6443               }
  6131   6444   
  6132   6445               if (dirty || whatIf)
  6133   6446               {
  6134   6447                   if (verbose)
         6448  +                {
  6135   6449                       TraceOps.DebugAndTrace(TracePriority.Highest,
  6136   6450                           debugCallback, traceCallback, String.Format(
  6137   6451                           "addElement = {0}", ForDisplay(addElement)),
  6138   6452                           traceCategory);
         6453  +                }
  6139   6454   
  6140   6455                   if (!whatIf)
  6141   6456                       document.Save(fileName);
  6142   6457   
  6143   6458                   filesModified++;
  6144   6459   
  6145   6460                   saved = true;
................................................................................
  6171   6486   
  6172   6487               if (addElement != null)
  6173   6488               {
  6174   6489                   addElement.ParentNode.RemoveChild(addElement);
  6175   6490                   dirty = true;
  6176   6491               }
  6177   6492   
  6178         -            XmlElement removeElement = document.SelectSingleNode(
  6179         -                String.Format(XPathForRemoveElement, invariantName)) as XmlElement;
         6493  +            XmlElement removeElement = document.SelectSingleNode(String.Format(
         6494  +                XPathForRemoveElement, invariantName)) as XmlElement;
  6180   6495   
  6181   6496               if (removeElement != null)
  6182   6497               {
  6183   6498                   removeElement.ParentNode.RemoveChild(removeElement);
  6184   6499                   dirty = true;
  6185   6500               }
  6186   6501   
  6187   6502               if (dirty || whatIf)
  6188   6503               {
  6189   6504                   if (verbose)
         6505  +                {
  6190   6506                       TraceOps.DebugAndTrace(TracePriority.Highest,
  6191   6507                           debugCallback, traceCallback, String.Format(
  6192   6508                           "addElement = {0}, removeElement = {1}",
  6193   6509                           ForDisplay(addElement), ForDisplay(removeElement)),
  6194   6510                           traceCategory);
         6511  +                }
  6195   6512   
  6196   6513                   if (!whatIf)
  6197   6514                       document.Save(fileName);
  6198   6515   
  6199   6516                   filesModified++;
  6200   6517   
  6201   6518                   saved = true;
................................................................................
  6257   6574               string frameworkName,
  6258   6575               Version frameworkVersion,
  6259   6576               string platformName,
  6260   6577               bool perUser,
  6261   6578               bool wow64
  6262   6579               )
  6263   6580           {
         6581  +            string frameworkVersionString = (frameworkVersion != null) ?
         6582  +                "v" + frameworkVersion.ToString() : null;
         6583  +
  6264   6584               //
  6265   6585               // NOTE: This registry key appears to always be 32-bit only
  6266   6586               //       (i.e. probably because it is only used by Visual
  6267   6587               //       Studio, which is currently always 32-bit only).
  6268   6588               //
  6269         -            string format = !String.IsNullOrEmpty(platformName) ?
  6270         -                "{0}\\Microsoft\\{1}\\v{2}\\{3}\\AssemblyFoldersEx" :
  6271         -                "{0}\\Microsoft\\{1}\\v{2}\\AssemblyFoldersEx";
  6272         -
  6273         -            return String.Format(format, GetRootKeyName(perUser, wow64),
  6274         -                frameworkName, frameworkVersion, platformName);
         6589  +            return String.Format(GetRootKeyName(perUser, wow64),
         6590  +                "Microsoft", frameworkName, frameworkVersionString,
         6591  +                platformName, "AssemblyFoldersEx");
  6275   6592           }
  6276   6593   
  6277   6594           ///////////////////////////////////////////////////////////////////////
  6278   6595   
  6279   6596           private static bool AddToAssemblyFolders(
  6280   6597               MockRegistryKey rootKey,
  6281   6598               string frameworkName,
................................................................................
  6296   6613   
  6297   6614               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6298   6615                       rootKey, keyName, true, whatIf, verbose))
  6299   6616               {
  6300   6617                   if (key == null)
  6301   6618                   {
  6302   6619                       error = String.Format(
  6303         -                        "could not open registry key: {0}\\{1}",
  6304         -                        rootKey, keyName);
         6620  +                        "could not open registry key: {0}",
         6621  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6305   6622   
  6306   6623                       return false;
  6307   6624                   }
  6308   6625   
  6309   6626                   using (MockRegistryKey subKey = RegistryHelper.CreateSubKey(
  6310   6627                           key, subKeyName, whatIf, verbose))
  6311   6628                   {
  6312   6629                       if (subKey == null)
  6313   6630                       {
  6314   6631                           error = String.Format(
  6315         -                            "could not create registry key: {0}\\{1}",
  6316         -                            key, subKeyName);
         6632  +                            "could not create registry key: {0}",
         6633  +                            RegistryHelper.JoinKeyNames(key, subKeyName));
  6317   6634   
  6318   6635                           return false;
  6319   6636                       }
  6320   6637   
  6321   6638                       RegistryHelper.SetValue(
  6322   6639                           subKey, null, directory, whatIf, verbose);
  6323   6640                   }
................................................................................
  6348   6665   
  6349   6666               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6350   6667                       rootKey, keyName, true, whatIf, verbose))
  6351   6668               {
  6352   6669                   if (key == null)
  6353   6670                   {
  6354   6671                       error = String.Format(
  6355         -                        "could not open registry key: {0}\\{1}",
  6356         -                        rootKey, keyName);
         6672  +                        "could not open registry key: {0}",
         6673  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6357   6674   
  6358   6675                       return false;
  6359   6676                   }
  6360   6677   
  6361   6678                   RegistryHelper.DeleteSubKey(
  6362   6679                       key, subKeyName, throwOnMissing, whatIf, verbose);
  6363   6680               }
................................................................................
  6415   6732   
  6416   6733           #region Visual Studio Handling
  6417   6734           private static string GetVsRootKeyName(
  6418   6735               bool perUser,
  6419   6736               bool wow64
  6420   6737               )
  6421   6738           {
  6422         -            return String.Format("{0}\\Microsoft\\VisualStudio",
  6423         -                GetRootKeyName(perUser, wow64));
         6739  +            return RegistryHelper.JoinKeyNames(
         6740  +                GetRootKeyName(perUser, wow64),
         6741  +                "Microsoft", "VisualStudio");
  6424   6742           }
  6425   6743   
  6426   6744           ///////////////////////////////////////////////////////////////////////
  6427   6745   
  6428   6746           private static string GetVsKeyName(
  6429   6747               Version vsVersion,
  6430   6748               string suffix,
................................................................................
  6431   6749               bool perUser,
  6432   6750               bool wow64
  6433   6751               )
  6434   6752           {
  6435   6753               if (vsVersion == null)
  6436   6754                   return null;
  6437   6755   
  6438         -            return String.Format(
  6439         -                "{0}\\{1}{2}", GetVsRootKeyName(perUser, wow64), vsVersion,
  6440         -                suffix);
         6756  +            return RegistryHelper.JoinKeyNames(
         6757  +                GetVsRootKeyName(perUser, wow64),
         6758  +                String.Format("{0}{1}", vsVersion, suffix));
  6441   6759           }
  6442   6760   
  6443   6761           ///////////////////////////////////////////////////////////////////////
  6444   6762   
  6445   6763           #region Visual Studio Data Source Handling
  6446   6764           private static bool AddVsDataSource(
  6447   6765               MockRegistryKey rootKey,
................................................................................
  6471   6789   
  6472   6790               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6473   6791                       rootKey, keyName, false, whatIf, verbose))
  6474   6792               {
  6475   6793                   if (key == null)
  6476   6794                   {
  6477   6795                       error = String.Format(
  6478         -                        "could not open registry key: {0}\\{1}",
  6479         -                        rootKey, keyName);
         6796  +                        "could not open registry key: {0}",
         6797  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6480   6798   
  6481   6799                       return false;
  6482   6800                   }
  6483   6801   
  6484   6802                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  6485   6803                           key, "DataSources", true, whatIf, verbose))
  6486   6804                   {
  6487   6805                       if (subKey == null)
  6488   6806                       {
  6489   6807                           error = String.Format(
  6490         -                            "could not open registry key: {0}\\DataSources",
  6491         -                            key);
         6808  +                            "could not open registry key: {0}",
         6809  +                            RegistryHelper.JoinKeyNames(key,
         6810  +                                "DataSources"));
  6492   6811   
  6493   6812                           return false;
  6494   6813                       }
  6495   6814   
  6496   6815                       using (MockRegistryKey dataSourceKey =
  6497   6816                               RegistryHelper.CreateSubKey(subKey,
  6498   6817                               package.DataSourceId.ToString(VsIdFormat),
  6499   6818                               whatIf, verbose))
  6500   6819                       {
  6501   6820                           if (dataSourceKey == null)
  6502   6821                           {
  6503   6822                               error = String.Format(
  6504         -                                "could not create registry key: {0}\\{1}", key,
  6505         -                                package.DataSourceId.ToString(VsIdFormat));
         6823  +                                "could not create registry key: {0}",
         6824  +                                RegistryHelper.JoinKeyNames(key,
         6825  +                                    package.DataSourceId.ToString(
         6826  +                                        VsIdFormat)));
  6506   6827   
  6507   6828                               return false;
  6508   6829                           }
  6509   6830   
  6510   6831                           RegistryHelper.SetValue(
  6511   6832                               dataSourceKey, null, String.Format(
  6512   6833                               "{0} Database File", ProjectName), whatIf,
................................................................................
  6517   6838                           //
  6518   6839                           RegistryHelper.SetValue(
  6519   6840                               dataSourceKey, "DefaultProvider",
  6520   6841                               package.DataProviderId.ToString(VsIdFormat),
  6521   6842                               whatIf, verbose);
  6522   6843   
  6523   6844                           RegistryHelper.CreateSubKey(dataSourceKey,
  6524         -                            String.Format("SupportingProviders\\{0}",
  6525         -                            package.DataProviderId.ToString(VsIdFormat)),
         6845  +                            RegistryHelper.JoinKeyNames("SupportingProviders",
         6846  +                                package.DataProviderId.ToString(VsIdFormat)),
  6526   6847                               whatIf, verbose);
  6527   6848                       }
  6528   6849                   }
  6529   6850               }
  6530   6851   
  6531   6852               return true;
  6532   6853           }
................................................................................
  6561   6882   
  6562   6883               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6563   6884                       rootKey, keyName, false, whatIf, verbose))
  6564   6885               {
  6565   6886                   if (key == null)
  6566   6887                   {
  6567   6888                       error = String.Format(
  6568         -                        "could not open registry key: {0}\\{1}",
  6569         -                        rootKey, keyName);
         6889  +                        "could not open registry key: {0}",
         6890  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6570   6891   
  6571   6892                       return false;
  6572   6893                   }
  6573   6894   
  6574   6895                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  6575   6896                           key, "DataSources", true, whatIf, verbose))
  6576   6897                   {
  6577   6898                       if (subKey == null)
  6578   6899                       {
  6579   6900                           error = String.Format(
  6580         -                            "could not open registry key: {0}\\DataSources",
  6581         -                            key);
         6901  +                            "could not open registry key: {0}",
         6902  +                            RegistryHelper.JoinKeyNames(key,
         6903  +                                "DataSources"));
  6582   6904   
  6583   6905                           return false;
  6584   6906                       }
  6585   6907   
  6586   6908                       RegistryHelper.DeleteSubKeyTree(
  6587   6909                           subKey, package.DataSourceId.ToString(VsIdFormat),
  6588   6910                           whatIf, verbose);
................................................................................
  6670   6992   
  6671   6993               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6672   6994                       rootKey, keyName, false, whatIf, verbose))
  6673   6995               {
  6674   6996                   if (key == null)
  6675   6997                   {
  6676   6998                       error = String.Format(
  6677         -                        "could not open registry key: {0}\\{1}",
  6678         -                        rootKey, keyName);
         6999  +                        "could not open registry key: {0}",
         7000  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6679   7001   
  6680   7002                       return false;
  6681   7003                   }
  6682   7004   
  6683   7005                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  6684   7006                           key, "DataProviders", true, whatIf, verbose))
  6685   7007                   {
  6686   7008                       if (subKey == null)
  6687   7009                       {
  6688   7010                           error = String.Format(
  6689         -                            "could not open registry key: {0}\\DataProviders",
  6690         -                            key);
         7011  +                            "could not open registry key: {0}",
         7012  +                            RegistryHelper.JoinKeyNames(key,
         7013  +                                "DataProviders"));
  6691   7014   
  6692   7015                           return false;
  6693   7016                       }
  6694   7017   
  6695   7018                       using (MockRegistryKey dataProviderKey =
  6696   7019                               RegistryHelper.CreateSubKey(subKey,
  6697   7020                               package.DataProviderId.ToString(VsIdFormat),
  6698   7021                               whatIf, verbose))
  6699   7022                       {
  6700   7023                           if (dataProviderKey == null)
  6701   7024                           {
  6702   7025                               error = String.Format(
  6703         -                                "could not create registry key: {0}\\{1}", key,
  6704         -                                package.DataProviderId.ToString(VsIdFormat));
         7026  +                                "could not create registry key: {0}",
         7027  +                                RegistryHelper.JoinKeyNames(key,
         7028  +                                    package.DataProviderId.ToString(
         7029  +                                        VsIdFormat)));
  6705   7030   
  6706   7031                               return false;
  6707   7032                           }
  6708   7033   
  6709   7034                           RegistryHelper.SetValue(
  6710   7035                               dataProviderKey, null, Description, whatIf,
  6711   7036                               verbose);
................................................................................
  6747   7072   
  6748   7073                           RegistryHelper.SetValue(
  6749   7074                               dataProviderKey, "FactoryService",
  6750   7075                               package.ServiceId.ToString(VsIdFormat), whatIf,
  6751   7076                               verbose);
  6752   7077   
  6753   7078                           RegistryHelper.CreateSubKey(dataProviderKey,
  6754         -                            "SupportedObjects\\DataConnectionUIControl",
  6755         -                            whatIf, verbose);
         7079  +                            RegistryHelper.JoinKeyNames("SupportedObjects",
         7080  +                                "DataConnectionUIControl"), whatIf, verbose);
         7081  +
         7082  +                        RegistryHelper.CreateSubKey(dataProviderKey,
         7083  +                            RegistryHelper.JoinKeyNames("SupportedObjects",
         7084  +                                "DataConnectionProperties"), whatIf, verbose);
  6756   7085   
  6757   7086                           RegistryHelper.CreateSubKey(dataProviderKey,
  6758         -                            "SupportedObjects\\DataConnectionProperties",
  6759         -                            whatIf, verbose);
         7087  +                            RegistryHelper.JoinKeyNames("SupportedObjects",
         7088  +                                "DataConnectionSupport"), whatIf, verbose);
  6760   7089   
  6761   7090                           RegistryHelper.CreateSubKey(dataProviderKey,
  6762         -                            "SupportedObjects\\DataConnectionSupport", whatIf,
  6763         -                            verbose);
         7091  +                            RegistryHelper.JoinKeyNames("SupportedObjects",
         7092  +                                "DataObjectSupport"), whatIf, verbose);
  6764   7093   
  6765   7094                           RegistryHelper.CreateSubKey(dataProviderKey,
  6766         -                            "SupportedObjects\\DataObjectSupport", whatIf,
  6767         -                            verbose);
  6768         -
  6769         -                        RegistryHelper.CreateSubKey(dataProviderKey,
  6770         -                            "SupportedObjects\\DataViewSupport", whatIf,
  6771         -                            verbose);
         7095  +                            RegistryHelper.JoinKeyNames("SupportedObjects",
         7096  +                                "DataViewSupport"), whatIf, verbose);
  6772   7097                       }
  6773   7098                   }
  6774   7099               }
  6775   7100   
  6776   7101               return true;
  6777   7102           }
  6778   7103   
................................................................................
  6800   7125   
  6801   7126               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6802   7127                       rootKey, keyName, false, whatIf, verbose))
  6803   7128               {
  6804   7129                   if (key == null)
  6805   7130                   {
  6806   7131                       error = String.Format(
  6807         -                        "could not open registry key: {0}\\{1}",
  6808         -                        rootKey, keyName);
         7132  +                        "could not open registry key: {0}",
         7133  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6809   7134   
  6810   7135                       return false;
  6811   7136                   }
  6812   7137   
  6813   7138                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  6814   7139                           key, "DataProviders", true, whatIf, verbose))
  6815   7140                   {
  6816   7141                       if (subKey == null)
  6817   7142                       {
  6818   7143                           error = String.Format(
  6819         -                            "could not open registry key: {0}\\DataProviders",
  6820         -                            key);
         7144  +                            "could not open registry key: {0}",
         7145  +                            RegistryHelper.JoinKeyNames(key,
         7146  +                                "DataProviders"));
  6821   7147   
  6822   7148                           return false;
  6823   7149                       }
  6824   7150   
  6825   7151                       RegistryHelper.DeleteSubKeyTree(
  6826   7152                           subKey, package.DataProviderId.ToString(VsIdFormat),
  6827   7153                           whatIf, verbose);
................................................................................
  6941   7267   
  6942   7268               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  6943   7269                       rootKey, keyName, false, whatIf, verbose))
  6944   7270               {
  6945   7271                   if (key == null)
  6946   7272                   {
  6947   7273                       error = String.Format(
  6948         -                        "could not open registry key: {0}\\{1}",
  6949         -                        rootKey, keyName);
         7274  +                        "could not open registry key: {0}",
         7275  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  6950   7276   
  6951   7277                       return false;
  6952   7278                   }
  6953   7279   
  6954   7280                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  6955   7281                           key, "Packages", true, whatIf, verbose))
  6956   7282                   {
  6957   7283                       if (subKey == null)
  6958   7284                       {
  6959   7285                           error = String.Format(
  6960         -                            "could not open registry key: {0}\\Packages",
  6961         -                            key);
         7286  +                            "could not open registry key: {0}",
         7287  +                            RegistryHelper.JoinKeyNames(key,
         7288  +                                "Packages"));
  6962   7289   
  6963   7290                           return false;
  6964   7291                       }
  6965   7292   
  6966   7293                       //
  6967   7294                       // NOTE: *WARNING* Changing any of these values will likely
  6968   7295                       //       require a new "package load key" (PLK) to be
................................................................................
  6986   7313                               RegistryHelper.CreateSubKey(subKey,
  6987   7314                               package.PackageId.ToString(VsIdFormat), whatIf,
  6988   7315                               verbose))
  6989   7316                       {
  6990   7317                           if (packageKey == null)
  6991   7318                           {
  6992   7319                               error = String.Format(
  6993         -                                "could not create registry key: {0}\\{1}",
  6994         -                                key, package.PackageId.ToString(VsIdFormat));
         7320  +                                "could not create registry key: {0}",
         7321  +                                RegistryHelper.JoinKeyNames(key,
         7322  +                                    package.PackageId.ToString(VsIdFormat)));
  6995   7323   
  6996   7324                               return false;
  6997   7325                           }
  6998   7326   
  6999   7327                           RegistryHelper.SetValue(packageKey, null,
  7000   7328                               String.Format("{0} Designer Package", ProjectName),
  7001   7329                               whatIf, verbose);
................................................................................
  7034   7362                           using (MockRegistryKey toolboxKey =
  7035   7363                                   RegistryHelper.CreateSubKey(packageKey,
  7036   7364                                   "Toolbox", whatIf, verbose))
  7037   7365                           {
  7038   7366                               if (toolboxKey == null)
  7039   7367                               {
  7040   7368                                   error = String.Format(
  7041         -                                    "could not create registry key: " +
  7042         -                                    "{0}\\Toolbox", packageKey);
         7369  +                                    "could not create registry key: {0}",
         7370  +                                    RegistryHelper.JoinKeyNames(packageKey,
         7371  +                                        "Toolbox"));
  7043   7372   
  7044   7373                                   return false;
  7045   7374                               }
  7046   7375   
  7047   7376                               RegistryHelper.SetValue(
  7048   7377                                   toolboxKey, "Default Items", 3, whatIf,
  7049   7378                                   verbose);
................................................................................
  7053   7382   
  7054   7383                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  7055   7384                           key, "Menus", true, whatIf, verbose))
  7056   7385                   {
  7057   7386                       if (subKey == null)
  7058   7387                       {
  7059   7388                           error = String.Format(
  7060         -                            "could not open registry key: {0}\\Menus",
  7061         -                            key);
         7389  +                            "could not open registry key: {0}",
         7390  +                            RegistryHelper.JoinKeyNames(key,
         7391  +                                "Menus"));
  7062   7392   
  7063   7393                           return false;
  7064   7394                       }
  7065   7395   
  7066   7396                       RegistryHelper.SetValue(
  7067   7397                           subKey, package.PackageId.ToString(VsIdFormat),
  7068   7398                           ", 1000, 3", whatIf, verbose);
................................................................................
  7070   7400   
  7071   7401                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  7072   7402                           key, "Services", true, whatIf, verbose))
  7073   7403                   {
  7074   7404                       if (subKey == null)
  7075   7405                       {
  7076   7406                           error = String.Format(
  7077         -                            "could not open registry key: {0}\\Services",
  7078         -                            key);
         7407  +                            "could not open registry key: {0}",
         7408  +                            RegistryHelper.JoinKeyNames(key,
         7409  +                                "Services"));
  7079   7410   
  7080   7411                           return false;
  7081   7412                       }
  7082   7413   
  7083   7414                       using (MockRegistryKey serviceKey =
  7084   7415                               RegistryHelper.CreateSubKey(subKey,
  7085   7416                               package.ServiceId.ToString(VsIdFormat), whatIf,
  7086   7417                               verbose))
  7087   7418                       {
  7088   7419                           if (serviceKey == null)
  7089   7420                           {
  7090   7421                               error = String.Format(
  7091         -                                "could not create registry key: {0}\\{1}",
  7092         -                                key, package.ServiceId.ToString(VsIdFormat));
         7422  +                                "could not create registry key: {0}",
         7423  +                                RegistryHelper.JoinKeyNames(key,
         7424  +                                    package.ServiceId.ToString(VsIdFormat)));
  7093   7425   
  7094   7426                               return false;
  7095   7427                           }
  7096   7428   
  7097   7429                           RegistryHelper.SetValue(serviceKey, null,
  7098   7430                               package.PackageId.ToString(VsIdFormat), whatIf,
  7099   7431                               verbose);
................................................................................
  7139   7471   
  7140   7472               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  7141   7473                       rootKey, keyName, false, whatIf, verbose))
  7142   7474               {
  7143   7475                   if (key == null)
  7144   7476                   {
  7145   7477                       error = String.Format(
  7146         -                        "could not open registry key: {0}\\{1}",
  7147         -                        rootKey, keyName);
         7478  +                        "could not open registry key: {0}",
         7479  +                        RegistryHelper.JoinKeyNames(rootKey, keyName));
  7148   7480   
  7149   7481                       return false;
  7150   7482                   }
  7151   7483   
  7152   7484                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  7153   7485                           key, "Packages", true, whatIf, verbose))
  7154   7486                   {
  7155   7487                       if (subKey == null)
  7156   7488                       {
  7157   7489                           error = String.Format(
  7158         -                            "could not open registry key: {0}\\Packages",
  7159         -                            key);
         7490  +                            "could not open registry key: {0}",
         7491  +                            RegistryHelper.JoinKeyNames(key,
         7492  +                                "Packages"));
  7160   7493   
  7161   7494                           return false;
  7162   7495                       }
  7163   7496   
  7164   7497                       RegistryHelper.DeleteSubKeyTree(
  7165   7498                           subKey, package.PackageId.ToString(VsIdFormat),
  7166   7499                           whatIf, verbose);
................................................................................
  7168   7501   
  7169   7502                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  7170   7503                           key, "Menus", true, whatIf, verbose))
  7171   7504                   {
  7172   7505                       if (subKey == null)
  7173   7506                       {
  7174   7507                           error = String.Format(
  7175         -                            "could not open registry key: {0}\\Menus",
  7176         -                            key);
         7508  +                            "could not open registry key: {0}",
         7509  +                            RegistryHelper.JoinKeyNames(key,
         7510  +                                "Menus"));
  7177   7511   
  7178   7512                           return false;
  7179   7513                       }
  7180   7514   
  7181   7515                       RegistryHelper.DeleteValue(
  7182   7516                           subKey, package.PackageId.ToString(VsIdFormat),
  7183   7517                           throwOnMissing, whatIf, verbose);
................................................................................
  7185   7519   
  7186   7520                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  7187   7521                           key, "Services", true, whatIf, verbose))
  7188   7522                   {
  7189   7523                       if (subKey == null)
  7190   7524                       {
  7191   7525                           error = String.Format(
  7192         -                            "could not open registry key: {0}\\Services",
  7193         -                            key);
         7526  +                            "could not open registry key: {0}",
         7527  +                            RegistryHelper.JoinKeyNames(key,
         7528  +                                "Services"));
  7194   7529   
  7195   7530                           return false;
  7196   7531                       }
  7197   7532   
  7198   7533                       RegistryHelper.DeleteSubKeyTree(
  7199   7534                           subKey, package.ServiceId.ToString(VsIdFormat),
  7200   7535                           whatIf, verbose);
................................................................................
  7332   7667               process.OutputDataReceived += new DataReceivedEventHandler(
  7333   7668                   VsDevEnvSetupOutputDataReceived);
  7334   7669   
  7335   7670               process.ErrorDataReceived += new DataReceivedEventHandler(
  7336   7671                   VsDevEnvSetupErrorDataReceived);
  7337   7672   
  7338   7673               if (verbose)
         7674  +            {
  7339   7675                   TraceOps.DebugAndTrace(TracePriority.Highest,
  7340   7676                       debugCallback, traceCallback, ForDisplay(startInfo),
  7341   7677                       traceCategory);
         7678  +            }
  7342   7679   
  7343   7680               //
  7344   7681               // NOTE: In "what-if" mode, do not actually start the process.
  7345   7682               //
  7346   7683               if (!whatIf)
  7347   7684               {
  7348   7685                   process.Start();
  7349   7686   
  7350   7687                   if (verbose)
         7688  +                {
  7351   7689                       TraceOps.DebugAndTrace(TracePriority.Highest,
  7352   7690                           debugCallback, traceCallback, String.Format(
  7353   7691                           "process = {0}", ForDisplay(process)),
  7354   7692                           traceCategory);
         7693  +                }
  7355   7694   
  7356   7695                   process.BeginOutputReadLine();
  7357   7696                   process.BeginErrorReadLine();
  7358   7697                   process.WaitForExit();
  7359   7698               }
  7360   7699   
  7361   7700               return true;
................................................................................
  7379   7718               //       This should force it to refresh its list of installed
  7380   7719               //       packages and their associated resources (i.e. this will
  7381   7720               //       effectively 'remove' the package being processed since
  7382   7721               //       this is being done after all the other changes for the
  7383   7722               //       package removal have been completed).
  7384   7723               //
  7385   7724               if (verbose)
         7725  +            {
  7386   7726                   TraceOps.DebugAndTrace(TracePriority.Highest,
  7387   7727                       debugCallback, traceCallback, String.Format(
  7388   7728                       "Preparing to run Visual Studio {0} 'setup' mode to " +
  7389   7729                       "refresh its configuration.", ForDisplay(vsVersion)),
  7390   7730                       traceCategory);
         7731  +            }
  7391   7732   
  7392   7733               return AddVsDevEnvSetup(
  7393   7734                   vsVersion, directory, perUser, whatIf, verbose, ref error);
  7394   7735           }
  7395   7736   
  7396   7737           ///////////////////////////////////////////////////////////////////////
  7397   7738