Exemplo n.º 1
0
        private SolutionState(
            BranchId branchId,
            int workspaceVersion,
            SolutionServices solutionServices,
            SolutionInfo solutionInfo,
            IEnumerable<ProjectId> projectIds,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
            ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap,
            ProjectDependencyGraph dependencyGraph,
            Lazy<VersionStamp> lazyLatestProjectVersion)
        {
            _branchId = branchId;
            _workspaceVersion = workspaceVersion;
            _solutionServices = solutionServices;
            _solutionInfo = solutionInfo;
            _projectIds = projectIds.ToImmutableReadOnlyListOrEmpty();
            _projectIdToProjectStateMap = idToProjectStateMap;
            _projectIdToTrackerMap = projectIdToTrackerMap;
            _linkedFilesMap = linkedFilesMap;
            _dependencyGraph = dependencyGraph;
            _lazyLatestProjectVersion = lazyLatestProjectVersion;

            // when solution state is changed, we re-calcuate its checksum
            _lazyChecksums = new AsyncLazy<SolutionStateChecksums>(ComputeChecksumsAsync, cacheResult: true);

            CheckInvariants();
        }
Exemplo n.º 2
0
            public DocumentAttributes With(
                DocumentId id = null,
                string name   = null,
                IEnumerable <string> folders             = null,
                Optional <SourceCodeKind> sourceCodeKind = default,
                Optional <string> filePath  = default,
                Optional <bool> isGenerated = default)
            {
                var newId             = id ?? Id;
                var newName           = name ?? Name;
                var newFolders        = folders?.ToImmutableReadOnlyListOrEmpty() ?? Folders;
                var newSourceCodeKind = sourceCodeKind.HasValue ? sourceCodeKind.Value : SourceCodeKind;
                var newFilePath       = filePath.HasValue ? filePath.Value : FilePath;
                var newIsGenerated    = isGenerated.HasValue ? isGenerated.Value : IsGenerated;

                if (newId == Id &&
                    newName == Name &&
                    newFolders == Folders &&
                    newSourceCodeKind == SourceCodeKind &&
                    newFilePath == FilePath &&
                    newIsGenerated == IsGenerated)
                {
                    return(this);
                }

                return(new DocumentAttributes(newId, newName, newFolders, newSourceCodeKind, newFilePath, newIsGenerated));
            }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new instance of a <see cref="DocumentInfo"/>.
        /// </summary>
        private DocumentInfo(
            DocumentId id,
            string name,
            IEnumerable<string> folders,
            SourceCodeKind sourceCodeKind,
            TextLoader loader,
            string filePath,
            bool isGenerated)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.Id = id;
            this.Name = name;
            this.Folders = folders.ToImmutableReadOnlyListOrEmpty();
            this.SourceCodeKind = sourceCodeKind;
            this.TextLoader = loader;
            this.FilePath = filePath;
            this.IsGenerated = isGenerated;
        }
Exemplo n.º 4
0
        private SolutionState(
            BranchId branchId,
            int workspaceVersion,
            SolutionServices solutionServices,
            SolutionId id,
            string filePath,
            IEnumerable<ProjectId> projectIds,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
            ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap,
            ProjectDependencyGraph dependencyGraph,
            VersionStamp version,
            Lazy<VersionStamp> lazyLatestProjectVersion)
        {
            _branchId = branchId;
            _workspaceVersion = workspaceVersion;
            _id = id;
            _filePath = filePath;
            _solutionServices = solutionServices;
            _projectIds = projectIds.ToImmutableReadOnlyListOrEmpty();
            _projectIdToProjectStateMap = idToProjectStateMap;
            _projectIdToTrackerMap = projectIdToTrackerMap;
            _linkedFilesMap = linkedFilesMap;
            _dependencyGraph = dependencyGraph;
            _version = version;
            _lazyLatestProjectVersion = lazyLatestProjectVersion;

            CheckInvariants();
        }
Exemplo n.º 5
0
        private ProjectState(
            ProjectInfo projectInfo,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            IEnumerable<DocumentId> documentIds,
            IEnumerable<DocumentId> additionalDocumentIds,
            ImmutableDictionary<DocumentId, DocumentState> documentStates,
            ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
            AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
            AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion,
            ValueSource<ProjectStateChecksums> lazyChecksums)
        {
            _projectInfo = projectInfo;
            _solutionServices = solutionServices;
            _languageServices = languageServices;
            _documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
            _additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
            _documentStates = documentStates;
            _additionalDocumentStates = additionalDocumentStates;
            _lazyLatestDocumentVersion = lazyLatestDocumentVersion;
            _lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;

            // for now, let it re-calculate if anything changed.
            // TODO: optimize this so that we only re-calcuate checksums that are actually changed
            _lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
Exemplo n.º 6
0
 private SolutionInfo(
     SolutionId id,
     VersionStamp version,
     string filePath,
     IEnumerable<ProjectInfo> projects)
 {
     this.Id = id;
     this.Version = version;
     this.FilePath = filePath;
     this.Projects = projects.ToImmutableReadOnlyListOrEmpty();
 }
Exemplo n.º 7
0
 public ProjectFileInfo(
     string outputPath,
     string assemblyName,
     IEnumerable<string> commandLineArgs,
     IEnumerable<DocumentFileInfo> documents,
     IEnumerable<DocumentFileInfo> additionalDocuments,
     IEnumerable<ProjectFileReference> projectReferences)
 {
     this.OutputFilePath = outputPath;
     this.AssemblyName = assemblyName;
     this.CommandLineArgs = commandLineArgs.ToImmutableArrayOrEmpty();
     this.Documents = documents.ToImmutableReadOnlyListOrEmpty();
     this.AdditionalDocuments = additionalDocuments.ToImmutableArrayOrEmpty();
     this.ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
 }
Exemplo n.º 8
0
 private ProjectState(
     ProjectInfo projectInfo,
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     IEnumerable<DocumentId> documentIds,
     ImmutableDictionary<DocumentId, DocumentState> documentStates,
     AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
     AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
 {
     this.projectInfo = projectInfo;
     this.solutionServices = solutionServices;
     this.languageServices = languageServices;
     this.documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
     this.documentStates = documentStates;
     this.lazyLatestDocumentVersion = lazyLatestDocumentVersion;
     this.lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;
 }
Exemplo n.º 9
0
 public ProjectFileInfo(
     Guid guid,
     string outputPath,
     string assemblyName,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     IEnumerable<DocumentFileInfo> documents,
     IEnumerable<ProjectFileReference> projectReferences,
     IEnumerable<MetadataReference> metadataReferences,
     IEnumerable<AnalyzerReference> analyzerReferences)
 {
     this.Guid = guid;
     this.OutputFilePath = outputPath;
     this.AssemblyName = assemblyName;
     this.CompilationOptions = compilationOptions;
     this.ParseOptions = parseOptions;
     this.Documents = documents.ToImmutableReadOnlyListOrEmpty();
     this.ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
     this.MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
     this.AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
 }
Exemplo n.º 10
0
        private ProjectState(
            ProjectInfo projectInfo,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            IEnumerable<DocumentId> documentIds,
            IEnumerable<DocumentId> additionalDocumentIds,
            ImmutableDictionary<DocumentId, DocumentState> documentStates,
            ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
            AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
            AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
        {
            _projectInfo = projectInfo;
            _solutionServices = solutionServices;
            _languageServices = languageServices;
            _documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
            _additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
            _documentStates = documentStates;
            _additionalDocumentStates = additionalDocumentStates;
            _lazyLatestDocumentVersion = lazyLatestDocumentVersion;
            _lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;

            _lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
Exemplo n.º 11
0
 public ProjectInfo WithAnalyzerReferences(IEnumerable<AnalyzerReference> analyzerReferences)
 {
     return With(analyzerReferences: analyzerReferences.ToImmutableReadOnlyListOrEmpty());
 }
Exemplo n.º 12
0
 public ProjectInfo WithAdditionalDocuments(IEnumerable<DocumentInfo> additionalDocuments)
 {
     return With(additionalDocuments: additionalDocuments.ToImmutableReadOnlyListOrEmpty());
 }
Exemplo n.º 13
0
        private ProjectInfo(
            ProjectId id,
            VersionStamp version,
            string name,
            string assemblyName,
            string language,
            string filePath,
            string outputFilePath,
            CompilationOptions compilationOptions,
            ParseOptions parseOptions,
            IEnumerable<DocumentInfo> documents,
            IEnumerable<ProjectReference> projectReferences,
            IEnumerable<MetadataReference> metadataReferences,
            IEnumerable<AnalyzerReference> analyzerReferences,
            bool isSubmission,
            Type hostObjectType)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            if (name == null)
            {
                throw new ArgumentNullException("displayName");
            }

            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (language == null)
            {
                throw new ArgumentNullException("language");
            }

            this.Id = id;
            this.Version = version;
            this.Name = name;
            this.AssemblyName = assemblyName;
            this.Language = language;
            this.FilePath = filePath;
            this.OutputFilePath = outputFilePath;
            this.CompilationOptions = compilationOptions;
            this.ParseOptions = parseOptions;
            this.Documents = documents.ToImmutableReadOnlyListOrEmpty();
            this.ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
            this.MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
            this.AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
            this.IsSubmission = isSubmission;
            this.HostObjectType = hostObjectType;
        }
Exemplo n.º 14
0
 private SolutionInfo(SolutionAttributes attributes, IEnumerable <ProjectInfo> projects)
 {
     Attributes = attributes;
     Projects   = projects.ToImmutableReadOnlyListOrEmpty();
 }
Exemplo n.º 15
0
 public ProjectInfo WithAnalyzerReferences(IEnumerable <AnalyzerReference> analyzerReferences)
 {
     return(this.With(analyzerReferences: analyzerReferences.ToImmutableReadOnlyListOrEmpty()));
 }
Exemplo n.º 16
0
 public ProjectInfo WithProjectReferences(IEnumerable <ProjectReference> projectReferences)
 {
     return(With(projectReferences: projectReferences.ToImmutableReadOnlyListOrEmpty()));
 }
Exemplo n.º 17
0
 public ProjectInfo WithProjectReferences(IEnumerable<ProjectReference> projectReferences)
 {
     return With(projectReferences: projectReferences.ToImmutableReadOnlyListOrEmpty());
 }
Exemplo n.º 18
0
 private SolutionInfo(SolutionAttributes attributes, IEnumerable<ProjectInfo> projects)
 {
     Attributes = attributes;
     Projects = projects.ToImmutableReadOnlyListOrEmpty();
 }
Exemplo n.º 19
0
 public ProjectInfo WithDocuments(IEnumerable <DocumentInfo> documents)
 {
     return(With(documents: documents.ToImmutableReadOnlyListOrEmpty()));
 }
Exemplo n.º 20
0
 public DocumentInfo WithFolders(IEnumerable <string> folders)
 {
     return(this.With(folders: folders.ToImmutableReadOnlyListOrEmpty()));
 }
Exemplo n.º 21
0
 public ProjectInfo WithAdditionalDocuments(IEnumerable <DocumentInfo> additionalDocuments)
 {
     return(With(additionalDocuments: additionalDocuments.ToImmutableReadOnlyListOrEmpty()));
 }
Exemplo n.º 22
0
 public ProjectInfo WithAnalyzerConfigDocuments(IEnumerable <DocumentInfo> analyzerConfigDocuments)
 {
     return(With(analyzerConfigDocuments: analyzerConfigDocuments.ToImmutableReadOnlyListOrEmpty()));
 }
Exemplo n.º 23
0
 public ProjectInfo WithDocuments(IEnumerable<DocumentInfo> documents)
 {
     return With(documents: documents.ToImmutableReadOnlyListOrEmpty());
 }
Exemplo n.º 24
0
            public DocumentAttributes(
                DocumentId id,
                string name,
                IEnumerable<string> folders,
                SourceCodeKind sourceCodeKind,
                string filePath,
                bool isGenerated)
            {
                if (id == null)
                {
                    throw new ArgumentNullException(nameof(id));
                }

                if (name == null)
                {
                    throw new ArgumentNullException(nameof(name));
                }

                Id = id;
                Name = name;
                Folders = folders.ToImmutableReadOnlyListOrEmpty();
                SourceCodeKind = sourceCodeKind;
                FilePath = filePath;
                IsGenerated = isGenerated;
            }
Exemplo n.º 25
0
 public ProjectInfo WithMetadataReferences(IEnumerable<MetadataReference> metadataReferences)
 {
     return With(metadataReferences: metadataReferences.ToImmutableReadOnlyListOrEmpty());
 }
Exemplo n.º 26
0
 public DocumentInfo WithFolders(IEnumerable<string> folders)
 {
     return this.With(folders: folders.ToImmutableReadOnlyListOrEmpty());
 }
Exemplo n.º 27
0
 private ProjectInfo(
     ProjectAttributes attributes,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     IEnumerable<DocumentInfo> documents,
     IEnumerable<ProjectReference> projectReferences,
     IEnumerable<MetadataReference> metadataReferences,
     IEnumerable<AnalyzerReference> analyzerReferences,
     IEnumerable<DocumentInfo> additionalDocuments,
     Type hostObjectType)
 {
     Attributes = attributes;
     CompilationOptions = compilationOptions;
     ParseOptions = parseOptions;
     Documents = documents.ToImmutableReadOnlyListOrEmpty();
     ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
     MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
     AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
     AdditionalDocuments = additionalDocuments.ToImmutableReadOnlyListOrEmpty();
     HostObjectType = hostObjectType;
 }
Exemplo n.º 28
0
 public ProjectInfo WithMetadataReferences(IEnumerable <MetadataReference> metadataReferences)
 {
     return(With(metadataReferences: metadataReferences.ToImmutableReadOnlyListOrEmpty()));
 }