Exemple #1
0
 void RemoveItemFromSolution(SD.SolutionItem item)
 {
     SD.ProjectSection section = GetExtensibilityGlobalsSection();
     section.Items.Remove(item);
     nonPersistedSolutionItems.Add(item);
     solution.Save();
 }
Exemple #2
0
        public void VariableValue_SetNewValueForVariableWhenExtensibilityGlobalsDoesNotExist_ExtensibilityGlobalsSectionCreated()
        {
            CreateSolution();

            globals.set_VariableValue("test", "new-value");

            SD.ProjectSection section = GetExtensibilityGlobalsSection();
            Assert.IsNull(section);
        }
Exemple #3
0
 SD.SolutionItem GetItemFromSolution(string name)
 {
     SD.ProjectSection section = GetExtensibilityGlobalsSection();
     if (section != null)
     {
         return(GetMatchingSolutionItem(section.Items, name));
     }
     return(null);
 }
Exemple #4
0
        public void VariablePersists_SetToTrueAfterNewVariableAdded_ExtensibilityGlobalsSectionAddedWithPostSolutionType()
        {
            CreateSolution();
            globals.set_VariableValue("test", "new-value");

            globals.set_VariablePersists("test", true);

            SD.ProjectSection section = GetExtensibilityGlobalsSection();
            Assert.AreEqual("postSolution", section.SectionType);
        }
Exemple #5
0
        SD.ProjectSection GetOrCreateExtensibilityGlobalsSection()
        {
            SD.ProjectSection section = GetExtensibilityGlobalsSection();
            if (section != null)
            {
                return(section);
            }
            var newSection = new SD.ProjectSection(ExtensibilityGlobalsSectionName, "postSolution");

            solution.Sections.Add(newSection);
            return(newSection);
        }
Exemple #6
0
        internal void AddItemToSolution(string name)
        {
            if (ItemExistsInSolution(name))
            {
                return;
            }

            SD.SolutionItem item = GetNonPersistedSolutionItem(name);
            nonPersistedSolutionItems.Remove(item);
            SD.ProjectSection section = GetOrCreateExtensibilityGlobalsSection();
            section.Items.Add(item);
            solution.Save();
        }
Exemple #7
0
        public void VariablePersists_SetPersistToTrueTwice_VariableAddedToSolutionOnce()
        {
            CreateSolution();
            globals.set_VariableValue("test", "one");

            globals.set_VariablePersists("test", true);
            globals.set_VariablePersists("test", true);

            SD.ProjectSection section = GetExtensibilityGlobalsSection();
            int count = section.Items.Count;

            Assert.AreEqual(1, count);
        }
		static ProjectSection ReadSection(TextReader sr, string name, string sectionType, string endTag)
		{
			ProjectSection newFolder = new ProjectSection(name, sectionType);
			while (true) {
				string line = sr.ReadLine();
				if (line == null || line.Trim() == endTag) {
					break;
				}
				Match match = sectionPattern.Match(line);
				if (match.Success) {
					newFolder.Items.Add(new SolutionItem(match.Result("${Key}"), match.Result("${Value}")));
				}
			}
			return newFolder;
		}
 /// <summary>
 /// Reads project sections from the TextReader until the line "EndProject" is found and saves
 /// them into the specified sectionList.
 /// </summary>
 public static void ReadProjectSections(TextReader sr, ICollection <ProjectSection> sectionList)
 {
     while (true)
     {
         string line = sr.ReadLine();
         if (line == null || line.Trim() == "EndProject")
         {
             break;
         }
         Match match = sectionHeaderPattern.Match(line);
         if (match.Success)
         {
             sectionList.Add(ProjectSection.ReadProjectSection(sr, match.Result("${Name}"), match.Result("${Type}")));
         }
     }
 }
        static ProjectSection ReadSection(TextReader sr, string name, string sectionType, string endTag)
        {
            ProjectSection newFolder = new ProjectSection(name, sectionType);

            while (true)
            {
                string line = sr.ReadLine();
                if (line == null || line.Trim() == endTag)
                {
                    break;
                }
                Match match = sectionPattern.Match(line);
                if (match.Success)
                {
                    newFolder.Items.Add(new SolutionItem(match.Result("${Key}"), match.Result("${Value}")));
                }
            }
            return(newFolder);
        }
Exemple #11
0
			public void SetProjectConfigurationPlatform(ProjectSection section, string newConfiguration, string newPlatform)
			{
				this.Configuration = newConfiguration;
				this.Platform = newPlatform;
				if (this.SolutionItem == null)
					return;
				this.SolutionItem.Location = newConfiguration + "|" + newPlatform;
				string thisName = this.SolutionItem.Name;
				if (StripBuild0(ref thisName)) {
					thisName += ".ActiveCfg";
					foreach (SolutionItem item in section.Items) {
						if (item.Name == thisName)
							item.Location = this.SolutionItem.Location;
					}
				}
			}
Exemple #12
0
			public void SetSolutionConfigurationPlatform(ProjectSection section, string newConfiguration, string newPlatform)
			{
				if (this.SolutionItem == null)
					return;
				string oldName = this.SolutionItem.Name;
				this.SolutionItem.Name = this.Project.IdGuid + "." + newConfiguration + "|" + newPlatform + ".Build.0";
				string newName = this.SolutionItem.Name;
				if (StripBuild0(ref oldName) && StripBuild0(ref newName)) {
					oldName += ".ActiveCfg";
					newName += ".ActiveCfg";
					foreach (SolutionItem item in section.Items) {
						if (item.Name == oldName)
							item.Name = newName;
					}
				}
			}
		SD.ProjectSection GetOrCreateExtensibilityGlobalsSection()
		{
			SD.ProjectSection section = GetExtensibilityGlobalsSection();
			if (section != null) {
				return section;
			}
			var newSection = new SD.ProjectSection(ExtensibilityGlobalsSectionName, "postSolution");
			solution.Sections.Add(newSection);
			return newSection;
		}
Exemple #14
0
		public ProjectSection GetSolutionConfigurationsSection()
		{
			foreach (ProjectSection sec in this.Sections) {
				if (sec.Name == "SolutionConfigurationPlatforms")
					return sec;
			}
			ProjectSection newSec = new ProjectSection("SolutionConfigurationPlatforms", "preSolution");
			this.Sections.Insert(0, newSec);
			foreach (ProjectSection sec in this.Sections) {
				if (sec.Name == "SolutionConfiguration") {
					this.Sections.Remove(sec);
					foreach (SolutionItem item in sec.Items) {
						newSec.Items.Add(new SolutionItem(item.Name + "|Any CPU", item.Location + "|Any CPU"));
					}
					break;
				}
			}
			return newSec;
		}
        public void AddExtensibilityGlobalsSection()
        {
            var section = new SD.ProjectSection("ExtensibilityGlobals", "postSolution");

            MSBuildSolution.Sections.Add(section);
        }
Exemple #16
0
        public ProjectSection GetProjectConfigurationsSection()
        {
            //foreach (ProjectSection sec in Sections) {
            //    if (sec.Name == "ProjectConfigurationPlatforms")
            //        return sec;
            //}
            ProjectSection newSec = new ProjectSection("ProjectConfigurationPlatforms", "postSolution");
            //Sections.Add(newSec);
            //foreach (ProjectSection sec in this.Sections) {
            //    if (sec.Name == "ProjectConfiguration") {
            //        this.Sections.Remove(sec);
            //        foreach (SolutionItem item in sec.Items) {
            //            string name = item.Name;
            //            string location = item.Location;
            //            if (!name.Contains("|")) {
            //                int pos = name.LastIndexOf('.');
            //                if (pos > 0) {
            //                    string firstpart = name.Substring(0, pos);
            //                    string lastpart = name.Substring(pos);
            //                    if (lastpart == ".0") {
            //                        pos = firstpart.LastIndexOf('.');
            //                        if (pos > 0) {
            //                            lastpart = name.Substring(pos);
            //                            firstpart = name.Substring(0, pos);
            //                        }
            //                    }
            //                    name = firstpart + "|Any CPU" + lastpart;
            //                }

            //                pos = location.LastIndexOf('|');
            //                if (pos < 0) {
            //                    location += "|Any CPU";
            //                } else {
            //                    string platform = location.Substring(pos+1);
            //                    bool found = false;
            //                    foreach (IProject p in this.Projects) {
            //                        if (p.PlatformNames.Contains(platform)) {
            //                            found = true;
            //                            break;
            //                        }
            //                    }
            //                    if (!found) {
            //                        location = location.Substring(0, pos) + "|Any CPU";
            //                    }
            //                }
            //            }
            //            newSec.Items.Add(new SolutionItem(name, location));
            //        }
            //        break;
            //    }
            //}
            return newSec;
        }
Exemple #17
0
		public ProjectSection GetSolutionConfigurationsSection()
		{
			foreach (ProjectSection sec in this.Sections) {
				if (sec.Name == "SolutionConfigurationPlatforms")
					return sec;
			}
			ProjectSection newSec = new ProjectSection("SolutionConfigurationPlatforms", "preSolution");
			this.Sections.Insert(0, newSec);
			
			// convert VS 2003 solution to VS 2005 (or later)
			foreach (ProjectSection sec in this.Sections) {
				if (sec.Name == "SolutionConfiguration") {
					this.Sections.Remove(sec);
					foreach (SolutionItem item in sec.Items) {
						// item.Name = item.Location
						// might be  ConfigName.0 = Debug   (VS.NET)
						// or        Debug = Debug          (VS.NET 03)
						newSec.Items.Add(new SolutionItem(item.Location + "|x86", item.Location + "|x86"));
					}
					break;
				}
			}
			return newSec;
		}
Exemple #18
0
		public ProjectSection GetProjectConfigurationsSection()
		{
			foreach (ProjectSection sec in Sections) {
				if (sec.Name == "ProjectConfigurationPlatforms")
					return sec;
			}
			ProjectSection newSec = new ProjectSection("ProjectConfigurationPlatforms", "postSolution");
			Sections.Add(newSec);
			foreach (ProjectSection sec in this.Sections) {
				if (sec.Name == "ProjectConfiguration") {
					this.Sections.Remove(sec);
					foreach (SolutionItem item in sec.Items) {
						string name = item.Name;
						string location = item.Location;
						if (!name.Contains("|")) {
							int pos = name.LastIndexOf('.');
							if (pos > 0) {
								string firstpart = name.Substring(0, pos);
								string lastpart = name.Substring(pos);
								if (lastpart == ".0") {
									pos = firstpart.LastIndexOf('.');
									if (pos > 0) {
										lastpart = name.Substring(pos);
										firstpart = name.Substring(0, pos);
									}
								}
								name = firstpart + "|Any CPU" + lastpart;
							}
							
							pos = location.LastIndexOf('|');
							if (pos < 0) {
								location += "|Any CPU";
							} else {
								string platform = location.Substring(pos+1);
								bool found = false;
								foreach (IProject p in this.Projects) {
									if (p.PlatformNames.Contains(platform)) {
										found = true;
										break;
									}
								}
								if (!found) {
									location = location.Substring(0, pos) + "|Any CPU";
								}
							}
						}
						newSec.Items.Add(new SolutionItem(name, location));
					}
					break;
				}
			}
			return newSec;
		}
Exemple #19
0
        /// <summary>
        /// Load a single project as solution.
        /// </summary>
        public static void LoadProject(string fileName)
        {
            string solutionFile = Path.ChangeExtension(fileName, ".sln");

            if (File.Exists(solutionFile))
            {
                LoadSolution(solutionFile);

                if (openSolution != null)
                {
                    bool found = false;
                    foreach (IProject p in openSolution.Projects)
                    {
                        if (FileUtility.IsEqualFileName(fileName, p.FileName))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found == false)
                    {
                        string[,] parseArgs = { { "SolutionName", Path.GetFileName(solutionFile) }, { "ProjectName", Path.GetFileName(fileName) } };
                        int res = MessageService.ShowCustomDialog(MessageService.ProductName,
                                                                  StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.SolutionDoesNotContainProject}", parseArgs),
                                                                  0, 2,
                                                                  StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.SolutionDoesNotContainProject.AddProjectToSolution}", parseArgs),
                                                                  StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.SolutionDoesNotContainProject.CreateNewSolution}", parseArgs),
                                                                  "${res:Global.IgnoreButtonText}");
                        if (res == 0)
                        {
                            // Add project to solution
                            Commands.AddExitingProjectToSolution.AddProject((ISolutionFolderNode)ProjectBrowserPad.Instance.SolutionNode, fileName);
                            SaveSolution();
                            return;
                        }
                        else if (res == 1)
                        {
                            CloseSolution();
                            try {
                                File.Copy(solutionFile, Path.ChangeExtension(solutionFile, ".old.sln"), true);
                            } catch (IOException) {}
                        }
                        else
                        {
                            // ignore, just open the solution
                            return;
                        }
                    }
                    else
                    {
                        // opened solution instead and correctly found the project
                        return;
                    }
                }
                else
                {
                    // some problem during opening, abort
                    return;
                }
            }
            Solution solution = new Solution();

            solution.Name = Path.GetFileNameWithoutExtension(fileName);
            ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(fileName);
            IProject         project;

            if (binding != null)
            {
                project = LanguageBindingService.LoadProject(solution, fileName, solution.Name);
                if (project is UnknownProject)
                {
                    if (((UnknownProject)project).WarningDisplayedToUser == false)
                    {
                        ((UnknownProject)project).ShowWarningMessageBox();
                    }
                    return;
                }
            }
            else
            {
                MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.InvalidProjectOrCombine}", new string[, ] {
                    { "FileName", fileName }
                }));
                return;
            }
            solution.AddFolder(project);
            ProjectSection configSection = solution.GetSolutionConfigurationsSection();

            foreach (string configuration in project.ConfigurationNames)
            {
                foreach (string platform in project.PlatformNames)
                {
                    string key;
                    if (platform == "AnyCPU")                       // Fix for SD2-786
                    {
                        key = configuration + "|Any CPU";
                    }
                    else
                    {
                        key = configuration + "|" + platform;
                    }
                    configSection.Items.Add(new SolutionItem(key, key));
                }
            }
            solution.FixSolutionConfiguration(new IProject[] { project });

            if (FileUtility.ObservedSave((NamedFileOperationDelegate)solution.Save, solutionFile) == FileOperationResult.OK)
            {
                // only load when saved succesfully
                LoadSolution(solutionFile);
            }
        }
		public void AddExtensibilityGlobalsSection()
		{
			var section = new SD.ProjectSection("ExtensibilityGlobals", "postSolution");
			MSBuildSolution.Sections.Add(section);
		}