internal static ProjectBlock Parse(TextReader reader) { var startLine = reader.ReadLine().TrimStart(null); var scanner = new LineScanner(startLine); if (scanner.ReadUpToAndEat("(\"") != "Project") { //throw new Exception(string.Format(WorkspacesResources.InvalidProjectBlockInSolutionFile4, "Project")); throw new Exception(); } var projectTypeGuid = Guid.Parse(scanner.ReadUpToAndEat("\")")); // Read chars upto next quote, must contain "=" with optional leading/trailing whitespaces. if (scanner.ReadUpToAndEat("\"").Trim() != "=") { //throw new Exception(WorkspacesResources.InvalidProjectBlockInSolutionFile); throw new Exception(); } var projectName = scanner.ReadUpToAndEat("\""); // Read chars upto next quote, must contain "," with optional leading/trailing whitespaces. if (scanner.ReadUpToAndEat("\"").Trim() != ",") { //throw new Exception(WorkspacesResources.InvalidProjectBlockInSolutionFile2); throw new Exception(); } var projectPath = scanner.ReadUpToAndEat("\""); // Read chars upto next quote, must contain "," with optional leading/trailing whitespaces. if (scanner.ReadUpToAndEat("\"").Trim() != ",") { //throw new Exception(WorkspacesResources.InvalidProjectBlockInSolutionFile3); throw new Exception(); } var projectGuid = Guid.Parse(scanner.ReadUpToAndEat("\"")); var projectSections = new List <SectionBlock>(); while (char.IsWhiteSpace((char)reader.Peek())) { projectSections.Add(SectionBlock.Parse(reader)); } // Expect to see "EndProject" but be tolerant with missing tags as in Dev12. // Instead, we may see either P' for "Project" or 'G' for "Global", which will be handled next. if (reader.Peek() != 'P' && reader.Peek() != 'G') { if (reader.ReadLine() != "EndProject") { //throw new Exception(string.Format(WorkspacesResources.InvalidProjectBlockInSolutionFile4, "EndProject")); throw new Exception(); } } return(new ProjectBlock(projectTypeGuid, projectName, projectPath, projectGuid, projectSections)); }
internal static SectionBlock Parse(TextReader reader) { string startLine; while ((startLine = reader.ReadLine()) != null) { startLine = startLine.TrimStart(null); if (startLine != string.Empty) { break; } } var scanner = new LineScanner(startLine); var type = scanner.ReadUpToAndEat("("); var parenthesizedName = scanner.ReadUpToAndEat(") = "); var sectionValue = scanner.ReadRest(); var keyValuePairs = new List <KeyValuePair <string, string> >(); string line; while ((line = reader.ReadLine()) != null) { line = line.TrimStart(null); // ignore empty lines if (line == string.Empty) { continue; } if (line == "End" + type) { break; } scanner = new LineScanner(line); var key = scanner.ReadUpToAndEat(" = "); var value = scanner.ReadRest(); keyValuePairs.Add(new KeyValuePair <string, string>(key, value)); } return(new SectionBlock(type, parenthesizedName, sectionValue, keyValuePairs)); }
internal static ProjectBlock Parse(TextReader reader) { var startLine = reader.ReadLine().TrimStart(null); var scanner = new LineScanner(startLine); if (scanner.ReadUpToAndEat("(\"") != "Project") { throw new Exception(string.Format(WorkspacesResources.InvalidProjectBlockInSolutionFile4, "Project")); } var projectTypeGuid = Guid.Parse(scanner.ReadUpToAndEat("\")")); // Read chars up to next quote, must contain "=" with optional leading/trailing whitespaces. if (scanner.ReadUpToAndEat("\"").Trim() != "=") { throw new Exception(WorkspacesResources.InvalidProjectBlockInSolutionFile); } var projectName = scanner.ReadUpToAndEat("\""); // Read chars up to next quote, must contain "," with optional leading/trailing whitespaces. if (scanner.ReadUpToAndEat("\"").Trim() != ",") { throw new Exception(WorkspacesResources.InvalidProjectBlockInSolutionFile2); } var projectPath = scanner.ReadUpToAndEat("\""); // Read chars up to next quote, must contain "," with optional leading/trailing whitespaces. if (scanner.ReadUpToAndEat("\"").Trim() != ",") { throw new Exception(WorkspacesResources.InvalidProjectBlockInSolutionFile3); } var projectGuid = Guid.Parse(scanner.ReadUpToAndEat("\"")); var projectSections = new List<SectionBlock>(); while (char.IsWhiteSpace((char)reader.Peek())) { projectSections.Add(SectionBlock.Parse(reader)); } // Expect to see "EndProject" but be tolerant with missing tags as in Dev12. // Instead, we may see either P' for "Project" or 'G' for "Global", which will be handled next. if (reader.Peek() != 'P' && reader.Peek() != 'G') { if (reader.ReadLine() != "EndProject") { throw new Exception(string.Format(WorkspacesResources.InvalidProjectBlockInSolutionFile4, "EndProject")); } } return new ProjectBlock(projectTypeGuid, projectName, projectPath, projectGuid, projectSections); }
internal static SectionBlock Parse(TextReader reader) { string startLine; while ((startLine = reader.ReadLine()) != null) { startLine = startLine.TrimStart(null); if (startLine != string.Empty) { break; } } var scanner = new LineScanner(startLine); var type = scanner.ReadUpToAndEat("("); var parenthesizedName = scanner.ReadUpToAndEat(") = "); var sectionValue = scanner.ReadRest(); var keyValuePairs = new List<KeyValuePair<string, string>>(); string line; while ((line = reader.ReadLine()) != null) { line = line.TrimStart(null); // ignore empty lines if (line == string.Empty) { continue; } if (line == "End" + type) { break; } scanner = new LineScanner(line); var key = scanner.ReadUpToAndEat(" = "); var value = scanner.ReadRest(); keyValuePairs.Add(new KeyValuePair<string, string>(key, value)); } return new SectionBlock(type, parenthesizedName, sectionValue, keyValuePairs); }