示例#1
0
        private IList <CSharpProject> LoadProjectFiles(string solutionFile)
        {
            var projectList = new List <CSharpProject>();

            foreach (string line in File.ReadLines(solutionFile))
            {
                Match match = ProjectLinePattern.Match(line);
                if (match.Success)
                {
                    string typeGuid = match.Groups["TypeGuid"].Value.ToUpperInvariant();
                    switch (typeGuid)
                    {
                    case "{2150E333-8FDC-42A3-9474-1A3956D46DE8}":     // Solution Folder
                        // ignore folders
                        break;

                    case "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}":     // C# project
                        string title       = match.Groups["Title"].Value;
                        string location    = match.Groups["Location"].Value;
                        Guid   projectGuid = Guid.Parse(match.Groups["Guid"].Value);
                        var    project     = new CSharpProject(this, Path.Combine(_solutionDirectory, location),
                                                               title, projectGuid);
                        project.PropertyChanged += OnProjectPropertyChanged;
                        projectList.Add(project);
                        break;
                    }
                }
            }
            return(projectList);
        }
示例#2
0
        public CSharpFile(CSharpProject project, string filePath)
        {
            _project  = project;
            _filePath = filePath;

            var parser = new CSharpParser(project.CompilerSettings);

            if (!(_exists = File.Exists(filePath)))
            {
                return;
            }
            using (FileStream stream = File.OpenRead(filePath))
            {
                _syntaxTree           = parser.Parse(stream, filePath);
                _unresolvedTypeSystem = _syntaxTree.ToTypeSystem();
            }
            if (parser.HasErrors)
            {
                _project.AddToErrorCount(parser.Errors.Count());
            }

            if (parser.HasWarnings)
            {
                _project.AddToWarningCount(parser.Warnings.Count());
            }
        }