Esempio 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();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an entire solution to the workspace, replacing any existing solution.
        /// </summary>
        public void AddSolution(SolutionInfo solutionInfo)
        {
            if (solutionInfo == null)
            {
                throw new ArgumentNullException("solutionInfo");
            }

            this.OnSolutionAdded(solutionInfo);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds an entire solution to the workspace, replacing any existing solution.
        /// </summary>
        public Solution AddSolution(SolutionInfo solutionInfo)
        {
            if (solutionInfo == null)
            {
                throw new ArgumentNullException("solutionInfo");
            }

            this.OnSolutionAdded(solutionInfo);

            return this.CurrentSolution;
        }
Esempio n. 4
0
        /// <summary>
        /// Adds an entire solution to the workspace, replacing any existing solution.
        /// </summary>
        public Solution AddSolution(SolutionInfo solutionInfo)
        {
            if (solutionInfo == null)
            {
                throw new ArgumentNullException(nameof(solutionInfo));
            }

            this.OnSolutionAdded(solutionInfo);

            this.UpdateReferencesAfterAdd();

            return this.CurrentSolution;
        }
Esempio n. 5
0
 public SolutionState(
     Workspace workspace,
     SolutionInfo info)
     : this(
         workspace.PrimaryBranchId,
         workspaceVersion: 0,
         solutionServices: new SolutionServices(workspace),
         solutionInfo: info,
         projectIds: null,
         idToProjectStateMap: ImmutableDictionary<ProjectId, ProjectState>.Empty,
         projectIdToTrackerMap: ImmutableDictionary<ProjectId, CompilationTracker>.Empty,
         linkedFilesMap: ImmutableDictionary.Create<string, ImmutableArray<DocumentId>>(StringComparer.OrdinalIgnoreCase),
         dependencyGraph: ProjectDependencyGraph.Empty,
         lazyLatestProjectVersion: null)
 {
     // this is for the very first solution state ever created
     _lazyLatestProjectVersion = new Lazy<VersionStamp>(() => ComputeLatestProjectVersion());
 }
Esempio n. 6
0
        /// <summary>
        /// Call this method to respond to a solution being opened in the host environment.
        /// </summary>
        protected internal void OnSolutionAdded(SolutionInfo solutionInfo)
        {
            var oldSolution = this.CurrentSolution;
            var solutionId  = solutionInfo.Id;

            using (this.serializationLock.DisposableWait())
            {
                CheckSolutionIsEmpty();
                this.SetCurrentSolution(this.CreateSolution(solutionInfo));
            }

            solutionInfo.Projects.Do(p => OnProjectAdded(p, silent: true));

            var newSolution = this.CurrentSolution;

            this.RegisterSolution(solutionInfo);

            this.RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind.SolutionAdded, oldSolution, newSolution);
        }
Esempio n. 7
0
        /// <summary>
        /// Call this method to respond to a solution being reloaded in the host environment.
        /// </summary>
        protected internal void OnSolutionReloaded(SolutionInfo reloadedSolutionInfo)
        {
            var oldSolution = this.CurrentSolution;

            Solution newSolution;

            using (this.serializationLock.DisposableWait())
            {
                newSolution = this.CreateSolution(reloadedSolutionInfo);
                newSolution = this.SetCurrentSolution(newSolution);

                reloadedSolutionInfo.Projects.Do(pi => OnProjectAdded_NoLock(pi, silent: true));

                newSolution = this.AdjustReloadedSolution(oldSolution, this.latestSolution);
                newSolution = this.SetCurrentSolution(newSolution);

                this.RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind.SolutionReloaded, oldSolution, newSolution);
            }
        }
Esempio n. 8
0
 internal Solution(
     Workspace workspace,
     IWorkspaceServiceProvider workspaceServices,
     SolutionInfo info)
     : this(
         workspace.PrimaryBranchId,
         workspaceVersion: 0,
         solutionServices: new SolutionServices(workspace, workspaceServices),
         id: info.Id,
         filePath: info.FilePath,
         version: info.Version,
         projectIds: ImmutableList.Create<ProjectId>(),
         idToProjectStateMap: ImmutableDictionary<ProjectId, ProjectState>.Empty,
         projectIdToTrackerMap: ImmutableDictionary<ProjectId, CompilationTracker>.Empty,
         dependencyGraph: ProjectDependencyGraph.Empty,
         lazyLatestProjectVersion: null)
 {
     this.lazyLatestProjectVersion = new Lazy<VersionStamp>(() => ComputeLatestProjectVersion());
 }
Esempio n. 9
0
 internal Solution(
     Workspace workspace,
     SolutionInfo info)
     : this(
         workspace.PrimaryBranchId,
         workspaceVersion: 0,
         solutionServices: new SolutionServices(workspace),
         id: info.Id,
         filePath: info.FilePath,
         version: info.Version,
         projectIds: null,
         idToProjectStateMap: ImmutableDictionary<ProjectId, ProjectState>.Empty,
         projectIdToTrackerMap: ImmutableDictionary<ProjectId, CompilationTracker>.Empty,
         linkedFilesMap: ImmutableDictionary.Create<string, ImmutableArray<DocumentId>>(StringComparer.OrdinalIgnoreCase),
         dependencyGraph: ProjectDependencyGraph.Empty,
         lazyLatestProjectVersion: null)
 {
     _lazyLatestProjectVersion = new Lazy<VersionStamp>(() => ComputeLatestProjectVersion());
 }
 public void OnSolutionAdded(SolutionInfo solutionInfo)
 {
     this.AssertIsForeground();
     RegisterPrimarySolutionAsync().Wait();
 }
Esempio n. 11
0
 internal Solution(Workspace workspace, SolutionInfo info)
     : this(new SolutionState(workspace, info))
 {
 }
Esempio n. 12
0
        private SolutionState Branch(
            SolutionInfo solutionInfo = null,
            IEnumerable<ProjectId> projectIds = null,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap = null,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap = null,
            ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap = null,
            ProjectDependencyGraph dependencyGraph = null,
            Lazy<VersionStamp> lazyLatestProjectVersion = null)
        {
            var branchId = GetBranchId();

            solutionInfo = solutionInfo ?? _solutionInfo;
            projectIds = projectIds ?? _projectIds;
            idToProjectStateMap = idToProjectStateMap ?? _projectIdToProjectStateMap;
            projectIdToTrackerMap = projectIdToTrackerMap ?? _projectIdToTrackerMap;
            linkedFilesMap = linkedFilesMap ?? _linkedFilesMap;
            dependencyGraph = dependencyGraph ?? _dependencyGraph;
            lazyLatestProjectVersion = lazyLatestProjectVersion ?? _lazyLatestProjectVersion;

            if (branchId == _branchId &&
                solutionInfo == _solutionInfo &&
                projectIds == _projectIds &&
                idToProjectStateMap == _projectIdToProjectStateMap &&
                projectIdToTrackerMap == _projectIdToTrackerMap &&
                linkedFilesMap == _linkedFilesMap &&
                dependencyGraph == _dependencyGraph &&
                lazyLatestProjectVersion == _lazyLatestProjectVersion)
            {
                return this;
            }


            return new SolutionState(
                branchId,
                _workspaceVersion,
                _solutionServices,
                solutionInfo,
                projectIds,
                idToProjectStateMap,
                projectIdToTrackerMap,
                linkedFilesMap,
                dependencyGraph,
                lazyLatestProjectVersion);
        }
Esempio n. 13
0
 /// <summary>
 /// Create a new empty solution instance associated with this workspace.
 /// </summary>
 protected internal Solution CreateSolution(SolutionId id)
 {
     return(CreateSolution(SolutionInfo.Create(id, VersionStamp.Create())));
 }
Esempio n. 14
0
 /// <summary>
 /// Create a new empty solution instance associated with this workspace.
 /// </summary>
 protected internal Solution CreateSolution(SolutionInfo solutionInfo)
 {
     return(new Solution(this, this.workspaceServicesProvider, solutionInfo));
 }
Esempio n. 15
0
 /// <summary>
 /// This method is called when a solution is first observed.
 /// </summary>
 /// <param name="solutionInfo"></param>
 protected virtual void RegisterSolution(SolutionInfo solutionInfo)
 {
 }
Esempio n. 16
0
 internal Solution(Workspace workspace, SolutionInfo info)
     : this(new SolutionState(workspace, info))
 {
 }
Esempio n. 17
0
 /// <summary>
 /// Create a new empty solution instance associated with this workspace.
 /// </summary>
 protected internal Solution CreateSolution(SolutionInfo solutionInfo)
 {
     return(new Solution(this, solutionInfo));
 }