Esempio n. 1
0
        public void Update_WIthDuplicates_Ignored()
        {
            var queue = new CompilationQueue();

            var range = ImmutableArray.CreateRange(new DesignTimeInputFileChange[]
            {
                new DesignTimeInputFileChange("FileName1", false),
                new DesignTimeInputFileChange("FileName1", false)
            });

            queue.Update(range, ImmutableHashSet.CreateRange(new string[] { "FileName1" }), ImmutableHashSet <string> .Empty, "");

            Assert.Equal(1, queue.Count);
        }
Esempio n. 2
0
        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);
        }
        internal void ProcessDataflowChanges(IProjectVersionedValue <DesignTimeInputsDelta> obj)
        {
            // Cancel any in-progress queue processing
            _compilationCancellationSource?.Cancel();

            DesignTimeInputsDelta delta = obj.Value;

            // add all of the changes to our queue
            _queue.Update(delta.ChangedInputs, delta.Inputs, delta.SharedInputs, delta.TempPEOutputPath);

            // Create a cancellation source so we can cancel the compilation if another message comes through
            _compilationCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(_project.Services.ProjectAsynchronousTasks.UnloadCancellationToken);

            JoinableTask task = _scheduler.ScheduleAsyncTask(ProcessCompileQueueAsync, _compilationCancellationSource.Token);

            // For unit testing purposes, optionally block the thread until the task we scheduled is complete
            if (CompileSynchronously)
            {
                _threadingService.ExecuteSynchronously(() => task.Task);
            }
        }