Esempio n. 1
0
        public void CloseAndDeleteOpenSolution()
        {
            IntegrationHelper.RetryDteCall(() => _dte.Documents.CloseAll(EnvDTE.vsSaveChanges.vsSaveChangesNo));

            if (IntegrationHelper.RetryDteCall(() => _dte.Solution) != null)
            {
                var directoriesToDelete = IntegrationHelper.RetryDteCall(() =>
                {
                    var directoryList = new List <string>();

                    // Save the full path to each project in the solution. This is so we can cleanup any folders after the solution is closed.
                    foreach (EnvDTE.Project project in _dte.Solution.Projects)
                    {
                        directoryList.Add(Path.GetDirectoryName(project.FullName));
                    }

                    // Save the full path to the solution. This is so we can cleanup any folders after the solution is closed.
                    // The solution might be zero-impact and thus has no name, so deal with that
                    if (!string.IsNullOrEmpty(_dte.Solution.FullName))
                    {
                        directoryList.Add(Path.GetDirectoryName(_dte.Solution.FullName));
                    }

                    return(directoryList);
                });

                IntegrationHelper.RetryDteCall(() => _dte.Solution.Close(SaveFirst: false));

                foreach (var directoryToDelete in directoriesToDelete)
                {
                    IntegrationHelper.TryDeleteDirectoryRecursively(directoryToDelete);
                }
            }
        }
Esempio n. 2
0
        internal async Task ExecuteDteCommandAsync(string command, string args = "")
        {
            // args is "" by default because thats what Dte.ExecuteCommand does by default and changing our default
            // to something more logical, like null, would change the expected behavior of Dte.ExecuteCommand

            await WaitForDteCommandAvailabilityAsync(command).ConfigureAwait(continueOnCapturedContext: false);

            IntegrationHelper.RetryDteCall(() => _dte.ExecuteCommand(command, args));
        }
Esempio n. 3
0
 internal Task <Window> LocateDteWindowAsync(string windowTitle)
 => IntegrationHelper.WaitForNotNullAsync(() => IntegrationHelper.RetryDteCall(() =>
 {
     foreach (Window window in _dte.Windows)
     {
         if (window.Caption.Equals(windowTitle, StringComparison.OrdinalIgnoreCase))
         {
             return(window);
         }
     }
     return(null);
 }));
Esempio n. 4
0
 private void CleanupRemotingService()
 {
     try
     {
         if ((IntegrationHelper.RetryDteCall(() => _dte?.Commands.Item(VisualStudioCommandNames.VsStopServiceCommand).IsAvailable).GetValueOrDefault()))
         {
             ExecuteDteCommandAsync(VisualStudioCommandNames.VsStopServiceCommand).GetAwaiter().GetResult();
         }
     }
     finally
     {
         if (_serviceChannel != null)
         {
             ChannelServices.UnregisterChannel(_serviceChannel);
         }
     }
 }
Esempio n. 5
0
        private void CleanupHostProcess()
        {
            IntegrationHelper.RetryDteCall(() => _dte.Quit());

            IntegrationHelper.KillProcess(_hostProcess);
        }
Esempio n. 6
0
 internal Task WaitForDteCommandAvailabilityAsync(string command)
 => IntegrationHelper.WaitForResultAsync(() => IntegrationHelper.RetryDteCall(() => Dte.Commands.Item(command).IsAvailable), expectedResult: true);