public void Pop_Removes() { var queue = new CompilationQueue(); queue.Push(new QueueItem("FileName", ImmutableHashSet <string> .Empty, "", false)); queue.Pop(); Assert.Equal(0, queue.Count); }
public void Push_UpdatesFileWriteTime() { var queue = new CompilationQueue(); queue.Push(new QueueItem("FileName", ImmutableHashSet <string> .Empty, "", false)); queue.Push(new QueueItem("FileName", ImmutableHashSet <string> .Empty, "", true)); Assert.Equal(1, queue.Count); Assert.True(queue.Pop()?.IgnoreFileWriteTime); }
public void Update_UpdatesFileWriteTime() { var queue = new CompilationQueue(); var range = ImmutableArray.CreateRange(new DesignTimeInputFileChange[] { new DesignTimeInputFileChange("FileName1", false), new DesignTimeInputFileChange("FileName1", true) }); queue.Update(range, ImmutableHashSet.CreateRange(new string[] { "FileName1" }), ImmutableHashSet <string> .Empty, ""); Assert.Equal(1, queue.Count); Assert.True(queue.Pop()?.IgnoreFileWriteTime); }
private Task ProcessCompileQueueAsync(CancellationToken token) { int compileCount = 0; int initialQueueLength = _queue.Count; var compileStopWatch = Stopwatch.StartNew(); return(_activeWorkspaceProjectContextHost.OpenContextForWriteAsync(async accessor => { while (true) { if (IsDisposing || IsDisposed) { return; } // we don't want to pop if we've been cancelled in the time it took to take the write lock, so check just in case. // this may be overkill if (token.IsCancellationRequested) { break; } // Grab the next file to compile off the queue QueueItem?item = _queue.Pop(); if (item == null) { break; } bool cancelled = false; string outputFileName = GetOutputFileName(item.FileName, item.TempPEOutputPath); try { if (await CompileDesignTimeInputAsync(accessor.Context, item.FileName, outputFileName, item.SharedInputs, item.IgnoreFileWriteTime, token)) { compileCount++; } } catch (OperationCanceledException) { cancelled = true; } if (cancelled || token.IsCancellationRequested) { // if the compilation was cancelled, we need to re-add the file so we catch it next time _queue.Push(item); break; } } LogTelemetry(cancelled: token.IsCancellationRequested); })); void LogTelemetry(bool cancelled) { compileStopWatch !.Stop(); _telemetryService.PostProperties(TelemetryEventName.TempPEProcessQueue, new[] { (TelemetryPropertyName.TempPECompileCount, (object)compileCount), (TelemetryPropertyName.TempPEInitialQueueLength, initialQueueLength), (TelemetryPropertyName.TempPECompileWasCancelled, cancelled), (TelemetryPropertyName.TempPECompileDuration, compileStopWatch.ElapsedMilliseconds) });
public void Pop_WhenEmpty_ReturnsNull() { var queue = new CompilationQueue(); Assert.Null(queue.Pop()); }