|
11 | 11 | using System.Threading;
|
12 | 12 | using System.Threading.Tasks;
|
13 | 13 | using Microsoft.CodeAnalysis.Diagnostics;
|
| 14 | +using Microsoft.CodeAnalysis.ErrorReporting; |
14 | 15 | using Microsoft.CodeAnalysis.Host;
|
15 | 16 | using Microsoft.CodeAnalysis.Options;
|
16 | 17 | using Microsoft.CodeAnalysis.PooledObjects;
|
@@ -626,16 +627,23 @@ public Solution AddProjectReferences(ProjectId projectId, IEnumerable<ProjectRef
|
626 | 627 | /// <exception cref="ArgumentException">The solution does not contain <paramref name="projectId"/>.</exception>
|
627 | 628 | public Solution RemoveProjectReference(ProjectId projectId, ProjectReference projectReference)
|
628 | 629 | {
|
629 |
| - if (projectReference == null) |
630 |
| - throw new ArgumentNullException(nameof(projectReference)); |
| 630 | + try |
| 631 | + { |
| 632 | + if (projectReference == null) |
| 633 | + throw new ArgumentNullException(nameof(projectReference)); |
631 | 634 |
|
632 |
| - CheckContainsProject(projectId); |
| 635 | + CheckContainsProject(projectId); |
633 | 636 |
|
634 |
| - var oldProject = GetRequiredProjectState(projectId); |
635 |
| - if (!oldProject.ProjectReferences.Contains(projectReference)) |
636 |
| - throw new ArgumentException(WorkspacesResources.Project_does_not_contain_specified_reference, nameof(projectReference)); |
| 637 | + var oldProject = GetRequiredProjectState(projectId); |
| 638 | + if (!oldProject.ProjectReferences.Contains(projectReference)) |
| 639 | + throw new ArgumentException(WorkspacesResources.Project_does_not_contain_specified_reference, nameof(projectReference)); |
637 | 640 |
|
638 |
| - return WithCompilationState(CompilationState.RemoveProjectReference(projectId, projectReference)); |
| 641 | + return WithCompilationState(CompilationState.RemoveProjectReference(projectId, projectReference)); |
| 642 | + } |
| 643 | + catch (Exception ex) when (FatalError.ReportAndPropagate(ex)) |
| 644 | + { |
| 645 | + throw ExceptionUtilities.Unreachable(); |
| 646 | + } |
639 | 647 | }
|
640 | 648 |
|
641 | 649 | /// <summary>
|
|
0 commit comments