Exemplo n.º 1
0
        public override Run VisitRun(Run node)
        {
            _run = node;

            if (_originalUriBaseIds != null)
            {
                _run.OriginalUriBaseIds = _run.OriginalUriBaseIds ?? new Dictionary <string, ArtifactLocation>();

                foreach (string key in _originalUriBaseIds.Keys)
                {
                    _run.OriginalUriBaseIds[key] = _originalUriBaseIds[key];
                }
            }

            if (node == null)
            {
                return(null);
            }

            bool scrapeFileReferences = _dataToInsert.HasFlag(OptionallyEmittedData.Hashes) ||
                                        _dataToInsert.HasFlag(OptionallyEmittedData.TextFiles) ||
                                        _dataToInsert.HasFlag(OptionallyEmittedData.BinaryFiles);

            if (scrapeFileReferences)
            {
                var visitor = new AddFileReferencesVisitor();
                visitor.VisitRun(node);
            }

            Run visited = base.VisitRun(node);

            return(visited);
        }
Exemplo n.º 2
0
        public void AddFilesVisitor_PopulateFilesObject()
        {
            string filePath = "file:///DOES NOT/EXIST.cpp";

            var run = new Run();

            run.Results = new List <Result>()
            {
                new Result
                {
                    Locations = new List <Location>()
                    {
                        new Location()
                        {
                            PhysicalLocation = new PhysicalLocation()
                            {
                                FileLocation = new FileLocation
                                {
                                    Uri = new Uri(filePath)
                                }
                            }
                        }
                    }
                }
            };

            run.Files.Should().BeNull();

            var visitor = new AddFileReferencesVisitor();

            visitor.Visit(run);

            run.Files.Count.Should().Be(1);
            run.Files[Uri.EscapeUriString(filePath)].Should().NotBeNull();
        }
Exemplo n.º 3
0
        public override Run VisitRun(Run node)
        {
            if (node != null)
            {
                bool scrapeFileReferences = _dataToInsert.Includes(OptionallyEmittedData.Hashes) ||
                                            _dataToInsert.Includes(OptionallyEmittedData.TextFiles) ||
                                            _dataToInsert.Includes(OptionallyEmittedData.BinaryFiles);

                if (scrapeFileReferences)
                {
                    var visitor = new AddFileReferencesVisitor();
                    visitor.VisitRun(node);
                }

                if (node.Files != null)
                {
                    var keys = node.Files.Keys.ToArray();
                    foreach (var key in keys)
                    {
                        var value = node.Files[key];
                        if (value != null)
                        {
                            node.Files[key] = VisitDictionaryValueNullChecked(key, value);
                        }
                    }
                }
            }

            return(node);
        }
Exemplo n.º 4
0
        public override Run VisitRun(Run node)
        {
            if (node != null)
            {
                bool scrapeFileReferences = _loggingOptions.Includes(LoggingOptions.ComputeFileHashes) ||
                                            _loggingOptions.Includes(LoggingOptions.PersistFileContents);

                if (scrapeFileReferences)
                {
                    var visitor = new AddFileReferencesVisitor();
                    visitor.VisitRun(node);
                }

                if (node.Files != null)
                {
                    var keys = node.Files.Keys.ToArray();
                    foreach (var key in keys)
                    {
                        var value = node.Files[key];
                        if (value != null)
                        {
                            node.Files[key] = VisitDictionaryValueNullChecked(key, value);
                        }
                    }
                }
            }

            return(node);
        }
Exemplo n.º 5
0
        public override Run VisitRun(Run node)
        {
            _run          = node;
            _gitHelper    = new GitHelper(_fileSystem, _processRunner);
            _repoRootUris = new HashSet <Uri>();

            if (_originalUriBaseIds != null)
            {
                _run.OriginalUriBaseIds ??= new Dictionary <string, ArtifactLocation>();

                foreach (string key in _originalUriBaseIds.Keys)
                {
                    _run.OriginalUriBaseIds[key] = _originalUriBaseIds[key];
                }
            }

            if (node == null)
            {
                return(null);
            }

            bool scrapeFileReferences = _dataToInsert.HasFlag(OptionallyEmittedData.Hashes) ||
                                        _dataToInsert.HasFlag(OptionallyEmittedData.TextFiles) ||
                                        _dataToInsert.HasFlag(OptionallyEmittedData.BinaryFiles);

            if (scrapeFileReferences)
            {
                var visitor = new AddFileReferencesVisitor();
                visitor.VisitRun(node);
            }

            Run visited = base.VisitRun(node);

            // After all the ArtifactLocations have been visited,
            if (_run.VersionControlProvenance == null && _dataToInsert.HasFlag(OptionallyEmittedData.VersionControlDetails))
            {
                _run.VersionControlProvenance = CreateVersionControlProvenance();
            }

            return(visited);
        }
Exemplo n.º 6
0
        public override Run VisitRun(Run node)
        {
            _run = node;

            if (node == null)
            {
                return(null);
            }

            bool scrapeFileReferences = _dataToInsert.Includes(OptionallyEmittedData.Hashes) ||
                                        _dataToInsert.Includes(OptionallyEmittedData.TextFiles) ||
                                        _dataToInsert.Includes(OptionallyEmittedData.BinaryFiles);

            if (scrapeFileReferences)
            {
                var visitor = new AddFileReferencesVisitor();
                visitor.VisitRun(node);
            }

            if (node.Files != null)
            {
                // Note, we modify this collection as  we enumerate it.
                // Hence the need to convert to an array here. Otherwise,
                // the standard collection enumerator will throw an
                // exception after we touch the collection.
                var keys = node.Files.Keys.ToArray();
                foreach (string key in keys)
                {
                    var value = node.Files[key];
                    if (value != null)
                    {
                        node.Files[key] = VisitDictionaryValueNullChecked(key, value);
                    }
                }
            }

            return(base.VisitRun(node));
        }