Example #1
0
 /// <summary>
 /// Documents a specific element.
 /// </summary>
 /// <param name="document">The TextDocument that contains the code.</param>
 /// <param name="element">The element to document.</param>
 private void DocumentElement(EnvDTE.TextDocument document, EnvDTE.CodeElement element)
 {
     EnvDTE.EditPoint startPoint;
     document.Selection.GotoLine(element.StartPoint.Line, true);
     startPoint = document.CreateEditPoint(document.Selection.ActivePoint);
     document.Selection.MoveToPoint(startPoint, true);
     window.SetFocus();
     window.DTE.ExecuteCommand("Tools.Submain.GhostDoc.DocumentThis", string.Empty);
 }
Example #2
0
 /// <summary>
 /// Performs the style task.
 /// </summary>
 /// <param name="projectItem">The project Item</param>
 /// <param name="ideWindow">The IDE window.</param>
 protected override void DoWork(ProjectItem projectItem, EnvDTE.Window ideWindow)
 {
     if (projectItem.Name.EndsWith(".cs"))
     {
         try
         {
             Debug.WriteLine("Formatting Document: " + projectItem.Name);
             ideWindow.SetFocus();
             ideWindow.DTE.ExecuteCommand("Edit.FormatDocument", string.Empty);
         }
         catch (Exception exc)
         {
             Debug.WriteLine(exc.ToString());
             Debug.WriteLine("Format failed, skipping");
         }
     }
 }
Example #3
0
 /// <summary>
 /// Performs the style task.
 /// </summary>
 /// <param name="projectItem">The project Item</param>
 /// <param name="ideWindow">The IDE window.</param>
 protected override void DoWork(ProjectItem projectItem, EnvDTE.Window ideWindow)
 {
     if (projectItem.Name.EndsWith(".cs"))
     {
         try
         {
             Debug.WriteLine("Running StyleCop: " + projectItem.Name);
             ideWindow.SetFocus();
             ideWindow.DTE.ExecuteCommand("Tools.RunStyleCop", string.Empty);
         }
         catch (Exception exc)
         {
             Debug.WriteLine(exc.ToString());
             Debug.WriteLine("StyleCop failed, skipping");
         }
     }
 }
        internal async Task CreateUnitTestAsync(IList <ProjectItemSummary> selectedFiles, bool addToProject = true)
        {
            var generationService = new TestGenerationService();
            var createdTestPaths  = new List <string>();

            foreach (ProjectItemSummary selectedFile in selectedFiles)
            {
                string generatedTestPath = await generationService.GenerateUnitTestFileAsync(
                    selectedFile,
                    this.SelectedProject.Project,
                    this.SelectedTestFramework,
                    this.SelectedMockFramework);

                createdTestPaths.Add(generatedTestPath);
            }

            if (addToProject)
            {
                bool focusSet = false;
                foreach (string createdTestPath in createdTestPaths)
                {
                    // Add the file to project
                    ProjectItem testItem = this.SelectedProject.Project.ProjectItems.AddFromFile(createdTestPath);

                    Window testWindow = testItem.Open(EnvDTE.Constants.vsViewKindCode);
                    testItem.ExpandView();
                    testWindow.Visible = true;

                    if (!focusSet)
                    {
                        testWindow.SetFocus();
                        focusSet = true;
                    }
                }

                StaticBoilerplateSettings.SaveSelectedTestProject(this.dte.Solution.FileName, this.SelectedProject.Project.FileName);
            }

            this.View?.Close();
        }
Example #5
0
        /// <summary>
        /// Performs the style task.
        /// </summary>
        /// <param name="projectItem">The project Item</param>
        /// <param name="ideWindow">The IDE window.</param>
        protected override void DoWork(ProjectItem projectItem, EnvDTE.Window ideWindow)
        {
            if (projectItem.Name.EndsWith(".cs") && !IsTemporarilyDisabled)
            {
                try
                {
                    if (errorDetectionFunction != null)
                    {
                        if (errorDetectionFunction())
                        {
                            IsTemporarilyDisabled = true;
                            return;
                        }
                    }

                    Debug.WriteLine("Removing and Sorting Usings on: " + projectItem.Name);

                    Stopwatch macroWatch = new Stopwatch();
                    macroWatch.Start();

                    ideWindow.SetFocus();
                    ideWindow.DTE.ExecuteCommand("Edit.RemoveAndSort", string.Empty);

                    macroWatch.Stop();
                    if (macroWatch.ElapsedMilliseconds > 1000)
                    {
                        if (System.Windows.Forms.MessageBox.Show("Remove and Sort usings seems to be having difficulties, do you want to skip it this iteration?", "Parole", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            IsTemporarilyDisabled = true;
                        }
                    }
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc.ToString());
                    Debug.WriteLine("Format failed, skipping");
                }
            }
        }