Esempio n. 1
0
        private static bool NoInstallPathsFound(
            Visualizer visualizer,
            RegistryData registryData,
            out ICollection <Visualizer> targetVisualizers)
        {
            targetVisualizers = new List <Visualizer>();

            PopulatePre2017InstallPath(visualizer, registryData, targetVisualizers);
            TryGetPost2015InstallPaths(visualizer, registryData, targetVisualizers);

            return(targetVisualizers.Count == 0);
        }
Esempio n. 2
0
        private static void TryGetPost2015InstallPaths(
            Visualizer visualizer,
            RegistryData registryData,
            ICollection <Visualizer> targetVisualizers)
        {
            var relevantDataItems = registryData
                                    .VsPost2015Data
                                    .Where(d => d.IsValid && (d.VsFullVersionNumber == visualizer.VsFullVersionNumber));

            foreach (var dataItem in relevantDataItems)
            {
                targetVisualizers.Add(visualizer.With(dataItem.RegistryKey, dataItem.InstallPath));
            }
        }
Esempio n. 3
0
        private static IEnumerable <Visualizer> GetRelevantVisualizers()
        {
            using (var registryData = new RegistryData())
            {
                if (registryData.NoVisualStudio)
                {
                    return(Enumerable.Empty <Visualizer>());
                }

                return(_thisAssembly
                       .GetManifestResourceNames()
                       .WithExtension("dll")
                       .Select(visualizerResourceName => new Visualizer
                {
                    ResourceName = visualizerResourceName,
                    VsVersionNumber = GetVsVersionNumber(visualizerResourceName)
                })
                       .SelectMany(visualizer => PopulateInstallPaths(visualizer, registryData))
                       .ToArray());
            }
        }
Esempio n. 4
0
        private static bool NoVisualizersToInstall(out IEnumerable <Visualizer> visualizers, out string errorMessage)
        {
            using (var registryData = new RegistryData(_thisAssemblyVersion))
            {
                if (registryData.NoVisualStudio)
                {
                    visualizers  = Enumerable.Empty <Visualizer>();
                    errorMessage = registryData.ErrorMessage;
                    return(true);
                }

                visualizers = _thisAssembly
                              .GetManifestResourceNames()
                              .WithExtension("dll")
                              .Select(visualizerResourceName => new Visualizer(Log, _thisAssemblyVersion, VsixManifest, visualizerResourceName))
                              .SelectMany(visualizer => registryData.GetInstallableVisualizersFor(visualizer))
                              .ToArray();

                errorMessage = null;
                return(false);
            }
        }
Esempio n. 5
0
        private static void PopulatePre2017InstallPath(
            Visualizer visualizer,
            RegistryData registryData,
            ICollection <Visualizer> targetVisualizers)
        {
            var pre2017Key = registryData
                             .VsPre2017KeyNames
                             .FirstOrDefault(name => name == visualizer.VsFullVersionNumber);

            if (pre2017Key == null)
            {
                return;
            }

            var vsSubKey    = registryData.VsPre2017MachineKey.OpenSubKey(pre2017Key);
            var installPath = vsSubKey?.GetValue("InstallDir") as string;

            if (string.IsNullOrWhiteSpace(installPath) || !Directory.Exists(installPath))
            {
                return;
            }

            targetVisualizers.Add(visualizer.With(vsSubKey, installPath));
        }
Esempio n. 6
0
        private static IEnumerable <Visualizer> PopulateInstallPaths(Visualizer visualizer, RegistryData registryData)
        {
            if (NoInstallPathsFound(visualizer, registryData, out ICollection <Visualizer> targetVisualizers))
            {
                yield break;
            }

            foreach (var targetVisualizer in targetVisualizers)
            {
                using (targetVisualizer)
                {
                    var vsInstallPath          = targetVisualizer.VsInstallDirectory;
                    var indexOfIde             = vsInstallPath.IndexOf("IDE", StringComparison.OrdinalIgnoreCase);
                    var pathToCommon7          = vsInstallPath.Substring(0, indexOfIde);
                    var pathToVisualizers      = Path.Combine(pathToCommon7, "Packages", "Debugger", "Visualizers");
                    var visualizerAssemblyName = GetResourceFileName(targetVisualizer.ResourceName);
                    var pathToExtensions       = GetPathToExtensions(vsInstallPath);

                    targetVisualizer.InstallPath      = Path.Combine(pathToVisualizers, visualizerAssemblyName);
                    targetVisualizer.VsixManifestPath = Path.Combine(pathToExtensions, "extension.vsixmanifest");

                    PopulateVsSetupData(targetVisualizer);

                    yield return(targetVisualizer);
                }
            }
        }