public async Task RunAsync(bool isDryRun)
        {
            try
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(_package.DisposalToken);

                var toolWindow = (BenchmarkTreeWindow)_package.FindToolWindow(typeof(BenchmarkTreeWindow), 0, false);
                BenchmarkTreeNode selectedNode = toolWindow.SelectedItem;

                var            dte2    = (DTE2)Package.GetGlobalService(typeof(SDTE));
                EnvDTE.Project project = GetProject(dte2, selectedNode.ProjectName);
                if (project == null)
                {
                    return;
                }

                var propertyProvider = await CreateProjectPropertyProviderAsync(project.Name);

                try
                {
                    if (!propertyProvider.IsOptimized)
                    {
                        await UIHelper.ShowErrorAsync(_package,
                                                      "The current build configuration does not have the \"Optimize code\" flag set and is therefore not suitable for running Benchmarks.\r\n\r\nPlease enable the the \"Optimize code\" flag (under Project Properties -> Build) or switch to a non-debug configuration (e.g. 'Release') before running a Benchmark.");

                        return;
                    }
                }
                catch (Exception)
                {
                }

                string configurationName = project.ConfigurationManager.ActiveConfiguration.ConfigurationName;
                dte2.Solution.SolutionBuild.BuildProject(configurationName, project.UniqueName, true);
                if (dte2.Solution.SolutionBuild.LastBuildInfo != 0)
                {
                    return;
                }

                var runParameters = new RunParameters
                {
                    OutputPath   = propertyProvider.OutputPath,
                    ProjectPath  = propertyProvider.ProjectPath,
                    Runtime      = propertyProvider.TargetRuntime,
                    AssemblyPath = propertyProvider.GetOutputFilename(),
                    IsDryRun     = isDryRun,
                    SelectedNode = selectedNode
                };
                BenchmarkRunController runController = new BenchmarkRunController(runParameters, GetOptions());
                await runController.RunAsync();
            }
            catch (Exception ex)
            {
                await UIHelper.ShowErrorAsync(_package, ex.Message);
            }
        }
Exemple #2
0
        private async void Execute(object sender, EventArgs e)
        {
            CodeEvaluationDTO codeEvaluation;

            try
            {
                codeEvaluation = await _service.AnalyzeCodeAsync(_selectedFilePath);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
                return;
            }

            ToolWindowPane window = _package.FindToolWindow(typeof(CodeAnalysisWindow), 0, true);

            if (window?.Frame == null)
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            var codeAnalysisWindow = window as CodeAnalysisWindow;

            codeAnalysisWindow?.UpdateVmContent(codeEvaluation);

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #3
0
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var window = (FunctionListWindow)package.FindToolWindow(typeof(FunctionListWindow), 0, true);

            Execute(window);
        }
        private void interfaceClassMapping(SchemaInfo schemaInfo, ClassInfo[] classInfos, Action <CodeClass[]> callbackOption)
        {
            ThreadHelper.ThrowIfNotOnUIThread("interfaceClassMapping");
            logger.Info("interfaceClassMapping called");
            ToolWindowPane toolWindowPane = package.FindToolWindow(typeof(InterfaceMapperWithClass), 0, create: true);

            if (toolWindowPane == null || toolWindowPane.Frame == null)
            {
                throw new NotSupportedException("Cannot create tool window");
            }
            interfaceMapperWithClassControl = (toolWindowPane.Content as InterfaceMapperWithClassControl);
            windowFrame            = (IVsWindowFrame)toolWindowPane.Frame;
            toolWindowPane.Caption = "Interface Class Mapper";
            ErrorHandler.ThrowOnFailure(windowFrame.Show());
            interfaceMapperWithClassControl.SetInterfaceMapperWithClassControlInput(new InterfaceMapperWithClassControlInput
            {
                ClassInfos     = classInfos,
                ProjectNames   = ClassFinder.FindProjects(dte.Solution),
                GetClasses     = ((Project project) => ClassFinder.FindProjectClass(project)),
                GetRefClasses  = ((Project project) => ClassFinder.FindProjectReferance(project)),
                CallbackOption = callbackOption,

                SchemaInfoCommon = schemaInfoCommon,
                Close            = () =>
                {
                    ThreadHelper.ThrowIfNotOnUIThread("interfaceClassMapping");
                    ErrorHandler.ThrowOnFailure(windowFrame.Hide());
                },
                ClearCache = () =>
                {
                    ClassFinder.ClearCache();
                },
                LastRunFound          = File.Exists(schemaInfo.FullMethodBasedUniqueName),
                CallbackLastRunOption = () =>
                {
                    var tempSchemaInfo = Json.Decode <SchemaInfo>(File.ReadAllText(schemaInfo.FullMethodBasedUniqueName));
                    fileCopyAndDebug(tempSchemaInfo);
                }
            });
        }
        private static void ShowToolWindow(AsyncPackage package)
        {
            ToolWindowPane window = package.FindToolWindow(typeof(RenameModalWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            ThreadHelper.ThrowIfNotOnUIThread();
            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #6
0
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var window = _package.FindToolWindow(typeof(SearchResultsToolWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            var windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #7
0
        private static void ShowToolWindow <T>(object sender, EventArgs e, AsyncPackage package)
        {
            ExLogger.LogToFile(Logger, $"{Resource.Message_OpeningToolWindow}: {typeof(T)}", LogLevel.Info);

            var window = package.FindToolWindow(typeof(T), 0, true);

            if (window?.Frame == null)
            {
                throw new NotSupportedException(Resource.ErrorMessage_CannotCreateToolWindow);
            }

            var windowFrame = (IVsWindowFrame)window.Frame;

            ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
        private void Execute(object sender, EventArgs e)
        {
            ThrowIfNotOnUIThread();

            // Get the instance number 0 of this tool window. This window is
            // single instance so this instance is actually the only one. The
            // last flag is set to true so that if the tool window does not
            // exists it will be created.
            var window = package.FindToolWindow(typeof(MainWindow), 0, true);

            Assumes.NotNull(window);
            Assumes.NotNull(window.Frame);
            var windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #9
0
        private void Execute(object sender, EventArgs e)
        {
            ToolWindowPane window = _package.FindToolWindow(typeof(ClosedDocumentsHistory), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                LoggerContext.Current.Logger.Error($"Command failed: {nameof(ShowDocumentsHIstoryCommand)} Cannot create tool window");
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

            LoggerContext.Current.Logger.Info($"VS Command: {nameof(ShowDocumentsHIstoryCommand)} was executed");
        }
Exemple #10
0
        // This is proper initialization since VS2017.
        //    For details see comment to GetAsyncToolWindowFactory() method.
        //private static void Execute(AsyncPackage package)
        //{
        //    package.JoinableTaskFactory.RunAsync(async () =>
        //    {
        //        ToolWindowPane window = await package.ShowToolWindowAsync(              // MISSING METHOD IN Microsoft.VisualStudio.Shell.14 in AsyncPackage class. Available since .15
        //            typeof(PBMWindow),
        //            0,
        //            create: true,
        //            cancellationToken: package.DisposalToken);
        //    });
        //}


        /// <summary>
        /// Shows "Parallel Builds Monitor" tool window when "VS -> Menu -> View -> Other Windows -> Parallel Builds Monitor" is clicked.
        /// </summary>
        private static void Execute(AsyncPackage package)
        {
            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            ToolWindowPane window = package.FindToolWindow(typeof(PBMWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #11
0
        private static ToolWindowPane ShowToolWindow(AsyncPackage package)
        {
            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            var window = package.FindToolWindow(typeof(BuildVisionPane), 0, true);

            if (window == null || window.Frame == null)
            {
                throw new InvalidOperationException(Resources.CanNotCreateWindow);
            }

            var windowFrame = (IVsWindowFrame)window.Frame;

            ErrorHandler.ThrowOnFailure(windowFrame.Show());
            return(window);
        }
Exemple #12
0
        private void Execute(object sender, EventArgs e)
        {
            ToolWindowPane window = _package.FindToolWindow(typeof(ChallengeWindow), 0, true);

            if (window?.Frame == null)
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            var challengeWindow = window as ChallengeWindow;

            challengeWindow?.UpdateVmContent(_selectedFilePath, _serverUrl);

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
        /// <summary>
        ///     Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ShowToolWindow(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            ToolWindowPane window = _Package.FindToolWindow(typeof(SmartTestsWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #14
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            var window = _package.FindToolWindow(typeof(NullForgivingToolWindow), 0, true);

            if (window?.Frame == null)
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            var windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #15
0
        public object CreateToolWindowForView(Type viewType, string caption)
        {
            IView view           = null;
            Type  toolWindowType = null;

            try
            {
                var id = _largestId;
                _largestId += 1; // this might cause a problem after this instance of VsToolWindowService has constructed its 2,147,483,647th tool window

                if (viewType == typeof(OutputView) || viewType == typeof(IOutputView))
                {
                    toolWindowType = typeof(OutputToolWindow);
                }

                ToolWindowPane window = _package.FindToolWindow(toolWindowType, id, create: true);
                if (window == null || window.Frame == null)
                {
                    throw new NotSupportedException("Cannot create tool window");
                }
                view           = window.Content as IView;
                window.Caption = caption;

                // give view a way to display its corresponding tool window
                view.DisplayView = () =>
                {
                    ThreadHelper.ThrowIfNotOnUIThread();
                    IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                    Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
                };

                return(view);
            }
            catch (Exception ex)
            {
                _logger.Error("VsToolWindowService tried to open a tool window of type {ViewType} but something went wrong: {ToolWindowDisplayException}", viewType, ex);
                return(view);
            }
        }
        private async Task ExecuteAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var token = await GetTokenAtCaretPositionAsync();

            ToolWindowPane window = _package.FindToolWindow(typeof(SearchResultsToolWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            var searchResultsToolWindow      = window as SearchResultsToolWindow;
            var searchResultsToolWindowFrame = window.Frame as IVsWindowFrame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(searchResultsToolWindowFrame.Show());

            var searchResultsToolWindowControl = searchResultsToolWindow.Content as SearchResultsToolWindowControl;

            searchResultsToolWindowControl.Search(token.ValueText);
        }
        public static void Prompt <TToolWindow>(AsyncPackage package, object dataContext = null, bool createIfNotExists = true)
            where TToolWindow : ToolWindowPane
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            ToolWindowPane window = package.FindToolWindow(typeof(TToolWindow), 0, createIfNotExists);

            if ((window == null) || (window.Frame == null))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            if (window.Content is UserControl control)
            {
                control.DataContext = dataContext;
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Exemple #18
0
        private void OnOpenAxoCover(object sender, EventArgs e)
        {
            var window = _package.FindToolWindow(typeof(TestExplorerToolWindow), 0, true);

            (window.Frame as IVsWindowFrame).ShowNoActivate();
        }