public void AddEvaluationChanges_CanAddItemWithMetadata()
        {
            var handler = CreateInstance(@"C:\Project\Project.csproj");

            var difference = IProjectChangeDiffFactory.WithAddedItems("A.cs");
            var metadata   = MetadataFactory.Create("A.cs", ("Name", "Value"));

            ApplyProjectEvaluation(handler, 1, difference, metadata);

            var result = handler.Files[@"C:\Project\A.cs"];

            Assert.Equal("Value", result["Name"]);
        }
        public void ApplyProjectEvaluationChanges_WithExistingEvaluationChanges_CanAddChangeMetadata()
        {
            var file    = "A.cs";
            var handler = CreateInstanceWithEvaluationItems(@"C:\Project\Project.csproj", file);

            var difference = IProjectChangeDiffFactory.WithChangedItems(file);
            var metadata   = MetadataFactory.Create(file, ("Name", "Value"));

            ApplyProjectEvaluation(handler, 2, difference, metadata);

            var result = handler.Files[@"C:\Project\A.cs"];

            Assert.Equal("Value", result["Name"]);
        }
Ejemplo n.º 3
0
        public void AddEvaluationChanges_ItemsWithExclusionMetadataAreIgnored()
        {
            var handler = CreateInstance(@"C:\Project\Project.csproj");

            var difference = IProjectChangeDiffFactory.WithAddedItems("A.cs;B.cs;C.cs");
            var metadata   = MetadataFactory.Create("A.cs", ("ExcludeFromCurrentConfiguration", "true"))
                             .Add("B.cs", ("ExcludeFromCurrentConfiguration", "false"));


            ApplyProjectEvaluation(handler, 1, difference, metadata);

            string[] expectedFiles = new[] { @"C:\Project\B.cs", @"C:\Project\C.cs" };
            Assert.Equal(expectedFiles.OrderBy(f => f), handler.FileNames.OrderBy(f => f));
        }
Ejemplo n.º 4
0
        private WorkflowRun ProcessWorkflowInContext(WorkflowRun run, IWorkflowEvent wfEvent)
        {
            var workflow = run.WorkflowBeingRun;

            using (Profiler.Measure("WorkflowRunner.Instance.StartWorkflowInContext " + workflow.Id))
            {
                var stopWatch = StartWorkflowTimer();

                IRunState runState = null;

                try
                {
                    if (!run.IsTemporaryId)
                    {
                        PrecacheWorkflow(run.Id);
                    }

                    using (new SecurityBypassContext())
                    {
                        var metadata = MetadataFactory.Create(workflow);

                        runState = CreateRunState(metadata, run);

                        if (runState.EffectiveSecurityContext == null)
                        {
                            throw new WorkflowMissingOwnerException();
                        }
                    }

                    // Wrap a Security bypass with the effective context. This less us "Pop" to run as the effective context.
                    using (CustomContext.SetContext(runState.EffectiveSecurityContext))
                    {
                        using (new SecurityBypassContext())
                        {
                            if (runState.Metadata.HasViolations)
                            {
                                MarkRunFailedHasErrors(runState);
                            }
                            else if (run.TriggerDepth > WorkflowTriggerHelper.MaxTriggerDepth)
                            {
                                MarkRunFailedTriggerDepth(runState);
                            }
                            else
                            {
                                var isCompleted = ProcessWorkflow(workflow, runState, wfEvent);
                            }
                        }
                    }
                }
                catch (WorkflowRunException ex)
                {
                    MarkRunFailed(runState, ex);

                    if (runState != null)
                    {
                        runState.FlushInternalArgs();
                    }
                }
                catch (Exception ex)
                {
                    MarkRunInternalError(runState, ex);

                    if (runState != null)
                    {
                        runState.FlushInternalArgs();
                    }
                }
                finally
                {
                    if (!Factory.WorkflowRunTaskManager.HasCancelled(runState.RunTaskId))
                    {
                        run = FinalizeRun(runState);
                    }
                }

                EndWorkflowTimer(stopWatch);
            }

            return(run);
        }