Beispiel #1
0
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            Initialize();

            VSSolution vs = GetVSSolution(ns);

            if (vs == null)
            {
                return;
            }

            if (pc != null)
            {
                pc.ProjectCollection.UnloadAllProjects();
            }

            foreach (VSProject p in vs.projects)
            {
                if (File.Exists(p.FileName) == false)
                {
                    continue;
                }

                pc = p.LoadProjectToMemory();

                p.Shuffle(pc);
            }
            MockProject();
        }
Beispiel #2
0
        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            RichTextBox r = richTextBox1;

            LoadPanel(panel2);

            VSSolution vs = GetVSSolution(ns);

            ArrayList S = VSSolution.GetVSProjects(vs.solutionFileName);

            foreach (vsproject v in S)
            {
                string s = v.content;

                string[] cc = s.Split("\n".ToCharArray());

                r.AppendText(cc[0] + "\n");

                string n = v.name.Replace("\"", "");

                n = n.Trim();

                v.name = v.name.Replace(n, '_' + n);

                v.file = v.file.Replace(n + ".", '_' + n + ".");

                string g = v.GetProject();

                r.AppendText(g + "\n");

                g = v.ModifyProject(g);

                r.AppendText(g + "\n");
            }
        }
Beispiel #3
0
        public static void TargetCleanOutput(ITaskContext context)
        {
            string buildConfiguration = context.Properties.Get <string>(BuildProps.BuildConfiguration);
            string productRootDir     = context.Properties.Get(BuildProps.ProductRootDir, ".");

            VSSolution solution = context.Properties.Get <VSSolution>(BuildProps.Solution);

            solution.ForEachProject(
                delegate(VSProjectInfo projectInfo)
            {
                if (projectInfo is VSProjectWithFileInfo)
                {
                    VSProjectWithFileInfo info = (VSProjectWithFileInfo)projectInfo;

                    LocalPath projectOutputPath = info.GetProjectOutputPath(buildConfiguration);

                    if (projectOutputPath == null)
                    {
                        return;
                    }

                    FullPath projectFullOutputPath = info.ProjectDirectoryPath.CombineWith(projectOutputPath);
                    DeleteDirectoryTask.Execute(context, projectFullOutputPath.ToString(), false);

                    string projectObjPath = String.Format(
                        CultureInfo.InvariantCulture,
                        @"{0}\obj\{1}",
                        projectInfo.ProjectName,
                        buildConfiguration);
                    projectObjPath = Path.Combine(productRootDir, projectObjPath);
                    DeleteDirectoryTask.Execute(context, projectObjPath, false);
                }
            });
        }
Beispiel #4
0
        public void LoadProjects(VSSolution _vs)
        {
            vs = _vs;

            cb.Items.Clear();

            cc.Items.Clear();

            foreach (VSProject p in vs.Projects)
            {
                cb.Items.Add(p.Name, false);

                cc.Items.Add(p.Name);
            }
            GetDependencyOrder();

            foreach (int pp in R)
            {
                string name = "";
                foreach (KeyValuePair <string, int> pair in dict)
                {
                    if (pp.Equals(pair.Value))
                    {
                        name = pair.Key;
                    }
                }

                lb.Items.Add(name);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Get's Visual studio solution information. if <see cref="solutionFileName"/> is not specified solution file name is readed from <see cref="IBuildPropertiesContext"/> property <see cref="BuildProps.SolutionFileName"/>
        /// </summary>
        /// <param name="context"></param>
        /// <param name="solutionFileName"></param>
        /// <returns></returns>
        public static VSSolution GetVsSolution(this ITaskContext context, string solutionFileName = null)
        {
            VSSolution solution     = null;
            bool       saveSolution = true;

            if (string.IsNullOrEmpty(solutionFileName))
            {
                solutionFileName = context.Properties.TryGet <string>(BuildProps.SolutionFileName);
                solution         = context.Properties.TryGet <VSSolution>(BuildProps.Solution);
            }
            else
            {
                saveSolution = false;
            }

            if (solution == null)
            {
                solution = context.Tasks().LoadSolutionTask(solutionFileName).DoNotFailOnError().Execute(context);
            }

            if (saveSolution)
            {
                context.Properties.Set(BuildProps.Solution, solution);
            }

            return(solution);
        }
Beispiel #6
0
        private void AutomaticallyUpdateProjects(VSSolution sourceSolution, VSSolution destinationSolution)
        {
            ReferenceCopierViewModel viewmodel = new ReferenceCopierViewModel();

            string sourceDirectory      = FileManager.GetDirectory(sourceSolution.FullFileName);
            string destinationDirectory = FileManager.GetDirectory(destinationSolution.FullFileName);

            string strippedDestinationSolutionName = FileManager.RemovePath(destinationSolution.FullFileName);

            foreach (var sourceProject in sourceSolution.ReferencedProjects)
            {
                var strippedSource = FileManager.RemovePath(sourceProject);

                var found = destinationSolution.ReferencedProjects.FirstOrDefault(item =>
                                                                                  FileManager.RemovePath(item) == strippedSource);



                if (found != null)
                {
                    ViewModel.FromFile = FileManager.RemoveDotDotSlash(sourceDirectory + sourceProject);
                    ViewModel.ToFile   = FileManager.RemoveDotDotSlash(destinationDirectory + found);

                    ViewModel.PerformCopy(showPopup: false);

                    PluginManager.ReceiveOutput($"Copied references for project {strippedSource} in {strippedDestinationSolutionName}.");
                }
                else
                {
                    PluginManager.ReceiveOutput($"Skipping project {strippedSource} because a matching project was not found in {strippedDestinationSolutionName}");
                }
            }
        }
Beispiel #7
0
        public static List <MethodDeclarationSyntax> MethodMembers(VSSolution vs, SyntaxTree syntaxTree)
        {
            var c = syntaxTree.GetRoot().DescendantNodes().OfType <MethodDeclarationSyntax>().ToList();

            c.Reverse();
            StringBuilder br      = new StringBuilder();
            string        content = syntaxTree.ToString();

            if (content.IndexOf("References") >= 0)
            {
                return(c);
            }
            br.Append(content);
            foreach (var b in c)
            {
                int    index  = content.LastIndexOf("\n", b.SpanStart);
                string margin = "";
                if (index >= 0)
                {
                    //margin = content.Substring(index, b.SpanStart - index);
                    index++;
                }
                else
                {
                    index = b.SpanStart;
                }
                br.Insert(index, "//References - \n" + margin);
            }
            SyntaxTree s = CSharpSyntaxTree.ParseText(br.ToString(), CSharpParseOptions.Default, syntaxTree.FilePath);

            vs.UpdateSyntaxTree(syntaxTree.FilePath, s.ToString());
            c = s.GetRoot().DescendantNodes().OfType <MethodDeclarationSyntax>().ToList();
            return(c);
        }
Beispiel #8
0
        /// <summary>
        /// Calculates the loc for the whole solution.
        /// </summary>
        /// <param name="solutionFileName">Name of the solution file.</param>
        public void CalculateLocForSolution(string solutionFileName)
        {
            //VSSolutionLocMetrics metrics = new VSSolutionLocMetrics();

            //Load the solution, appropriate projects and their compile items.
            VSSolution solution = VSSolution.Load(solutionFileName);

            solution.LoadProjects();

            foreach (VSProjectInfo projectInfo in solution.Projects)
            {
                //just C# projects
                if (projectInfo.ProjectTypeGuid != VSProjectType.CSharpProjectType.ProjectTypeGuid)
                {
                    continue;
                }

                //Calculate the metrics for each containing project.
                VSProjectLocMetrics projectMetrics = VSProjectLocMetrics.CalculateLocForProject(
                    (VSProjectWithFileInfo)projectInfo,
                    locStatsMap);
                this.AddLocMetrics(projectMetrics);
            }

            locCalculated = true;
        }
Beispiel #9
0
        void test1()
        {
            string     sol_file  = @"\\svigi-11\e$\Webs\DotNetDes\ECI.Config\ECI.Applications\MergeSystem.Indexus.Service\Logs\NAnt\NAntBuild00002\MergeSystem.Indexus.Service.sln";
            string     sol_file2 = @"C:\Development\Instalador\2.0\DotNet\dotNET.Deploy\dotNET.Deploy.sln";
            VSSolution solution  = VSSolution.Load(sol_file);

            solution.LoadProjects();


            if (solution != null)
            {
                if (solution.Projects != null)
                {
                    foreach (VSProjectWithFileInfo info in solution.Projects)
                    {
                        info.Project = VSProject.Load(info.ProjectFileNameFull);
                        foreach (VSProjectItem item in info.Project.Items)
                        {
                            Console.WriteLine(item.ItemType.ToString());
                            Console.WriteLine(item.Item);
                            foreach (string key in item.ItemProperties.Keys)
                            {
                                Console.WriteLine(item.ItemProperties[key]);
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        private void C_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (syntaxTree == null)
            {
                return;
            }
            var b = syntaxTree.GetRoot().DescendantNodes().OfType <InvocationExpressionSyntax>().ToList();

            foreach (InvocationExpressionSyntax es in b)
            {
                if (es.Expression is MemberAccessExpressionSyntax)
                {
                    MemberAccessExpressionSyntax sa = es.Expression as MemberAccessExpressionSyntax;
                    string name   = sa.Name.ToString();
                    string member = sa.Expression.ToString();
                }
            }
            //var c = syntaxTree.GetRoot().DescendantNodes().OfType<MemberDeclarationSyntax>().ToList();

            //foreach (MemberDeclarationSyntax es in c)
            //{
            //}

            XElement xe = Roslyn.SyntaxVisualizer.DgmlHelper.SyntaxDgmlHelper.ToDgml(syntaxTree.GetRoot());

            VSSolution.OpenSyntaxGraphTool(xe);
        }
Beispiel #11
0
        public void AddVSSolution(VSSolution vs)
        {
            string repoPath = Path.GetDirectoryName(vs.solutionFileName);

            using (var repo = new Repository(repoPath))
            {
                foreach (VSProject vp in vs.projects)
                {
                    var compileItems = vp.GetCompileItems();
                    foreach (string file in compileItems)
                    {
                        repo.Index.Stage(file);
                    }
                }

                var author = new Signature("author.Name", "author.Email", DateTime.Now);

                const string shortMessage  = "Initial VE-Explorer commit";
                const string commitMessage = shortMessage + "\n\nVE-Explorer";

                Commit commit = repo.Commit(commitMessage, author, author);

                Branch firstCommitBranch = repo.Branches["master"];
                repo.Checkout(firstCommitBranch);
            }
        }
Beispiel #12
0
        public static ArrayList GetProjectPlatform(VSSolution vs)
        {
            ArrayList L = new ArrayList();

            if (vs == null)
            {
                return(L);
            }

            L = vs.GetSolutionPlatforms();

            ArrayList P = new ArrayList();

            foreach (string s in L)
            {
                string[] cc = s.Split("|".ToCharArray());

                if (cc.Length < 1)
                {
                    continue;
                }
                if (cc.Length == 2)
                {
                    if (P.IndexOf(cc[1]) < 0)
                    {
                        P.Add(cc[1]);
                    }
                }
            }

            P.Add("Configuration Manager");

            return(P);
        }
Beispiel #13
0
        public void MockProject()
        {
            ArrayList S = VSSolution.GetVSProjects(vs.solutionFileName);

            string content = File.ReadAllText(vs.solutionFileName);

            foreach (vsproject v in S)
            {
                v.content = content;

                string n = v.name.Replace("\"", "");

                n = n.Trim();

                v.name = v.name.Replace(n, '_' + n);

                v.file = v.file.Replace(n + ".", '_' + n + ".");

                string g = v.GetProject();

                g = v.ModifyProject(g);

                content = g;
            }

            string file = vs.solutionFileName;

            string name = Path.GetFileName(file).Trim();

            file = file.Replace(name, "_" + name);

            File.WriteAllText(file, content);
        }
Beispiel #14
0
        public static void Run(ModuleCollection[] collections)
        {
            // Load all compilation configs
            VSFullConfiguration[] configs = BuildStatics.GetVSFullConfigurations();
            RecipeTarget[]        recipes = new RecipeTarget[configs.Length];
            for (int i = 0; i < configs.Length; ++i)
            {
                recipes[i] = configs[i].AsRecipeTarget();
            }

            // Make sure all recipes are loaded
            foreach (ModuleCollection collection in collections)
            {
                collection.LoadModuleRecipes(recipes);
            }


            // Resolve all dependencies
            RecipeCollection.ResolveModuleDependencies(recipes, collections);


            // Create solution and project files
            VSSolution solution = new VSSolution(collections);

            solution.LoadProjects();
            VSSolutionIO.WriteAllDetails(solution, configs);
        }
Beispiel #15
0
        private void V3_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem b = sender as TreeViewItem;

            if (b == null)
            {
                return;
            }
            SourceRefData source = b.Tag as SourceRefData;

            if (source == null)
            {
                return;
            }
            VSSolution vs = editorWindow.vs;

            var references = vs.FindReferences(source.Offset, source.FileName);

            if (references == null)
            {
                return;
            }

            b.Items.Clear();

            b.Header = "Calls to " + source.name;

            FindNextCalls(references.ToList(), b);

            e.Handled = true;
        }
Beispiel #16
0
        protected override void ProcessRecord()
        {
            //string file = Path.GetFullPath("F:\\Application\\MSBuildProjects-new\\VStudio.sln");

            string file = Path.GetFullPath(SolutionFile);

            if (!File.Exists(file))
            {
                throw new FileNotFoundException("File does not exist.", file);
            }

            TreeView b = VSParsers.VSExplorer.LoadProject(file, Folder);

            if (b != null)
            {
                WriteObject("Project contains " + b.Nodes[0].Nodes.Count + " nodes");
            }
            else
            {
                WriteObject("Project did not open properly");
                return;
            }
            CreateView_Solution.ProjectItemInfo p = b.Nodes[0].Nodes[0].Tag as CreateView_Solution.ProjectItemInfo;
            if (p == null)
            {
                WriteObject("VSSolution tag not found");
                return;
            }
            else
            {
                WriteObject("VSSolution tag found");
            }
            VSSolution vs = p.vs;

            if (vs == null)
            {
                WriteObject("VSSolution not found");
                return;
            }
            else
            {
                WriteObject("VSSolution found");
            }
            VSProject vp = vs.GetProjectbyName(ProjectName);

            if (vp == null)
            {
                WriteObject("VSProject not found");
                return;
            }
            else
            {
                WriteObject("VSProject found");
            }

            vp.SetReference(PackageName);

            WriteObject("Completed....");
        }
Beispiel #17
0
 private void Ef_event_SelectedSolutionChanged(object sender, VSSolution vs)
 {
     if (vs == null)
     {
         return;
     }
     this.BeginInvoke(new Action(() => { /*LoadComponents();*/ }));
 }
        private VSSolution GetMainSolution()
        {
            string mainSln = ProjectSyncer.LocateSolution(GlueState.Self.CurrentMainProject.FullFileName);

            var solution = VSSolution.FromFile(mainSln);

            return(solution);
        }
Beispiel #19
0
        private VSSolution GetMainSolution()
        {
            var mainSln = GlueState.Self.CurrentSlnFileName;

            var solution = VSSolution.FromFile(mainSln);

            return(solution);
        }
Beispiel #20
0
        public List <INamespaceOrTypeSymbol> ProjectTypes(VSSolution vs)
        {
            string FileName = ProjectToLoad;

            string filename = FileToLoad;

            typesofproject = vs.ProjecTypes(filename);

            return(typesofproject);
        }
Beispiel #21
0
        public void Load(string filename, VSSolution vs)
        {
            if (vs == null)
            {
                return;
            }
            SyntaxTree syntaxTree = vs.GetSyntaxTree(filename);

            dv.LoadSyntaxTree(syntaxTree);
        }
Beispiel #22
0
        private void HandleAutomaticallyCopyClick(object sender, RoutedEventArgs e)
        {
            VSSolution        mainSolution    = GetMainSolution();
            List <VSSolution> syncedSolutions = GetSyncedSolutions();

            foreach (var solution in syncedSolutions)
            {
                AutomaticallyUpdateProjects(mainSolution, solution);
            }
        }
Beispiel #23
0
        public void LoadProjects_MixedProjects()
        {
            VSSolution solution = VSSolution.Load(@"TestData/SolutionWithProjects.sln");

            solution.LoadProjects();

            var coreProjects = solution.Projects.Where(i => i.ProjectDetails.IsNetCoreProjectType).ToList();

            Assert.Equal(2, coreProjects.Count);
        }
Beispiel #24
0
        public void CheckIfCompileItemsArePresentInSolutionExplorerTree(TreeView v)
        {
            Microsoft.Build.Evaluation.Project pc = null;

            TreeNode b = v.Nodes[0];

            VSSolution vs = v.Tag as VSSolution;

            // Assert.IsNotNull(b);

            // Assert.IsNotNull(vs);

            if (vs == null)
            {
                return;
            }

            foreach (VSProject p in vs.projects)
            {
                if (p.ProjectType == "SolutionFolder")
                {
                    continue;
                }

                pc = p.LoadProjectToMemory();
                GetSubTypes(pc, p);

                VSParsers.msbuilder_alls bb = new VSParsers.msbuilder_alls();

                TreeNode node = bb.GetProjectNode(b, p);

                //   Assert.That(node, Is.Not.Null);

                int i = 0;
                foreach (string s in dict.Keys)
                {
                    ArrayList L = dict[s];

                    foreach (Microsoft.Build.Evaluation.ProjectItem pp in L)
                    {
                        string type    = pp.ItemType;
                        string include = pp.EvaluatedInclude;

                        TreeNode ng = bb.FindNodesIncludes(node, include);

                        //Assert.That(ng, Is.Not.Null);

                        if (ng != null)
                        {
                            i++;
                        }
                    }
                }
            }
        }
Beispiel #25
0
        public void LoadSolution_OldCsprojAndNewCsproj_Succesfull()
        {
            var solution = VSSolution.Load(@"TestData/Test.sln");

            Assert.Equal(11, solution.Projects.Count);
            Assert.Equal(12, solution.SolutionVersion);
            Assert.Equal("Hsl.Simobil.SelfCare.WebApi", solution.Projects[0].ProjectName);
            Assert.Equal("9a19103f-16f7-4668-be54-9a1e7a4f7556", solution.Projects[0].ProjectTypeGuid.ToString());
            Assert.Equal("213084f6-184a-47ee-95ae-db0f537671ed", solution.Projects[0].ProjectGuid.ToString());
            Assert.Equal("Comtrade.A1.SelfCare.Core.Tests", solution.Projects[1].ProjectName);
        }
        public void CheckSolutionFiles()
        {
            VSSolution solution = VSSolution.Load(@"..\..\..\ProjectPilot.sln");

            VSProjectInfo project = solution.FindProjectByName("Samples");

            Assert.IsInstanceOfType(typeof(VSSolutionFilesInfo), project);
            VSSolutionFilesInfo solutionFilesInfo = (VSSolutionFilesInfo)project;

            Assert.AreEqual(18, solutionFilesInfo.Files.Count);
        }
Beispiel #27
0
        async public void OpenFile(string file, CountdownEvent e)
        {
            AutoResetEvent are = new AutoResetEvent(false);

            ef.Invoke(new Action(() => ef.Command_OpenFile(file, e)));
            await Task.Run(() => are.WaitOne());

            VSSolution       vs  = ef.GetVSSolution();
            ManualResetEvent mre = vs.SynchronizedEventForCompileFile(file);

            Task.Run(() => mre.WaitOne()).Wait();
        }
Beispiel #28
0
        public static FullPath GetProjectOutputPath(this ITaskContext context, string projectName)
        {
            VSSolution            solution    = context.Properties.Get <VSSolution>(BuildProps.Solution);
            VSProjectWithFileInfo projectInfo =
                (VSProjectWithFileInfo)solution.FindProjectByName(projectName);

            LocalPath projectOutputPath = projectInfo.GetProjectOutputPath(
                context.Properties.Get <string>(BuildProps.BuildConfiguration));
            FullPath projectTargetDir = projectInfo.ProjectDirectoryPath.CombineWith(projectOutputPath);

            return(projectTargetDir);
        }
        public void LoadSolution()
        {
            VSSolution solution = VSSolution.Load(@"..\..\..\ProjectPilot.sln");

            solution.ForEachProject(delegate(VSProjectInfo projectInfo)
            {
                VSProjectType projectType = solution.ProjectTypesDictionary.FindProjectType(projectInfo.ProjectTypeGuid);
                System.Console.Out.WriteLine(
                    "{0} ({1})",
                    projectInfo.ProjectName,
                    projectType.ProjectTypeName);
            });
        }
Beispiel #30
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (Results == null)
            {
                return;
            }
            if (ef == null)
            {
                return;
            }
            if (ef.scr == null)
            {
                return;
            }

            int bb = comboBox2.SelectedIndex;

            if (bb == 2)
            {
                ScriptControl.ScriptControl scr = ef.scr;

                ArrayList L = ToLinesProject(Results);

                AvalonDocument doc = ef.scr.GetActiveDocument();

                string filename = doc.FileName;

                VSSolution vs = ef.GetVSSolution();

                VSProject vp = vs.GetProjectbyFileName(filename);

                scr.BookmarkAll(filename, vp, L);
            }
            else if (bb == 3)
            {
                ScriptControl.ScriptControl scr = ef.scr;

                ArrayList L = ToLinesProject(Results);

                AvalonDocument doc = ef.scr.GetActiveDocument();

                string filename = doc.FileName;

                VSSolution vs = ef.GetVSSolution();

                VSProject vp = vs.MainVSProject;

                scr.BookmarkAll(vp, L);
            }
        }