Ejemplo n.º 1
0
        public CSharpFile(CSharpProject project, FilePath fileName, string sourceCode)
        {
            Ensure.ArgumentNotNull(project, "project");

            Project      = project;
            FileName     = fileName;
            OriginalText = sourceCode;

            var parser = new CSharpParser(Project.CompilerSettings);

            SyntaxTree = parser.Parse(sourceCode, fileName.FullPath);

            Errors = parser.HasErrors
                ? parser.ErrorsAndWarnings
                : new List <Error>(0);

            UnresolvedTypeSystemForFile = SyntaxTree.ToTypeSystem();
        }
Ejemplo n.º 2
0
        public CSharpFile(CSharpProject project, FilePath fileName, string sourceCode)
        {
            Ensure.ArgumentNotNull(project, "project");

            Project = project;
            FileName = fileName;
            OriginalText = sourceCode;

            var parser = new CSharpParser(Project.CompilerSettings);

            SyntaxTree = parser.Parse(sourceCode, fileName.FullPath);

            Errors = parser.HasErrors
                ? parser.ErrorsAndWarnings
                : new List<Error>(0);

            UnresolvedTypeSystemForFile = SyntaxTree.ToTypeSystem();
        }
Ejemplo n.º 3
0
        public CSharpFile BuildCSharpFile(CSharpProject p, FilePath filename)
        {
            if (_openDocumentManager.IsDocumentOpen(filename))
            {
                _log.DebugFormat("Class file is open and will not be cached: [{0}]", filename);

                return new CSharpFile(p, filename, _fileReader.ReadAllText(filename));
            }

            return _fileCache.GetOrAdd(filename,
                f =>
                {
                    _log.DebugFormat("Build CSharpFile [{0}]", filename);

                    _fileByProjectIndex.Add(p.FileName, f);

                    return new CSharpFile(p, f, _fileReader.ReadAllText(f));
                });
        }