@@ -59,6 +59,7 @@ public void Dispose()
59
59
// Release before dispose to ensure we don't throw exceptions from the background thread trying to release
60
60
// while we're disposing. Multiple releases are fine, and if we release and it lets something passed the lock
61
61
// our cancellation token check will mean its a no-op.
62
+ _logger . LogTrace ( $ "Releasing the semaphore in Dispose") ;
62
63
_semaphore . Release ( ) ;
63
64
_semaphore . Dispose ( ) ;
64
65
@@ -116,14 +117,19 @@ private async Task UpdateWorkspaceStateAsync(Project? workspaceProject, IProject
116
117
// So if we now do multiple requests to resolve TagHelpers simultaneously it results in only a
117
118
// single one executing at a time so that we don't have N number of requests in flight with these
118
119
// 10mb payloads waiting to be processed.
120
+ _logger . LogTrace ( $ "In UpdateWorkspaceStateAsync, waiting for the semaphore, for '{ projectSnapshot . Key } '") ;
119
121
await _semaphore . WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
120
122
}
121
123
catch ( Exception )
122
124
{
125
+ _logger . LogTrace ( $ "Exception waiting for the semaphore '{ projectSnapshot . Key } '") ;
126
+
123
127
// Object disposed or task cancelled exceptions should be swallowed/no-op'd
124
128
return ;
125
129
}
126
130
131
+ _logger . LogTrace ( $ "Got the semaphore '{ projectSnapshot . Key } '") ;
132
+
127
133
try
128
134
{
129
135
OnStartingBackgroundWork ( ) ;
@@ -135,54 +141,71 @@ private async Task UpdateWorkspaceStateAsync(Project? workspaceProject, IProject
135
141
136
142
var workspaceState = await GetProjectWorkspaceStateAsync ( workspaceProject , projectSnapshot , cancellationToken ) ;
137
143
138
- if ( workspaceState is null || cancellationToken . IsCancellationRequested )
144
+ if ( workspaceState is null )
145
+ {
146
+ _logger . LogTrace ( $ "Couldn't get any state for '{ projectSnapshot . Key } '") ;
147
+ return ;
148
+ }
149
+ else if ( cancellationToken . IsCancellationRequested )
139
150
{
151
+ _logger . LogTrace ( $ "Got a cancellation request during discovery for '{ projectSnapshot . Key } '") ;
140
152
return ;
141
153
}
142
154
155
+ _logger . LogTrace ( $ "Updating project info with { workspaceState . TagHelpers . Length } tag helpers for '{ projectSnapshot . Key } '") ;
156
+
143
157
await _projectManager
144
158
. UpdateAsync (
145
159
static ( updater , state ) =>
146
160
{
147
- var ( projectKey , workspaceState , cancellationToken ) = state ;
161
+ var ( projectKey , workspaceState , logger , cancellationToken ) = state ;
148
162
149
163
if ( cancellationToken . IsCancellationRequested )
150
164
{
151
165
return ;
152
166
}
153
167
168
+ logger . LogTrace ( $ "Really updating project info with { workspaceState . TagHelpers . Length } tag helpers for '{ projectKey } '") ;
154
169
updater . ProjectWorkspaceStateChanged ( projectKey , workspaceState ) ;
155
170
} ,
156
- state : ( projectSnapshot . Key , workspaceState , cancellationToken ) ,
171
+ state : ( projectSnapshot . Key , workspaceState , _logger , cancellationToken ) ,
157
172
cancellationToken )
158
173
. ConfigureAwait ( false ) ;
159
174
}
160
175
catch ( OperationCanceledException )
161
176
{
177
+ _logger . LogTrace ( $ "Got an OperationCancelledException, for '{ projectSnapshot . Key } '") ;
162
178
// Abort work if we get a task canceled exception
163
179
return ;
164
180
}
165
181
catch ( Exception ex )
166
182
{
183
+ _logger . LogTrace ( $ "Got an exception, for '{ projectSnapshot . Key } '") ;
167
184
_logger . LogError ( ex ) ;
168
185
}
169
186
finally
170
187
{
171
188
try
172
189
{
190
+ _logger . LogTrace ( $ "Felt cute, might release a semaphore later, for '{ projectSnapshot . Key } '") ;
191
+
173
192
// Prevent ObjectDisposedException if we've disposed before we got here. The dispose method will release
174
193
// anyway, so we're all good.
175
194
if ( ! cancellationToken . IsCancellationRequested )
176
195
{
196
+ _logger . LogTrace ( $ "Releasing the semaphore, for '{ projectSnapshot . Key } '") ;
177
197
_semaphore . Release ( ) ;
178
198
}
199
+
200
+ _logger . LogTrace ( $ "If you didn't see a log message about releasing a semaphore, we have a problem. (for '{ projectSnapshot . Key } ')") ;
179
201
}
180
202
catch
181
203
{
182
204
// Swallow exceptions that happen from releasing the semaphore.
183
205
}
184
206
}
185
207
208
+ _logger . LogTrace ( $ "All finished for '{ projectSnapshot . Key } '") ;
186
209
OnBackgroundWorkCompleted ( ) ;
187
210
}
188
211
@@ -202,6 +225,8 @@ await _projectManager
202
225
return ProjectWorkspaceState . Default ;
203
226
}
204
227
228
+ _logger . LogTrace ( $ "Starting tag helper discovery for { projectSnapshot . FilePath } ") ;
229
+
205
230
// Specifically not using BeginBlock because we want to capture cases where tag helper discovery never finishes.
206
231
var telemetryId = Guid . NewGuid ( ) ;
207
232
0 commit comments