Skip to content

Commit ac1968d

Browse files
authored
Add NFW tracking to Solution.RemoveProjectReference (#74965)
Will help find underlying issue for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2136005 CPS has a system to catch exceptions from code they call into and have created this bug with a callstack and essentially no additional information about the exception being thrown. The hope here is that our reporting system will give us more actionable data.
1 parent cb6ef38 commit ac1968d

File tree

1 file changed

+15
-7
lines changed
  • src/Workspaces/Core/Portable/Workspace/Solution

1 file changed

+15
-7
lines changed

src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Threading;
1212
using System.Threading.Tasks;
1313
using Microsoft.CodeAnalysis.Diagnostics;
14+
using Microsoft.CodeAnalysis.ErrorReporting;
1415
using Microsoft.CodeAnalysis.Host;
1516
using Microsoft.CodeAnalysis.Options;
1617
using Microsoft.CodeAnalysis.PooledObjects;
@@ -626,16 +627,23 @@ public Solution AddProjectReferences(ProjectId projectId, IEnumerable<ProjectRef
626627
/// <exception cref="ArgumentException">The solution does not contain <paramref name="projectId"/>.</exception>
627628
public Solution RemoveProjectReference(ProjectId projectId, ProjectReference projectReference)
628629
{
629-
if (projectReference == null)
630-
throw new ArgumentNullException(nameof(projectReference));
630+
try
631+
{
632+
if (projectReference == null)
633+
throw new ArgumentNullException(nameof(projectReference));
631634

632-
CheckContainsProject(projectId);
635+
CheckContainsProject(projectId);
633636

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));
637640

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+
}
639647
}
640648

641649
/// <summary>

0 commit comments

Comments
 (0)