Beispiel #1
0
            private async Task EnqueueWorkItemAsync(ProjectChanges projectChanges)
            {
                await EnqueueProjectConfigurationChangeWorkItemAsync(projectChanges)
                .ConfigureAwait(false);

                foreach (var addedDocumentId in projectChanges.GetAddedDocuments())
                {
                    await EnqueueWorkItemAsync(
                        projectChanges.NewProject.GetRequiredDocument(addedDocumentId),
                        InvocationReasons.DocumentAdded
                        )
                    .ConfigureAwait(false);
                }

                foreach (var changedDocumentId in projectChanges.GetChangedDocuments())
                {
                    await EnqueueWorkItemAsync(
                        projectChanges.OldProject.GetRequiredDocument(changedDocumentId),
                        projectChanges.NewProject.GetRequiredDocument(changedDocumentId)
                        )
                    .ConfigureAwait(continueOnCapturedContext: false);
                }

                foreach (var removedDocumentId in projectChanges.GetRemovedDocuments())
                {
                    await EnqueueWorkItemAsync(
                        projectChanges.OldProject.GetRequiredDocument(removedDocumentId),
                        InvocationReasons.DocumentRemoved
                        )
                    .ConfigureAwait(false);
                }
            }
Beispiel #2
0
 private bool HasProjectFileChanges(ProjectChanges changes)
 {
     return(changes.GetAddedDocuments().Any() ||
            changes.GetRemovedDocuments().Any() ||
            changes.GetAddedMetadataReferences().Any() ||
            changes.GetRemovedMetadataReferences().Any() ||
            changes.GetAddedProjectReferences().Any() ||
            changes.GetRemovedProjectReferences().Any() ||
            changes.GetAddedAnalyzerReferences().Any() ||
            changes.GetRemovedAnalyzerReferences().Any());
 }
Beispiel #3
0
        protected override void ApplyProjectChanges(ProjectChanges projectChanges)
        {
            System.Diagnostics.Debug.Assert(this.applyChangesProjectFile == null);

            var project = projectChanges.OldProject ?? projectChanges.NewProject;

            try
            {
                // if we need to modify the project file, load it first.
                if (projectChanges.GetAddedDocuments().Any() ||
                    projectChanges.GetRemovedDocuments().Any())
                {
                    var projectPath = project.FilePath;
                    IProjectFileLoader loader;
                    if (this.TryGetLoaderFromProjectPath(projectPath, ReportMode.Ignore, out loader))
                    {
                        try
                        {
                            this.applyChangesProjectFile = loader.LoadProjectFileAsync(projectPath, this.properties, CancellationToken.None).Result;
                        }
                        catch (System.IO.IOException exception)
                        {
                            this.OnWorkspaceFailed(new ProjectDiagnostic(WorkspaceDiagnosticKind.Failure, exception.Message, projectChanges.ProjectId));
                        }
                    }
                }

                // do normal apply operations
                base.ApplyProjectChanges(projectChanges);

                // save project file
                if (this.applyChangesProjectFile != null)
                {
                    try
                    {
                        this.applyChangesProjectFile.Save();
                    }
                    catch (System.IO.IOException exception)
                    {
                        this.OnWorkspaceFailed(new ProjectDiagnostic(WorkspaceDiagnosticKind.Failure, exception.Message, projectChanges.ProjectId));
                    }
                }
            }
            finally
            {
                this.applyChangesProjectFile = null;
            }
        }
Beispiel #4
0
            private async Task EnqueueWorkItemAsync(ProjectChanges projectChanges)
            {
                await EnqueueProjectConfigurationChangeWorkItemAsync(projectChanges).ConfigureAwait(false);

                foreach (var addedDocumentId in projectChanges.GetAddedDocuments())
                {
                    await EnqueueWorkItemAsync(projectChanges.NewProject.GetDocument(addedDocumentId), InvocationReasons.DocumentAdded).ConfigureAwait(false);
                }

                foreach (var changedDocumentId in projectChanges.GetChangedDocuments())
                {
                    await EnqueueWorkItemAsync(projectChanges.OldProject.GetDocument(changedDocumentId), projectChanges.NewProject.GetDocument(changedDocumentId))
                        .ConfigureAwait(continueOnCapturedContext: false);
                }

                foreach (var removedDocumentId in projectChanges.GetRemovedDocuments())
                {
                    await EnqueueWorkItemAsync(projectChanges.OldProject.GetDocument(removedDocumentId), InvocationReasons.DocumentRemoved).ConfigureAwait(false);
                }
            }