Skip to content

Commit 336b591

Browse files
authored
Fix NFW due to invoking Workspace.RaiseEventForHandlers in the CA process (#77546)
NFW telemetry indicates Solution.Workspace is getting called in our server process. This is due to a recent change I made around immediate eventing. In the server process, there are no immediate (or standard) workspace event handlers, but due to this recent changewe were always calling RaiseEventForHandlers for the immediate handlers without checking for their presence.
1 parent 6a6e924 commit 336b591

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,19 @@ protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solutio
7878
projectId = documentId.ProjectId;
7979
}
8080

81-
var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
82-
81+
WorkspaceChangeEventArgs args = null;
8382
var ev = GetEventHandlers<WorkspaceChangeEventArgs>(WorkspaceChangedImmediateEventName);
84-
RaiseEventForHandlers(ev, args, FunctionId.Workspace_EventsImmediate);
83+
84+
if (ev.HasHandlers)
85+
{
86+
args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
87+
RaiseEventForHandlers(ev, args, FunctionId.Workspace_EventsImmediate);
88+
}
8589

8690
ev = GetEventHandlers<WorkspaceChangeEventArgs>(WorkspaceChangeEventName);
8791
if (ev.HasHandlers)
8892
{
93+
args ??= new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
8994
return this.ScheduleTask(() =>
9095
{
9196
RaiseEventForHandlers(ev, args, FunctionId.Workspace_Events);

0 commit comments

Comments
 (0)