コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ToolComponentReference" /> 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 ToolComponentReference(ToolComponentReference other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Init(other.Name, other.Index, other.Guid, other.Properties);
        }
コード例 #2
0
        protected virtual void Init(string id, int index, string guid, ToolComponentReference toolComponent, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Id    = id;
            Index = index;
            Guid  = guid;
            if (toolComponent != null)
            {
                ToolComponent = new ToolComponentReference(toolComponent);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
コード例 #3
0
        /// <summary>
        ///  Find the ToolComponent corresponding to a ToolComponentReference.
        /// </summary>
        /// <param name="reference">ToolComponentReference to resolve</param>
        /// <returns>ToolComponent for reference</returns>
        public ToolComponent GetToolComponentFromReference(ToolComponentReference reference)
        {
            // Follows SARIF Spec 3.54.2 (toolComponent lookup)

            // No Reference: Driver
            if (reference == null)
            {
                return(this.Driver);
            }

            // Lookup by Index if present
            if (reference.Index != -1)
            {
                if (reference.Index >= this.Extensions?.Count)
                {
                    throw new ArgumentOutOfRangeException($"ToolComponentReference referred to index {reference.Index}, but tool only has {this.Extensions?.Count ?? 0} components.");
                }

                return(this.Extensions[reference.Index]);
            }

            // Lookup by GUID if present
            if (!string.IsNullOrEmpty(reference.Guid))
            {
                if (this.Extensions != null)
                {
                    foreach (ToolComponent component in this.Extensions)
                    {
                        if (component.Guid == reference.Guid)
                        {
                            return(component);
                        }
                    }
                }

                throw new ArgumentException($"ToolComponentReference referred to Guid {reference.Guid}, which was not found in this.Extensions.");
            }

            // Neither specified? Driver.
            return(this.Driver);
        }
コード例 #4
0
        protected virtual void Init(string guid, string name, string organization, string product, string productSuite, MultiformatMessageString shortDescription, MultiformatMessageString fullDescription, string fullName, string version, string semanticVersion, string dottedQuadFileVersion, string releaseDateUtc, Uri downloadUri, Uri informationUri, IDictionary <string, MultiformatMessageString> globalMessageStrings, IEnumerable <ReportingDescriptor> notifications, IEnumerable <ReportingDescriptor> rules, IEnumerable <ReportingDescriptor> taxa, IEnumerable <ArtifactLocation> locations, string language, ToolComponentContents contents, bool isComprehensive, string localizedDataSemanticVersion, string minimumRequiredLocalizedDataSemanticVersion, ToolComponentReference associatedComponent, TranslationMetadata translationMetadata, IEnumerable <ToolComponentReference> supportedTaxonomies, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Guid         = guid;
            Name         = name;
            Organization = organization;
            Product      = product;
            ProductSuite = productSuite;
            if (shortDescription != null)
            {
                ShortDescription = new MultiformatMessageString(shortDescription);
            }

            if (fullDescription != null)
            {
                FullDescription = new MultiformatMessageString(fullDescription);
            }

            FullName              = fullName;
            Version               = version;
            SemanticVersion       = semanticVersion;
            DottedQuadFileVersion = dottedQuadFileVersion;
            ReleaseDateUtc        = releaseDateUtc;
            if (downloadUri != null)
            {
                DownloadUri = new Uri(downloadUri.OriginalString, downloadUri.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative);
            }

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

            if (globalMessageStrings != null)
            {
                GlobalMessageStrings = new Dictionary <string, MultiformatMessageString>();
                foreach (var value_0 in globalMessageStrings)
                {
                    GlobalMessageStrings.Add(value_0.Key, new MultiformatMessageString(value_0.Value));
                }
            }

            if (notifications != null)
            {
                var destination_0 = new List <ReportingDescriptor>();
                foreach (var value_1 in notifications)
                {
                    if (value_1 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new ReportingDescriptor(value_1));
                    }
                }

                Notifications = destination_0;
            }

            if (rules != null)
            {
                var destination_1 = new List <ReportingDescriptor>();
                foreach (var value_2 in rules)
                {
                    if (value_2 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new ReportingDescriptor(value_2));
                    }
                }

                Rules = destination_1;
            }

            if (taxa != null)
            {
                var destination_2 = new List <ReportingDescriptor>();
                foreach (var value_3 in taxa)
                {
                    if (value_3 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new ReportingDescriptor(value_3));
                    }
                }

                Taxa = destination_2;
            }

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

                Locations = destination_3;
            }

            Language        = language;
            Contents        = contents;
            IsComprehensive = isComprehensive;
            LocalizedDataSemanticVersion = localizedDataSemanticVersion;
            MinimumRequiredLocalizedDataSemanticVersion = minimumRequiredLocalizedDataSemanticVersion;
            if (associatedComponent != null)
            {
                AssociatedComponent = new ToolComponentReference(associatedComponent);
            }

            if (translationMetadata != null)
            {
                TranslationMetadata = new TranslationMetadata(translationMetadata);
            }

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

                SupportedTaxonomies = destination_4;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolComponent" /> class from the supplied values.
 /// </summary>
 /// <param name="guid">
 /// An initialization value for the <see cref="P:Guid" /> property.
 /// </param>
 /// <param name="name">
 /// An initialization value for the <see cref="P:Name" /> property.
 /// </param>
 /// <param name="organization">
 /// An initialization value for the <see cref="P:Organization" /> property.
 /// </param>
 /// <param name="product">
 /// An initialization value for the <see cref="P:Product" /> property.
 /// </param>
 /// <param name="productSuite">
 /// An initialization value for the <see cref="P:ProductSuite" /> property.
 /// </param>
 /// <param name="shortDescription">
 /// An initialization value for the <see cref="P:ShortDescription" /> property.
 /// </param>
 /// <param name="fullDescription">
 /// An initialization value for the <see cref="P:FullDescription" /> property.
 /// </param>
 /// <param name="fullName">
 /// An initialization value for the <see cref="P:FullName" /> property.
 /// </param>
 /// <param name="version">
 /// An initialization value for the <see cref="P:Version" /> property.
 /// </param>
 /// <param name="semanticVersion">
 /// An initialization value for the <see cref="P:SemanticVersion" /> property.
 /// </param>
 /// <param name="dottedQuadFileVersion">
 /// An initialization value for the <see cref="P:DottedQuadFileVersion" /> property.
 /// </param>
 /// <param name="releaseDateUtc">
 /// An initialization value for the <see cref="P:ReleaseDateUtc" /> property.
 /// </param>
 /// <param name="downloadUri">
 /// An initialization value for the <see cref="P:DownloadUri" /> property.
 /// </param>
 /// <param name="informationUri">
 /// An initialization value for the <see cref="P:InformationUri" /> property.
 /// </param>
 /// <param name="globalMessageStrings">
 /// An initialization value for the <see cref="P:GlobalMessageStrings" /> property.
 /// </param>
 /// <param name="notifications">
 /// An initialization value for the <see cref="P:Notifications" /> property.
 /// </param>
 /// <param name="rules">
 /// An initialization value for the <see cref="P:Rules" /> property.
 /// </param>
 /// <param name="taxa">
 /// An initialization value for the <see cref="P:Taxa" /> property.
 /// </param>
 /// <param name="locations">
 /// An initialization value for the <see cref="P:Locations" /> property.
 /// </param>
 /// <param name="language">
 /// An initialization value for the <see cref="P:Language" /> property.
 /// </param>
 /// <param name="contents">
 /// An initialization value for the <see cref="P:Contents" /> property.
 /// </param>
 /// <param name="isComprehensive">
 /// An initialization value for the <see cref="P:IsComprehensive" /> property.
 /// </param>
 /// <param name="localizedDataSemanticVersion">
 /// An initialization value for the <see cref="P:LocalizedDataSemanticVersion" /> property.
 /// </param>
 /// <param name="minimumRequiredLocalizedDataSemanticVersion">
 /// An initialization value for the <see cref="P:MinimumRequiredLocalizedDataSemanticVersion" /> property.
 /// </param>
 /// <param name="associatedComponent">
 /// An initialization value for the <see cref="P:AssociatedComponent" /> property.
 /// </param>
 /// <param name="translationMetadata">
 /// An initialization value for the <see cref="P:TranslationMetadata" /> property.
 /// </param>
 /// <param name="supportedTaxonomies">
 /// An initialization value for the <see cref="P:SupportedTaxonomies" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public ToolComponent(string guid, string name, string organization, string product, string productSuite, MultiformatMessageString shortDescription, MultiformatMessageString fullDescription, string fullName, string version, string semanticVersion, string dottedQuadFileVersion, string releaseDateUtc, Uri downloadUri, Uri informationUri, IDictionary <string, MultiformatMessageString> globalMessageStrings, IEnumerable <ReportingDescriptor> notifications, IEnumerable <ReportingDescriptor> rules, IEnumerable <ReportingDescriptor> taxa, IEnumerable <ArtifactLocation> locations, string language, ToolComponentContents contents, bool isComprehensive, string localizedDataSemanticVersion, string minimumRequiredLocalizedDataSemanticVersion, ToolComponentReference associatedComponent, TranslationMetadata translationMetadata, IEnumerable <ToolComponentReference> supportedTaxonomies, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(guid, name, organization, product, productSuite, shortDescription, fullDescription, fullName, version, semanticVersion, dottedQuadFileVersion, releaseDateUtc, downloadUri, informationUri, globalMessageStrings, notifications, rules, taxa, locations, language, contents, isComprehensive, localizedDataSemanticVersion, minimumRequiredLocalizedDataSemanticVersion, associatedComponent, translationMetadata, supportedTaxonomies, properties);
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportingDescriptorReference" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P:Id" /> property.
 /// </param>
 /// <param name="index">
 /// An initialization value for the <see cref="P:Index" /> property.
 /// </param>
 /// <param name="guid">
 /// An initialization value for the <see cref="P:Guid" /> property.
 /// </param>
 /// <param name="toolComponent">
 /// An initialization value for the <see cref="P:ToolComponent" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public ReportingDescriptorReference(string id, int index, string guid, ToolComponentReference toolComponent, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(id, index, guid, toolComponent, properties);
 }
コード例 #7
0
 public bool ValueEquals(ToolComponentReference other) => ValueComparer.Equals(this, other);
コード例 #8
0
 /// <summary>
 ///  Find the ToolComponent corresponding to a ToolComponentReference.
 /// </summary>
 /// <param name="reference">ToolComponentReference to resolve</param>
 /// <returns>ToolComponent for reference</returns>
 public ToolComponent GetToolComponentFromReference(ToolComponentReference reference)
 {
     return(this.Tool.GetToolComponentFromReference(reference));
 }