Esempio n. 1
0
 void WriteFolderFiles(SlnProject proj, SolutionFolder folder)
 {
     if (folder.Files.Count > 0)
     {
         var sec = proj.Sections.GetOrCreateSection("SolutionItems", SlnSectionType.PreProcess);
         sec.Properties.Clear();
         foreach (FilePath f in folder.Files)
         {
             string relFile = MSBuildProjectService.ToMSBuildPathRelative(folder.ParentSolution.ItemDirectory, f);
             sec.Properties.SetValue(relFile, relFile);
         }
     }
     else
     {
         proj.Sections.RemoveSection("SolutionItems");
     }
 }
Esempio n. 2
0
        void DeserializeSolutionItem(ProgressMonitor monitor, Solution sln, SolutionFolderItem item, SlnProject proj)
        {
            // Deserialize the object
            var sec = proj.Sections.GetSection("MonoDevelopProperties");

            if (sec == null)
            {
                return;
            }

            sln.ReadSolutionFolderItemData(monitor, sec.Properties, item);
        }
Esempio n. 3
0
        public void Read(TextReader reader)
        {
            string line;
            int    curLineNum  = 0;
            bool   globalFound = false;
            bool   productRead = false;

            while ((line = reader.ReadLine()) != null)
            {
                curLineNum++;
                line = line.Trim();
                if (line.StartsWith("Microsoft Visual Studio Solution File", StringComparison.Ordinal))
                {
                    int i = line.LastIndexOf(' ');
                    if (i == -1)
                    {
                        throw new InvalidSolutionFormatException(curLineNum);
                    }
                    FormatVersion    = line.Substring(i + 1);
                    prefixBlankLines = curLineNum - 1;
                }
                if (line.StartsWith("# ", StringComparison.Ordinal))
                {
                    if (!productRead)
                    {
                        productRead        = true;
                        ProductDescription = line.Substring(2);
                    }
                }
                else if (line.StartsWith("Project", StringComparison.Ordinal))
                {
                    SlnProject p = new SlnProject();
                    p.Read(reader, line, ref curLineNum);
                    projects.Add(p);
                }
                else if (line == "Global")
                {
                    if (globalFound)
                    {
                        throw new InvalidSolutionFormatException(curLineNum, "Global section specified more than once");
                    }
                    globalFound = true;
                    while ((line = reader.ReadLine()) != null)
                    {
                        curLineNum++;
                        line = line.Trim();
                        if (line == "EndGlobal")
                        {
                            break;
                        }
                        else if (line.StartsWith("GlobalSection", StringComparison.Ordinal))
                        {
                            var sec = new SlnSection();
                            sec.Read(reader, line, ref curLineNum);
                            sections.Add(sec);
                        }
                        else                           // Ignore text that's out of place
                        {
                            continue;
                        }
                    }
                    if (line == null)
                    {
                        throw new InvalidSolutionFormatException(curLineNum, "Global section not closed");
                    }
                }
                else if (line.IndexOf('=') != -1)
                {
                    metadata.ReadLine(line, curLineNum);
                }
            }
            if (FormatVersion == null)
            {
                throw new InvalidSolutionFormatException(curLineNum, "File header is missing");
            }
        }