Esempio n. 1
0
 /// <summary>
 /// Returns a <see cref="string"/> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="string"/> representation of this instance. The format strings can be changed in the
 /// Resources.resx resource file at the key 'SolutionToString', 'SolutionProjects' and
 /// 'SolutionProjectDependencies'.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// The format string was a <see langword="null"/>.
 /// </exception>
 /// <exception cref="FormatException">
 /// An index from the format string is either less than zero or greater than or equal to the number of arguments.
 /// </exception>
 public override string ToString()
 {
     return(String.Format(
                Resources.Solution_ToString,
                Environment.NewLine,
                '\t',
                Name,
                FileName,
                SolutionProjects.Any()
             ? SolutionProjects.Aggregate(
                    String.Empty,
                    (t, p) => string.Format(
                        "{0}{1}{2}{2}{3}",
                        t,
                        Environment.NewLine,
                        '\t',
                        p))
             : "None",
                SolutionProjectDependencies.Any()
             ? SolutionProjectDependencies.Aggregate(
                    String.Empty,
                    (t, p) =>
                    string.Format(
                        "{0}{1}{2}{2}{3}:{4}",
                        t,
                        Environment.NewLine,
                        '\t',
                        p.Solution.Name,
                        p.ProjectName))
             : "None"));
 }
Esempio n. 2
0
        public ProjectGraphNode AddNode(ProjectGraphNode node, bool isSolutionProject)
        {
            AllNodes[node.ToString()] = node;
            if (isSolutionProject)
            {
                SolutionProjects.Add(node);
            }

            return(node);
        }
Esempio n. 3
0
        public ProjectGraphNode GetOrAdd(Project project, bool isSolutionProject)
        {
            var node = AllNodes.TryGet(project.FullPath) ??
                       AddNode(new ProjectGraphNode(project, this), isSolutionProject);

            if (isSolutionProject && !SolutionProjects.Contains(node))
            {
                SolutionProjects.Add(node);
            }

            return(node);
        }
Esempio n. 4
0
        static StructurePlatformConventionsTest()
        {
            SolutionDir = Path.GetDirectoryName(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath));
            PackagesDir = ".." + Path.DirectorySeparatorChar + "packages" + Path.DirectorySeparatorChar;

            SolutionProjects     = Directory.GetDirectories(SolutionDir, $"{SolutionName}.*").ToArray();
            SolutionCodeProjects = SolutionProjects.Where(p => !p.EndsWith(".Tests")).ToArray();
            SolutionTestProjects = SolutionProjects.Where(p => p.EndsWith(".Tests")).ToArray();

            ProjectNamespace = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");

            Console.WriteLine(@"SolutionDir={0}", SolutionDir);
        }
Esempio n. 5
0
        /// <summary>
        /// Handler called whenever active solution is closed.
        /// </summary>
        private void solutionClosed()
        {
            _wasSolutionClosed = true;
            //changes can be omitted
            _changes.Clear();

            //all projects are also closed
            var projectsCopy = SolutionProjects.ToArray();

            foreach (var project in projectsCopy)
            {
                onProjectRemoved(project);
            }

            if (SolutionClosed != null)
            {
                SolutionClosed();
            }
        }
Esempio n. 6
0
 public MainWindow()
 {
     InitializeComponent();
     dataGrid.ItemsSource = SolutionProjects.GetProjects();
     BtnGo.Click         += BtnGo_Click;
 }
        private async Task ExecuteAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsStatusbar statusBar = (IVsStatusbar)await ServiceProvider.GetServiceAsync(typeof(SVsStatusbar));

            Assumes.Present(statusBar);

            DTE dte = (DTE)await ServiceProvider.GetServiceAsync(typeof(DTE));

            Assumes.Present(dte);
            var uri = new Uri(typeof(PrQuantifierExtendMenuPackage).Assembly.CodeBase, UriKind.Absolute);

            documentEvents = dte.Events.DocumentEvents;
            documentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

            var projects = SolutionProjects.Projects();

            while (true)
            {
                if ((runPrQuantifierDateTime == changedEventDateTime &&
                     runPrQuantifierDateTime != default) ||
                    projects.Count() == 0)
                {
                    await Task.Delay(TimeSpan.FromMilliseconds(500));

                    // refresh projects list in case is still empty
                    if (projects.Count() == 0)
                    {
                        projects = SolutionProjects.Projects();
                    }

                    continue;
                }

                try
                {
                    using var process = new System.Diagnostics.Process()
                          {
                              StartInfo = new ProcessStartInfo
                              {
                                  RedirectStandardOutput = true,
                                  CreateNoWindow         = true,
                                  UseShellExecute        = false,
                                  FileName  = Path.Combine(Path.GetDirectoryName(uri.LocalPath), @"PrQuantifier\PullRequestQuantifier.Local.Client.exe"),
                                  Arguments = $"-GitRepoPath \"{projects.ElementAt(0).FullName}\" -output Detailed"
                              }
                          };

                    process.Start();
                    Print(statusBar, await ReadOutputAsync(process));

                    if (changedEventDateTime == default)
                    {
                        changedEventDateTime = DateTimeOffset.Now;
                    }

                    runPrQuantifierDateTime = changedEventDateTime;
                }
                catch (Exception ex)
                {
                    statusBar.SetText($"PrQuantifier extension has encountered an error, please report it to ... Exception {ex.Message}");
                    return;
                }
            }
        }