Ejemplo n.º 1
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 static void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            string message = $"Package: {_package.GetType().Name} inside {typeof(addNewTest).FullName}";

            Logger.Log(message);

            var regTestProj = new Regex(@"^*.\.Test$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            Project projUnitTest = ProjectHelpers.GetAllProjects()
                                   .Where(proj =>
            {
                try { return(regTestProj.IsMatch(proj.Name)); }
                catch { return(false); }
            })
                                   .Single();

            Logger.Log($"Test Project found: { projUnitTest.Name}");

            var selected = ProjectHelpers.GetSelectedItems();

            // find the test project
            Assumes.Present(projUnitTest);

            if (selected.Count() > 1)
            {
                Logger.Log($"Can only handle one selected Item");
            }

            Logger.Log(selected.First <ProjectItem>().Name);
            // assert there is a folder
            // asert test schema for {current item}
            // start new test template {projectName, path}
        }
Ejemplo n.º 2
0
        public static async Task UpdateAllSpritesAsync(bool isBuild = false)
        {
            foreach (Project project in ProjectHelpers.GetAllProjects())
            {
                if (project.ProjectItems.Count == 0)
                {
                    continue;
                }

                string folder = ProjectHelpers.GetRootFolder(project);

                if (string.IsNullOrEmpty(folder))
                {
                    continue;
                }

                SpriteImageMenu menu = new SpriteImageMenu();

                foreach (string file in Directory.EnumerateFiles(folder, "*.sprite", SearchOption.AllDirectories))
                {
                    if (ProjectHelpers.GetProjectItem(file) == null)
                    {
                        continue;
                    }

                    await menu.UpdateSpriteAsync(file, isBuild);
                }
            }
        }
        public void ProjectEnumerationTest()
        {
            var solutionService = VSHost.GetService <IVsSolution>(typeof(SVsSolution));

            Project project = ProjectHelpers.GetAllProjects().First(p => p.Name == "CS-Normal");

            IVsHierarchy projHierarchy;

            ErrorHandler.ThrowOnFailure(solutionService.GetProjectOfUniqueName(project.UniqueName, out projHierarchy));
            ErrorHandler.ThrowOnFailure(solutionService.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, projHierarchy, 0));

            // We target VS2013, which can only open WinStore
            // apps when running on Win8.1. Therefore, I skip
            // those projects when testing on older platforms
            var isWin81 = Type.GetType("Windows.UI.Xaml.Controls.Flyout, Windows.UI.Xaml, ContentType=WindowsRuntime", false) != null;

            ProjectHelpers.GetAllProjects()
            .Select(ProjectHelpers.GetRootFolder)
            .Select(f => f.TrimEnd('\\'))
            .Should()
            .BeEquivalentTo(
                Directory.EnumerateDirectories(Path.Combine(VSHost.FixtureDirectory, "ProjectEnumeration"))
                .Where(f => Path.GetFileName(f) != "CS-Normal" && Path.GetFileName(f) != "Debug")                       // Skip temp folder & unloaded project
                .Where(f => isWin81 || !f.Contains("WinStore"))
                );
        }
 public void IsWebProjectTest()
 {
     foreach (var project in ProjectHelpers.GetAllProjects())
     {
         project.IsWebProject().Should().Be(project.Name.StartsWith("Web") || project.Name.StartsWith("JS"),
                                            project.Name + " should be detected");
     }
 }
Ejemplo n.º 5
0
        private void HasStylesheet(object sender, System.EventArgs e)
        {
            OleMenuCommand menuCommand = sender as OleMenuCommand;
            bool           fileExist   = File.Exists(MarkdownMargin.GetCustomStylesheetFilePath());
            var            projects    = ProjectHelpers.GetAllProjects();

            menuCommand.Enabled = projects.Any() && !fileExist;
        }
Ejemplo n.º 6
0
        private void SolutionBeforeQueryStatus(object sender, System.EventArgs e)
        {
            OleMenuCommand menuCommand   = sender as OleMenuCommand;
            bool           settingsExist = XmlColorPaletteProvider.SolutionColorsExist;

            var projects = ProjectHelpers.GetAllProjects();

            menuCommand.Enabled = projects.Any() && !settingsExist;
        }
Ejemplo n.º 7
0
 public Task CompileSolutionAsync(IContentType contentType)
 {
     return(CompileFilesAsync(contentType,
                              ProjectHelpers.GetAllProjects()
                              .Select(ProjectHelpers.GetRootFolder)
                              .Where(p => !string.IsNullOrEmpty(p))
                              .SelectMany(p => Directory.EnumerateFiles(p, "*", SearchOption.AllDirectories))
                              ));
 }
Ejemplo n.º 8
0
        private void OnSolutionOpened()
        {
            var projects = ProjectHelpers.GetAllProjects();

            foreach (var project in projects)
            {
                EnsureProjectIsActive(project);
            }
        }
Ejemplo n.º 9
0
        ///<summary>Rescans all the entire graph from the source files in the current Visual Studio solution.</summary>
        ///<remarks>Although this method is async, it performs lots of synchronous work, and should not be called on a UI thread.</remarks>
        public Task RescanSolutionAsync()
        {
            var sourceFiles = ProjectHelpers.GetAllProjects()
                              .Select(ProjectHelpers.GetRootFolder)
                              .Where(p => !string.IsNullOrEmpty(p))
                              .SelectMany(p => Directory.EnumerateFiles(p, "*", SearchOption.AllDirectories))
                              .Where(f => extensions.Contains(Path.GetExtension(f)));

            return(RescanAllAsync(sourceFiles));
        }
Ejemplo n.º 10
0
        private void CompileSolution(object sender, EventArgs e)
        {
            var projects = ProjectHelpers.GetAllProjects();

            foreach (Project project in projects)
            {
                string config = project.GetConfigFile();

                if (!string.IsNullOrEmpty(config))
                {
                    CompilerService.Process(config);
                }
            }
        }
Ejemplo n.º 11
0
        private void UpdateSelectedBundle(object sender, EventArgs e)
        {
            var projects = ProjectHelpers.GetAllProjects();

            foreach (Project project in projects)
            {
                string config = project.GetConfigFile();

                if (!string.IsNullOrEmpty(config))
                {
                    BundleService.Process(config);
                }
            }
        }
Ejemplo n.º 12
0
        private void OnSolutionOpened()
        {
            try
            {
                var projects = ProjectHelpers.GetAllProjects();

                foreach (var project in projects)
                {
                    EnsureProjectIsActive(project);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Ejemplo n.º 13
0
        private void CompileSolution(object sender, EventArgs e)
        {
            var projects = ProjectHelpers.GetAllProjects();

            foreach (Project project in projects)
            {
                string folder  = Path.GetDirectoryName(project.GetRootFolder());
                var    configs = GetFiles(folder, Constants.CONFIG_FILENAME);

                foreach (string config in configs)
                {
                    if (!string.IsNullOrEmpty(config))
                    {
                        CompilerService.Process(config);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void UpdateSelectedBundle(object sender, EventArgs e)
        {
            var projects = ProjectHelpers.GetAllProjects();

            foreach (Project project in projects)
            {
                string folder  = Path.GetDirectoryName(project.GetRootFolder());
                var    configs = GetFiles(folder, Constants.CONFIG_FILENAME);

                foreach (string config in configs)
                {
                    if (!string.IsNullOrEmpty(config))
                    {
                        BundleService.Process(config);
                    }
                }
            }

            Telemetry.TrackEvent("VS update all bundles");
        }