protected virtual void Init(Address address, ArtifactLocation artifactLocation, Region region, Region contextRegion, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (address != null)
            {
                Address = new Address(address);
            }

            if (artifactLocation != null)
            {
                ArtifactLocation = new ArtifactLocation(artifactLocation);
            }

            if (region != null)
            {
                Region = new Region(region);
            }

            if (contextRegion != null)
            {
                ContextRegion = new Region(contextRegion);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #2
0
        private void RetrieveFileIndexAndValidate(Run run, ArtifactLocation fileLocation, int expectedFileIndex)
        {
            int fileIndex = run.GetFileIndex(fileLocation, addToFilesTableIfNotPresent: false);

            fileLocation.Index.Should().Be(fileIndex);
            fileIndex.Should().Be(expectedFileIndex);
        }
Пример #3
0
        private void Init(ArtifactLocation artifactLocation, IEnumerable <Replacement> replacements, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (artifactLocation != null)
            {
                ArtifactLocation = new ArtifactLocation(artifactLocation);
            }

            if (replacements != null)
            {
                var destination_0 = new List <Replacement>();
                foreach (var value_0 in replacements)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Replacement(value_0));
                    }
                }

                Replacements = destination_0;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #4
0
        private void Init(Message description, ArtifactLocation location, int parentIndex, int offset, int length, ArtifactRoles roles, string mimeType, ArtifactContent contents, string encoding, string sourceLanguage, IDictionary <string, string> hashes, DateTime lastModifiedTimeUtc, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (description != null)
            {
                Description = new Message(description);
            }

            if (location != null)
            {
                Location = new ArtifactLocation(location);
            }

            ParentIndex = parentIndex;
            Offset      = offset;
            Length      = length;
            Roles       = roles;
            MimeType    = mimeType;
            if (contents != null)
            {
                Contents = new ArtifactContent(contents);
            }

            Encoding       = encoding;
            SourceLanguage = sourceLanguage;
            if (hashes != null)
            {
                Hashes = new Dictionary <string, string>(hashes);
            }

            LastModifiedTimeUtc = lastModifiedTimeUtc;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #5
0
        public void Run_RetrievesExistingFileDataObject()
        {
            Run run = BuildDefaultRunObject();

            ArtifactLocation fileLocation = BuildDefaultFileLocation();

            fileLocation.Index.Should().Be(-1);

            // Retrieve existing file location. Our input file location should have its
            // fileIndex property set as well.
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 1);

            // Repeat look-up with bad file index value. This should succeed and reset
            // the fileIndex to the appropriate value.
            fileLocation       = BuildDefaultFileLocation();
            fileLocation.Index = Int32.MaxValue;
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 1);

            // Now set a unique property bag on the file location. The property bag
            // should not interfere with retrieving the file data object. The property bag should
            // not be modified as a result of retrieving the file data index.
            fileLocation = BuildDefaultFileLocation();
            fileLocation.SetProperty(Guid.NewGuid().ToString(), "");
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 1);

            // Now use a file location that has no url and therefore relies strictly on
            // the index in run.artifacts (i.e., _fileToIndexMap will not be used).
            fileLocation       = new ArtifactLocation();
            fileLocation.Index = 0;
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 0);
        }
Пример #6
0
        public void Run_RetrievesExistingFileDataObject()
        {
            Run run = BuildDefaultRunObject();

            ArtifactLocation fileLocation = BuildDefaultFileLocation();

            fileLocation.Index.Should().Be(-1);

            // Retrieve existing file location. Our input file location should have its
            // fileIndex property set as well.
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 1);

            // Repeat look-up with bad file index value. This should succeed and reset
            // the fileIndex to the appropriate value.
            fileLocation       = BuildDefaultFileLocation();
            fileLocation.Index = Int32.MaxValue;
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 1);

            // Now set a unique property bag on the file location. The property bag
            // should not interfere with retrieving the file data object. The property bag should
            // not be modified as a result of retrieving the file data index.
            fileLocation       = BuildDefaultFileLocation();
            fileLocation.Index = Int32.MaxValue;
            RetrieveFileIndexAndValidate(run, fileLocation, expectedFileIndex: 1);
        }
        public virtual ArtifactLocation VisitArtifactLocation(ArtifactLocation node)
        {
            if (node != null)
            {
            }

            return(node);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ArtifactLocation" /> class from the specified instance.
        /// </summary>
        /// <param name="other">
        /// The instance from which the new instance is to be initialized.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="other" /> is null.
        /// </exception>
        public ArtifactLocation(ArtifactLocation other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Init(other.Uri, other.UriBaseId, other.Index, other.Description, other.Properties);
        }
Пример #9
0
        public Uri ExpandUrisWithUriBaseId(string key, string currentValue = null)
        {
            ArtifactLocation fileLocation = this.OriginalUriBaseIds[key];

            if (fileLocation.UriBaseId == null)
            {
                return(fileLocation.Uri);
            }
            throw new InvalidOperationException("Author this code along with tests for originalUriBaseIds that are nested");
        }
Пример #10
0
        /// <summary>
        /// Attempt to reconstruct a URI, if appropriate, using Run instance
        /// originalUriBaseId and uriBaseId properties. If this method cannot
        /// successfully reconstitute an absolute URI, it will return false
        /// and populate 'resolvedUri' with null.
        /// </summary>
        /// <param name="originalUriBaseIds">The original uri base id values associated with the tool run.</param>
        /// <param name="resolvedUri">The reconstructed absolute URI or null (if an absolute URI cannot be reconstructed).</param>
        /// <returns></returns>
        public bool TryReconstructAbsoluteUri(IDictionary <string, ArtifactLocation> originalUriBaseIds, out Uri resolvedUri)
        {
            resolvedUri = null;

            // If this artifactLocation represents a top level originalUriBaseId, then the value of the URI may be absent.
            if (this.Uri == null)
            {
                return(false);
            }

            if (this.Uri.IsAbsoluteUri)
            {
                resolvedUri = this.Uri;
                return(true);
            }

            // The URI is a relative reference. Do we have the information we need to resolve it?
            if (originalUriBaseIds == null)
            {
                return(false);
            }

            // Walk up the UriBaseId chain until we find an ArtifactLocation object:
            //    - whose Uri is absolute (success), or
            //      which lacks a UriBaseId property (failure), or
            //    - whose UriBaseId is not defined in originalUriBaseIds (failure), or
            //    - which lacks a Uri property (failure).
            ArtifactLocation artifactLocation = this;
            Uri stemUri = this.Uri;

            while (!stemUri.IsAbsoluteUri)
            {
                if (string.IsNullOrEmpty(artifactLocation.UriBaseId) ||
                    !originalUriBaseIds.TryGetValue(artifactLocation.UriBaseId, out artifactLocation) ||
                    artifactLocation.Uri == null)
                {
                    return(false);
                }

                // I'd like to use the ctor new Uri(baseUri, relativeUri) here, but it fails with
                // ArgumentOutOfRangeException, perhaps because it doesn't like the baseUri argument
                // to be relative. So...
                string artifactLocationOriginalUriString = artifactLocation.Uri.OriginalString;
                if (!artifactLocationOriginalUriString.EndsWith("/"))
                {
                    artifactLocationOriginalUriString += "/";
                }
                stemUri = new Uri(artifactLocationOriginalUriString + stemUri.OriginalString, UriKind.RelativeOrAbsolute);
            }

            // If we got here, we found an absolute URI.
            resolvedUri = stemUri;
            return(true);
        }
Пример #11
0
        protected virtual void Init(Message description, ArtifactLocation artifactLocation, IEnumerable <Region> regions, IEnumerable <Rectangle> rectangles, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (description != null)
            {
                Description = new Message(description);
            }

            if (artifactLocation != null)
            {
                ArtifactLocation = new ArtifactLocation(artifactLocation);
            }

            if (regions != null)
            {
                var destination_0 = new List <Region>();
                foreach (var value_0 in regions)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Region(value_0));
                    }
                }

                Regions = destination_0;
            }

            if (rectangles != null)
            {
                var destination_1 = new List <Rectangle>();
                foreach (var value_1 in rectangles)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Rectangle(value_1));
                    }
                }

                Rectangles = destination_1;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #12
0
        protected virtual void Init(ArtifactLocation displayBase, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (displayBase != null)
            {
                DisplayBase = new ArtifactLocation(displayBase);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #13
0
        private void Init(string toolComponentGuid, ArtifactLocation location, string semanticVersion, bool partialTranslation, object globalMessageStrings, IEnumerable <ReportingDescriptorTranslation> reportingDescriptors, IEnumerable <ReportingDescriptorTranslation> notificationDescriptors, IDictionary <string, SerializedPropertyInfo> properties)
        {
            ToolComponentGuid = toolComponentGuid;
            if (location != null)
            {
                Location = new ArtifactLocation(location);
            }

            SemanticVersion      = semanticVersion;
            PartialTranslation   = partialTranslation;
            GlobalMessageStrings = globalMessageStrings;
            if (reportingDescriptors != null)
            {
                var destination_0 = new List <ReportingDescriptorTranslation>();
                foreach (var value_0 in reportingDescriptors)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new ReportingDescriptorTranslation(value_0));
                    }
                }

                ReportingDescriptors = destination_0;
            }

            if (notificationDescriptors != null)
            {
                var destination_1 = new List <ReportingDescriptorTranslation>();
                foreach (var value_1 in notificationDescriptors)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new ReportingDescriptorTranslation(value_1));
                    }
                }

                NotificationDescriptors = destination_1;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #14
0
        private void Init(ArtifactLocation artifactLocation, string instanceGuid, int itemCount, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (artifactLocation != null)
            {
                ArtifactLocation = new ArtifactLocation(artifactLocation);
            }

            InstanceGuid = instanceGuid;
            ItemCount    = itemCount;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
        private void Init(ArtifactLocation location, string guid, int itemCount, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (location != null)
            {
                Location = new ArtifactLocation(location);
            }

            Guid      = guid;
            ItemCount = itemCount;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #16
0
        private void InitializeFileToIndexMap()
        {
            _fileToIndexMap = new Dictionary <ArtifactLocation, int>(ArtifactLocation.ValueComparer);

            // First, we'll initialize our file object to index map
            // with any files that already exist in the table
            for (int i = 0; i < this.Artifacts?.Count; i++)
            {
                Artifact fileData = this.Artifacts[i];

                var fileLocation = new ArtifactLocation
                {
                    Uri       = fileData.Location?.Uri,
                    UriBaseId = fileData.Location?.UriBaseId,
                };

                _fileToIndexMap[fileLocation] = i;
            }
        }
        protected virtual void Init(Uri repositoryUri, string revisionId, string branch, string revisionTag, DateTime asOfTimeUtc, ArtifactLocation mappedTo, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (repositoryUri != null)
            {
                RepositoryUri = new Uri(repositoryUri.OriginalString, repositoryUri.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative);
            }

            RevisionId  = revisionId;
            Branch      = branch;
            RevisionTag = revisionTag;
            AsOfTimeUtc = asOfTimeUtc;
            if (mappedTo != null)
            {
                MappedTo = new ArtifactLocation(mappedTo);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
        public void SarifConsolidator_ArtifactLocation()
        {
            SarifConsolidator consolidator = new SarifConsolidator(new Run());

            // If Index set, remove Uri and UriBaseId
            ArtifactLocation a         = new ArtifactLocation(SampleArtifactLocation);
            ArtifactLocation aExpected = new ArtifactLocation(SampleArtifactLocationTrimmed);

            consolidator.Trim(a);
            Assert.Null(a.Uri);
            Assert.True(ArtifactLocation.ValueComparer.Equals(aExpected, a));

            // Uri not removed when no Index
            a = new ArtifactLocation()
            {
                Uri = SampleUri, UriBaseId = "Root"
            };
            aExpected = new ArtifactLocation(a);

            consolidator.Trim(a);
            Assert.Equal(SampleUri, a.Uri);
            Assert.True(ArtifactLocation.ValueComparer.Equals(aExpected, a));
        }
Пример #19
0
        private void Init(int id, ArtifactLocation artifactLocation, Region region, Region contextRegion, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Id = id;
            if (artifactLocation != null)
            {
                ArtifactLocation = new ArtifactLocation(artifactLocation);
            }

            if (region != null)
            {
                Region = new Region(region);
            }

            if (contextRegion != null)
            {
                ContextRegion = new Region(contextRegion);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #20
0
        public int GetFileIndex(
            ArtifactLocation fileLocation,
            bool addToFilesTableIfNotPresent   = true,
            OptionallyEmittedData dataToInsert = OptionallyEmittedData.None,
            Encoding encoding = null,
            HashData hashData = null)
        {
            if (fileLocation == null)
            {
                throw new ArgumentNullException(nameof(fileLocation));
            }

            if (this.Artifacts == null || this.Artifacts.Count == 0)
            {
                if (!addToFilesTableIfNotPresent)
                {
                    return(-1);
                }
            }

            if (_fileToIndexMap == null)
            {
                InitializeFileToIndexMap();
            }

            if (fileLocation.Uri == null)
            {
                // We only have a file index, so just return it.
                return(fileLocation.Index);
            }

            // Strictly speaking, some elements that may contribute to a files table
            // key are case sensitive, e.g., everything but the schema and protocol of a
            // web URI. We don't have a proper comparer implementation that can handle
            // all cases. For now, we cover the Windows happy path, which assumes that
            // most URIs in log files are file paths (which are case-insensitive)
            //
            // Tracking item for an improved comparer:
            // https://github.com/Microsoft/sarif-sdk/issues/973

            // When we perform a files table look-up, only the uri and uriBaseId
            // are relevant; these properties together comprise the unique identity
            // of the file object. The file index, of course, does not relate to the
            // file identity. We consciously exclude the properties bag as well.

            // We will normalize the input fileLocation.Uri to make URIs more consistent
            // throughout the emitted log.
            fileLocation.Uri = new Uri(UriHelper.MakeValidUri(fileLocation.Uri.OriginalString), UriKind.RelativeOrAbsolute);

            var filesTableKey = new ArtifactLocation
            {
                Uri       = fileLocation.Uri,
                UriBaseId = fileLocation.UriBaseId
            };

            if (!_fileToIndexMap.TryGetValue(filesTableKey, out int fileIndex))
            {
                if (addToFilesTableIfNotPresent)
                {
                    this.Artifacts = this.Artifacts ?? new List <Artifact>();
                    fileIndex      = this.Artifacts.Count;

                    var fileData = Artifact.Create(
                        filesTableKey.Uri,
                        dataToInsert,
                        hashData: hashData,
                        encoding: null);

                    // Copy ArtifactLocation to ensure changes to Result copy don't affect new Run.Artifacts copy
                    fileData.Location = new ArtifactLocation(fileLocation);

                    this.Artifacts.Add(fileData);

                    _fileToIndexMap[filesTableKey] = fileIndex;
                }
                else
                {
                    // We did not find the item. The call was not configured to add the entry.
                    // Return the default value that indicates the item isn't present.
                    fileIndex = -1;
                }
            }

            fileLocation.Index = fileIndex;
            return(fileIndex);
        }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArtifactChange" /> class from the supplied values.
 /// </summary>
 /// <param name="artifactLocation">
 /// An initialization value for the <see cref="P:ArtifactLocation" /> property.
 /// </param>
 /// <param name="replacements">
 /// An initialization value for the <see cref="P:Replacements" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public ArtifactChange(ArtifactLocation artifactLocation, IEnumerable <Replacement> replacements, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(artifactLocation, replacements, properties);
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Result" /> class from the supplied values.
 /// </summary>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P:RuleId" /> property.
 /// </param>
 /// <param name="ruleIndex">
 /// An initialization value for the <see cref="P:RuleIndex" /> property.
 /// </param>
 /// <param name="extensionIndex">
 /// An initialization value for the <see cref="P:ExtensionIndex" /> property.
 /// </param>
 /// <param name="kind">
 /// An initialization value for the <see cref="P:Kind" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P:Level" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P:Message" /> property.
 /// </param>
 /// <param name="analysisTarget">
 /// An initialization value for the <see cref="P:AnalysisTarget" /> property.
 /// </param>
 /// <param name="locations">
 /// An initialization value for the <see cref="P:Locations" /> property.
 /// </param>
 /// <param name="instanceGuid">
 /// An initialization value for the <see cref="P:InstanceGuid" /> property.
 /// </param>
 /// <param name="correlationGuid">
 /// An initialization value for the <see cref="P:CorrelationGuid" /> property.
 /// </param>
 /// <param name="occurrenceCount">
 /// An initialization value for the <see cref="P:OccurrenceCount" /> property.
 /// </param>
 /// <param name="partialFingerprints">
 /// An initialization value for the <see cref="P:PartialFingerprints" /> property.
 /// </param>
 /// <param name="fingerprints">
 /// An initialization value for the <see cref="P:Fingerprints" /> property.
 /// </param>
 /// <param name="stacks">
 /// An initialization value for the <see cref="P:Stacks" /> property.
 /// </param>
 /// <param name="codeFlows">
 /// An initialization value for the <see cref="P:CodeFlows" /> property.
 /// </param>
 /// <param name="graphs">
 /// An initialization value for the <see cref="P:Graphs" /> property.
 /// </param>
 /// <param name="graphTraversals">
 /// An initialization value for the <see cref="P:GraphTraversals" /> property.
 /// </param>
 /// <param name="relatedLocations">
 /// An initialization value for the <see cref="P:RelatedLocations" /> property.
 /// </param>
 /// <param name="suppressionStates">
 /// An initialization value for the <see cref="P:SuppressionStates" /> property.
 /// </param>
 /// <param name="baselineState">
 /// An initialization value for the <see cref="P:BaselineState" /> property.
 /// </param>
 /// <param name="rank">
 /// An initialization value for the <see cref="P:Rank" /> property.
 /// </param>
 /// <param name="attachments">
 /// An initialization value for the <see cref="P:Attachments" /> property.
 /// </param>
 /// <param name="hostedViewerUri">
 /// An initialization value for the <see cref="P:HostedViewerUri" /> property.
 /// </param>
 /// <param name="workItemUris">
 /// An initialization value for the <see cref="P:WorkItemUris" /> property.
 /// </param>
 /// <param name="provenance">
 /// An initialization value for the <see cref="P:Provenance" /> property.
 /// </param>
 /// <param name="fixes">
 /// An initialization value for the <see cref="P:Fixes" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Result(string ruleId, int ruleIndex, int extensionIndex, ResultKind kind, FailureLevel level, Message message, ArtifactLocation analysisTarget, IEnumerable <Location> locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary <string, string> partialFingerprints, IDictionary <string, string> fingerprints, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IDictionary <string, Graph> graphs, IEnumerable <GraphTraversal> graphTraversals, IEnumerable <Location> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, double rank, IEnumerable <Attachment> attachments, Uri hostedViewerUri, IEnumerable <Uri> workItemUris, ResultProvenance provenance, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(ruleId, ruleIndex, extensionIndex, kind, level, message, analysisTarget, locations, instanceGuid, correlationGuid, occurrenceCount, partialFingerprints, fingerprints, stacks, codeFlows, graphs, graphTraversals, relatedLocations, suppressionStates, baselineState, rank, attachments, hostedViewerUri, workItemUris, provenance, fixes, properties);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExternalPropertyFileReference" /> class from the supplied values.
 /// </summary>
 /// <param name="location">
 /// An initialization value for the <see cref="P:Location" /> property.
 /// </param>
 /// <param name="guid">
 /// An initialization value for the <see cref="P:Guid" /> property.
 /// </param>
 /// <param name="itemCount">
 /// An initialization value for the <see cref="P:ItemCount" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public ExternalPropertyFileReference(ArtifactLocation location, string guid, int itemCount, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(location, guid, itemCount, properties);
 }
Пример #24
0
        private void Init(string commandLine, IEnumerable <string> arguments, IEnumerable <ArtifactLocation> responseFiles, DateTime startTimeUtc, DateTime endTimeUtc, int exitCode, IEnumerable <ReportingConfigurationOverride> reportingConfigurationOverrides, IEnumerable <Notification> toolNotifications, IEnumerable <Notification> configurationNotifications, string exitCodeDescription, string exitSignalName, int exitSignalNumber, string processStartFailureMessage, bool toolExecutionSuccessful, string machine, string account, int processId, ArtifactLocation executableLocation, ArtifactLocation workingDirectory, IDictionary <string, string> environmentVariables, ArtifactLocation stdin, ArtifactLocation stdout, ArtifactLocation stderr, ArtifactLocation stdoutStderr, IDictionary <string, SerializedPropertyInfo> properties)
        {
            CommandLine = commandLine;
            if (arguments != null)
            {
                var destination_0 = new List <string>();
                foreach (var value_0 in arguments)
                {
                    destination_0.Add(value_0);
                }

                Arguments = destination_0;
            }

            if (responseFiles != null)
            {
                var destination_1 = new List <ArtifactLocation>();
                foreach (var value_1 in responseFiles)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new ArtifactLocation(value_1));
                    }
                }

                ResponseFiles = destination_1;
            }

            StartTimeUtc = startTimeUtc;
            EndTimeUtc   = endTimeUtc;
            ExitCode     = exitCode;
            if (reportingConfigurationOverrides != null)
            {
                var destination_2 = new List <ReportingConfigurationOverride>();
                foreach (var value_2 in reportingConfigurationOverrides)
                {
                    if (value_2 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new ReportingConfigurationOverride(value_2));
                    }
                }

                ReportingConfigurationOverrides = destination_2;
            }

            if (toolNotifications != null)
            {
                var destination_3 = new List <Notification>();
                foreach (var value_3 in toolNotifications)
                {
                    if (value_3 == null)
                    {
                        destination_3.Add(null);
                    }
                    else
                    {
                        destination_3.Add(new Notification(value_3));
                    }
                }

                ToolNotifications = destination_3;
            }

            if (configurationNotifications != null)
            {
                var destination_4 = new List <Notification>();
                foreach (var value_4 in configurationNotifications)
                {
                    if (value_4 == null)
                    {
                        destination_4.Add(null);
                    }
                    else
                    {
                        destination_4.Add(new Notification(value_4));
                    }
                }

                ConfigurationNotifications = destination_4;
            }

            ExitCodeDescription        = exitCodeDescription;
            ExitSignalName             = exitSignalName;
            ExitSignalNumber           = exitSignalNumber;
            ProcessStartFailureMessage = processStartFailureMessage;
            ToolExecutionSuccessful    = toolExecutionSuccessful;
            Machine   = machine;
            Account   = account;
            ProcessId = processId;
            if (executableLocation != null)
            {
                ExecutableLocation = new ArtifactLocation(executableLocation);
            }

            if (workingDirectory != null)
            {
                WorkingDirectory = new ArtifactLocation(workingDirectory);
            }

            if (environmentVariables != null)
            {
                EnvironmentVariables = new Dictionary <string, string>(environmentVariables);
            }

            if (stdin != null)
            {
                Stdin = new ArtifactLocation(stdin);
            }

            if (stdout != null)
            {
                Stdout = new ArtifactLocation(stdout);
            }

            if (stderr != null)
            {
                Stderr = new ArtifactLocation(stderr);
            }

            if (stdoutStderr != null)
            {
                StdoutStderr = new ArtifactLocation(stdoutStderr);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #25
0
        private void Init(string ruleId, int ruleIndex, int extensionIndex, ResultKind kind, FailureLevel level, Message message, ArtifactLocation analysisTarget, IEnumerable <Location> locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary <string, string> partialFingerprints, IDictionary <string, string> fingerprints, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IDictionary <string, Graph> graphs, IEnumerable <GraphTraversal> graphTraversals, IEnumerable <Location> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, double rank, IEnumerable <Attachment> attachments, Uri hostedViewerUri, IEnumerable <Uri> workItemUris, ResultProvenance provenance, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
        {
            RuleId             = ruleId;
            RuleIndex          = ruleIndex;
            RuleExtensionIndex = extensionIndex;
            Kind  = kind;
            Level = level;
            if (message != null)
            {
                Message = new Message(message);
            }

            if (analysisTarget != null)
            {
                AnalysisTarget = new ArtifactLocation(analysisTarget);
            }

            if (locations != null)
            {
                var destination_0 = new List <Location>();
                foreach (var value_0 in locations)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Location(value_0));
                    }
                }

                Locations = destination_0;
            }

            InstanceGuid    = instanceGuid;
            CorrelationGuid = correlationGuid;
            OccurrenceCount = occurrenceCount;
            if (partialFingerprints != null)
            {
                PartialFingerprints = new Dictionary <string, string>(partialFingerprints);
            }

            if (fingerprints != null)
            {
                Fingerprints = new Dictionary <string, string>(fingerprints);
            }

            if (stacks != null)
            {
                var destination_1 = new List <Stack>();
                foreach (var value_1 in stacks)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Stack(value_1));
                    }
                }

                Stacks = destination_1;
            }

            if (codeFlows != null)
            {
                var destination_2 = new List <CodeFlow>();
                foreach (var value_2 in codeFlows)
                {
                    if (value_2 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new CodeFlow(value_2));
                    }
                }

                CodeFlows = destination_2;
            }

            if (graphs != null)
            {
                Graphs = new Dictionary <string, Graph>();
                foreach (var value_3 in graphs)
                {
                    Graphs.Add(value_3.Key, new Graph(value_3.Value));
                }
            }

            if (graphTraversals != null)
            {
                var destination_3 = new List <GraphTraversal>();
                foreach (var value_4 in graphTraversals)
                {
                    if (value_4 == null)
                    {
                        destination_3.Add(null);
                    }
                    else
                    {
                        destination_3.Add(new GraphTraversal(value_4));
                    }
                }

                GraphTraversals = destination_3;
            }

            if (relatedLocations != null)
            {
                var destination_4 = new List <Location>();
                foreach (var value_5 in relatedLocations)
                {
                    if (value_5 == null)
                    {
                        destination_4.Add(null);
                    }
                    else
                    {
                        destination_4.Add(new Location(value_5));
                    }
                }

                RelatedLocations = destination_4;
            }

            SuppressionStates = suppressionStates;
            BaselineState     = baselineState;
            Rank = rank;
            if (attachments != null)
            {
                var destination_5 = new List <Attachment>();
                foreach (var value_6 in attachments)
                {
                    if (value_6 == null)
                    {
                        destination_5.Add(null);
                    }
                    else
                    {
                        destination_5.Add(new Attachment(value_6));
                    }
                }

                Attachments = destination_5;
            }

            if (hostedViewerUri != null)
            {
                HostedViewerUri = new Uri(hostedViewerUri.OriginalString, hostedViewerUri.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative);
            }

            if (workItemUris != null)
            {
                var destination_6 = new List <Uri>();
                foreach (var value_7 in workItemUris)
                {
                    destination_6.Add(value_7);
                }

                WorkItemUris = destination_6;
            }

            if (provenance != null)
            {
                Provenance = new ResultProvenance(provenance);
            }

            if (fixes != null)
            {
                var destination_7 = new List <Fix>();
                foreach (var value_8 in fixes)
                {
                    if (value_8 == null)
                    {
                        destination_7.Add(null);
                    }
                    else
                    {
                        destination_7.Add(new Fix(value_8));
                    }
                }

                Fixes = destination_7;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Artifact" /> class from the supplied values.
 /// </summary>
 /// <param name="description">
 /// An initialization value for the <see cref="P:Description" /> property.
 /// </param>
 /// <param name="location">
 /// An initialization value for the <see cref="P:Location" /> property.
 /// </param>
 /// <param name="parentIndex">
 /// An initialization value for the <see cref="P:ParentIndex" /> property.
 /// </param>
 /// <param name="offset">
 /// An initialization value for the <see cref="P:Offset" /> property.
 /// </param>
 /// <param name="length">
 /// An initialization value for the <see cref="P:Length" /> property.
 /// </param>
 /// <param name="roles">
 /// An initialization value for the <see cref="P:Roles" /> property.
 /// </param>
 /// <param name="mimeType">
 /// An initialization value for the <see cref="P:MimeType" /> property.
 /// </param>
 /// <param name="contents">
 /// An initialization value for the <see cref="P:Contents" /> property.
 /// </param>
 /// <param name="encoding">
 /// An initialization value for the <see cref="P:Encoding" /> property.
 /// </param>
 /// <param name="sourceLanguage">
 /// An initialization value for the <see cref="P:SourceLanguage" /> property.
 /// </param>
 /// <param name="hashes">
 /// An initialization value for the <see cref="P:Hashes" /> property.
 /// </param>
 /// <param name="lastModifiedTimeUtc">
 /// An initialization value for the <see cref="P:LastModifiedTimeUtc" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Artifact(Message description, ArtifactLocation location, int parentIndex, int offset, int length, ArtifactRoles roles, string mimeType, ArtifactContent contents, string encoding, string sourceLanguage, IDictionary <string, string> hashes, DateTime lastModifiedTimeUtc, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(description, location, parentIndex, offset, length, roles, mimeType, contents, encoding, sourceLanguage, hashes, lastModifiedTimeUtc, properties);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PhysicalLocation" /> class from the supplied values.
 /// </summary>
 /// <param name="address">
 /// An initialization value for the <see cref="P:Address" /> property.
 /// </param>
 /// <param name="artifactLocation">
 /// An initialization value for the <see cref="P:ArtifactLocation" /> property.
 /// </param>
 /// <param name="region">
 /// An initialization value for the <see cref="P:Region" /> property.
 /// </param>
 /// <param name="contextRegion">
 /// An initialization value for the <see cref="P:ContextRegion" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public PhysicalLocation(Address address, ArtifactLocation artifactLocation, Region region, Region contextRegion, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(address, artifactLocation, region, contextRegion, properties);
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Attachment" /> class from the supplied values.
 /// </summary>
 /// <param name="description">
 /// An initialization value for the <see cref="P:Description" /> property.
 /// </param>
 /// <param name="artifactLocation">
 /// An initialization value for the <see cref="P:ArtifactLocation" /> property.
 /// </param>
 /// <param name="regions">
 /// An initialization value for the <see cref="P:Regions" /> property.
 /// </param>
 /// <param name="rectangles">
 /// An initialization value for the <see cref="P:Rectangles" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Attachment(Message description, ArtifactLocation artifactLocation, IEnumerable <Region> regions, IEnumerable <Rectangle> rectangles, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(description, artifactLocation, regions, rectangles, properties);
 }
 public bool ValueEquals(ArtifactLocation other) => ValueComparer.Equals(this, other);
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Invocation" /> class from the supplied values.
 /// </summary>
 /// <param name="commandLine">
 /// An initialization value for the <see cref="P:CommandLine" /> property.
 /// </param>
 /// <param name="arguments">
 /// An initialization value for the <see cref="P:Arguments" /> property.
 /// </param>
 /// <param name="responseFiles">
 /// An initialization value for the <see cref="P:ResponseFiles" /> property.
 /// </param>
 /// <param name="startTimeUtc">
 /// An initialization value for the <see cref="P:StartTimeUtc" /> property.
 /// </param>
 /// <param name="endTimeUtc">
 /// An initialization value for the <see cref="P:EndTimeUtc" /> property.
 /// </param>
 /// <param name="exitCode">
 /// An initialization value for the <see cref="P:ExitCode" /> property.
 /// </param>
 /// <param name="reportingConfigurationOverrides">
 /// An initialization value for the <see cref="P:ReportingConfigurationOverrides" /> property.
 /// </param>
 /// <param name="toolNotifications">
 /// An initialization value for the <see cref="P:ToolNotifications" /> property.
 /// </param>
 /// <param name="configurationNotifications">
 /// An initialization value for the <see cref="P:ConfigurationNotifications" /> property.
 /// </param>
 /// <param name="exitCodeDescription">
 /// An initialization value for the <see cref="P:ExitCodeDescription" /> property.
 /// </param>
 /// <param name="exitSignalName">
 /// An initialization value for the <see cref="P:ExitSignalName" /> property.
 /// </param>
 /// <param name="exitSignalNumber">
 /// An initialization value for the <see cref="P:ExitSignalNumber" /> property.
 /// </param>
 /// <param name="processStartFailureMessage">
 /// An initialization value for the <see cref="P:ProcessStartFailureMessage" /> property.
 /// </param>
 /// <param name="toolExecutionSuccessful">
 /// An initialization value for the <see cref="P:ToolExecutionSuccessful" /> property.
 /// </param>
 /// <param name="machine">
 /// An initialization value for the <see cref="P:Machine" /> property.
 /// </param>
 /// <param name="account">
 /// An initialization value for the <see cref="P:Account" /> property.
 /// </param>
 /// <param name="processId">
 /// An initialization value for the <see cref="P:ProcessId" /> property.
 /// </param>
 /// <param name="executableLocation">
 /// An initialization value for the <see cref="P:ExecutableLocation" /> property.
 /// </param>
 /// <param name="workingDirectory">
 /// An initialization value for the <see cref="P:WorkingDirectory" /> property.
 /// </param>
 /// <param name="environmentVariables">
 /// An initialization value for the <see cref="P:EnvironmentVariables" /> property.
 /// </param>
 /// <param name="stdin">
 /// An initialization value for the <see cref="P:Stdin" /> property.
 /// </param>
 /// <param name="stdout">
 /// An initialization value for the <see cref="P:Stdout" /> property.
 /// </param>
 /// <param name="stderr">
 /// An initialization value for the <see cref="P:Stderr" /> property.
 /// </param>
 /// <param name="stdoutStderr">
 /// An initialization value for the <see cref="P:StdoutStderr" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Invocation(string commandLine, IEnumerable <string> arguments, IEnumerable <ArtifactLocation> responseFiles, DateTime startTimeUtc, DateTime endTimeUtc, int exitCode, IEnumerable <ReportingConfigurationOverride> reportingConfigurationOverrides, IEnumerable <Notification> toolNotifications, IEnumerable <Notification> configurationNotifications, string exitCodeDescription, string exitSignalName, int exitSignalNumber, string processStartFailureMessage, bool toolExecutionSuccessful, string machine, string account, int processId, ArtifactLocation executableLocation, ArtifactLocation workingDirectory, IDictionary <string, string> environmentVariables, ArtifactLocation stdin, ArtifactLocation stdout, ArtifactLocation stderr, ArtifactLocation stdoutStderr, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(commandLine, arguments, responseFiles, startTimeUtc, endTimeUtc, exitCode, reportingConfigurationOverrides, toolNotifications, configurationNotifications, exitCodeDescription, exitSignalName, exitSignalNumber, processStartFailureMessage, toolExecutionSuccessful, machine, account, processId, executableLocation, workingDirectory, environmentVariables, stdin, stdout, stderr, stdoutStderr, properties);
 }