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

            Init(other.Uri, other.UriBaseId, other.Region);
        }
Example #2
0
        public static Notification CreateNotification(
            Uri uri,
            string notificationId,
            string ruleId,
            FailureLevel level,
            Exception exception,
            bool persistExceptionStack,
            string messageFormat,
            params string[] args)
        {
            messageFormat = messageFormat ?? GetMessageFormatResourceForNotification(notificationId);

            string message = string.Format(CultureInfo.CurrentCulture, messageFormat, args);

            string exceptionMessage = exception?.Message;

            if (!string.IsNullOrEmpty(exceptionMessage))
            {
                // {0} ('{1}')
                message = string.Format(CultureInfo.InvariantCulture, SdkResources.NotificationWithExceptionMessage, message, exceptionMessage);
            }

            ExceptionData exceptionData = exception != null && persistExceptionStack
                ? ExceptionData.Create(exception)
                : null;

            PhysicalLocation physicalLocation = uri != null
                ? new PhysicalLocation
            {
                ArtifactLocation = new ArtifactLocation
                {
                    Uri = uri
                },
            }
                : null;

            var notification = new Notification
            {
                Locations = new List <Location>
                {
                    new Location
                    {
                        PhysicalLocation = physicalLocation
                    }
                },
                Level   = level,
                Message = new Message {
                    Text = message
                },
                Exception = exceptionData
            };

            if (!string.IsNullOrWhiteSpace(notificationId))
            {
                notification.Descriptor = new ReportingDescriptorReference
                {
                    Id = notificationId,
                };
            }

            if (!string.IsNullOrWhiteSpace(ruleId))
            {
                notification.AssociatedRule = new ReportingDescriptorReference
                {
                    Id = ruleId,
                };
            }

            return(notification);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Notification" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P: Id" /> property.
 /// </param>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P: RuleId" /> property.
 /// </param>
 /// <param name="ruleKey">
 /// An initialization value for the <see cref="P: RuleKey" /> property.
 /// </param>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P: PhysicalLocation" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P: Level" /> property.
 /// </param>
 /// <param name="threadId">
 /// An initialization value for the <see cref="P: ThreadId" /> property.
 /// </param>
 /// <param name="time">
 /// An initialization value for the <see cref="P: Time" /> property.
 /// </param>
 /// <param name="exception">
 /// An initialization value for the <see cref="P: Exception" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Notification(string id, string ruleId, string ruleKey, PhysicalLocation physicalLocation, string message, NotificationLevel level, int threadId, DateTime time, ExceptionData exception, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(id, ruleId, ruleKey, physicalLocation, message, level, threadId, time, exception, properties);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotatedCodeLocation" /> class from the supplied values.
 /// </summary>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P: PhysicalLocation" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 /// <param name="tags">
 /// An initialization value for the <see cref="P: Tags" /> property.
 /// </param>
 public AnnotatedCodeLocation(PhysicalLocation physicalLocation, string message, IDictionary <string, string> properties, ISet <string> tags)
 {
     Init(physicalLocation, message, properties, tags);
 }
Example #5
0
        protected virtual void Init(int id, PhysicalLocation physicalLocation, IEnumerable <LogicalLocation> logicalLocations, Message message, IEnumerable <Region> annotations, IEnumerable <LocationRelationship> relationships, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Id = id;
            if (physicalLocation != null)
            {
                PhysicalLocation = new PhysicalLocation(physicalLocation);
            }

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

                LogicalLocations = destination_0;
            }

            if (message != null)
            {
                Message = new Message(message);
            }

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

                Annotations = destination_1;
            }

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

                Relationships = destination_2;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Location" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P:Id" /> property.
 /// </param>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P:PhysicalLocation" /> property.
 /// </param>
 /// <param name="logicalLocations">
 /// An initialization value for the <see cref="P:LogicalLocations" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P:Message" /> property.
 /// </param>
 /// <param name="annotations">
 /// An initialization value for the <see cref="P:Annotations" /> property.
 /// </param>
 /// <param name="relationships">
 /// An initialization value for the <see cref="P:Relationships" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Location(int id, PhysicalLocation physicalLocation, IEnumerable <LogicalLocation> logicalLocations, Message message, IEnumerable <Region> annotations, IEnumerable <LocationRelationship> relationships, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(id, physicalLocation, logicalLocations, message, annotations, relationships, properties);
 }
        private void Init(int id, int step, PhysicalLocation physicalLocation, string fullyQualifiedLogicalName, string logicalLocationKey, string module, int threadId, string message, AnnotatedCodeLocationKind kind, TaintKind taintKind, string target, IEnumerable<string> values, object state, string targetKey, bool essential, AnnotatedCodeLocationImportance importance, string snippet, IEnumerable<Annotation> annotations, IDictionary<string, SerializedPropertyInfo> properties)
        {
            Id = id;
            Step = step;
            if (physicalLocation != null)
            {
                PhysicalLocation = new PhysicalLocation(physicalLocation);
            }

            FullyQualifiedLogicalName = fullyQualifiedLogicalName;
            LogicalLocationKey = logicalLocationKey;
            Module = module;
            ThreadId = threadId;
            Message = message;
            Kind = kind;
            TaintKind = taintKind;
            Target = target;
            if (values != null)
            {
                var destination_0 = new List<string>();
                foreach (var value_0 in values)
                {
                    destination_0.Add(value_0);
                }

                Values = destination_0;
            }

            State = state;
            TargetKey = targetKey;
            Essential = essential;
            Importance = importance;
            Snippet = snippet;
            if (annotations != null)
            {
                var destination_1 = new List<Annotation>();
                foreach (var value_1 in annotations)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Annotation(value_1));
                    }
                }

                Annotations = destination_1;
            }

            if (properties != null)
            {
                Properties = new Dictionary<string, SerializedPropertyInfo>(properties);
            }
        }
 public bool ValueEquals(PhysicalLocation other) => ValueComparer.Equals(this, other);
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Location" /> class from the supplied values.
 /// </summary>
 /// <param name="analysisTarget">
 /// An initialization value for the <see cref="P: AnalysisTarget" /> property.
 /// </param>
 /// <param name="resultFile">
 /// An initialization value for the <see cref="P: ResultFile" /> property.
 /// </param>
 /// <param name="fullyQualifiedLogicalName">
 /// An initialization value for the <see cref="P: FullyQualifiedLogicalName" /> property.
 /// </param>
 /// <param name="logicalLocationKey">
 /// An initialization value for the <see cref="P: LogicalLocationKey" /> property.
 /// </param>
 /// <param name="decoratedName">
 /// An initialization value for the <see cref="P: DecoratedName" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Location(PhysicalLocation analysisTarget, PhysicalLocation resultFile, string fullyQualifiedLogicalName, string logicalLocationKey, string decoratedName, IDictionary<string, SerializedPropertyInfo> properties)
 {
     Init(analysisTarget, resultFile, fullyQualifiedLogicalName, logicalLocationKey, decoratedName, properties);
 }
Example #10
0
        private void Init(PhysicalLocation analysisTarget, PhysicalLocation resultFile, string fullyQualifiedLogicalName, string logicalLocationKey, string decoratedName, IDictionary<string, SerializedPropertyInfo> properties)
        {
            if (analysisTarget != null)
            {
                AnalysisTarget = new PhysicalLocation(analysisTarget);
            }

            if (resultFile != null)
            {
                ResultFile = new PhysicalLocation(resultFile);
            }

            FullyQualifiedLogicalName = fullyQualifiedLogicalName;
            LogicalLocationKey = logicalLocationKey;
            DecoratedName = decoratedName;
            if (properties != null)
            {
                Properties = new Dictionary<string, SerializedPropertyInfo>(properties);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotatedCodeLocation" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P: Id" /> property.
 /// </param>
 /// <param name="step">
 /// An initialization value for the <see cref="P: Step" /> property.
 /// </param>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P: PhysicalLocation" /> property.
 /// </param>
 /// <param name="fullyQualifiedLogicalName">
 /// An initialization value for the <see cref="P: FullyQualifiedLogicalName" /> property.
 /// </param>
 /// <param name="logicalLocationKey">
 /// An initialization value for the <see cref="P: LogicalLocationKey" /> property.
 /// </param>
 /// <param name="module">
 /// An initialization value for the <see cref="P: Module" /> property.
 /// </param>
 /// <param name="threadId">
 /// An initialization value for the <see cref="P: ThreadId" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="kind">
 /// An initialization value for the <see cref="P: Kind" /> property.
 /// </param>
 /// <param name="taintKind">
 /// An initialization value for the <see cref="P: TaintKind" /> property.
 /// </param>
 /// <param name="target">
 /// An initialization value for the <see cref="P: Target" /> property.
 /// </param>
 /// <param name="values">
 /// An initialization value for the <see cref="P: Values" /> property.
 /// </param>
 /// <param name="state">
 /// An initialization value for the <see cref="P: State" /> property.
 /// </param>
 /// <param name="targetKey">
 /// An initialization value for the <see cref="P: TargetKey" /> property.
 /// </param>
 /// <param name="essential">
 /// An initialization value for the <see cref="P: Essential" /> property.
 /// </param>
 /// <param name="importance">
 /// An initialization value for the <see cref="P: Importance" /> property.
 /// </param>
 /// <param name="snippet">
 /// An initialization value for the <see cref="P: Snippet" /> property.
 /// </param>
 /// <param name="annotations">
 /// An initialization value for the <see cref="P: Annotations" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public AnnotatedCodeLocation(int id, int step, PhysicalLocation physicalLocation, string fullyQualifiedLogicalName, string logicalLocationKey, string module, int threadId, string message, AnnotatedCodeLocationKind kind, TaintKind taintKind, string target, IEnumerable <string> values, object state, string targetKey, bool essential, AnnotatedCodeLocationImportance importance, string snippet, IEnumerable <Annotation> annotations, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(id, step, physicalLocation, fullyQualifiedLogicalName, logicalLocationKey, module, threadId, message, kind, taintKind, target, values, state, targetKey, essential, importance, snippet, annotations, properties);
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Location" /> class from the supplied values.
 /// </summary>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P: PhysicalLocation" /> property.
 /// </param>
 /// <param name="fullyQualifiedLogicalName">
 /// An initialization value for the <see cref="P: FullyQualifiedLogicalName" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="annotations">
 /// An initialization value for the <see cref="P: Annotations" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Location(PhysicalLocation physicalLocation, string fullyQualifiedLogicalName, Message message, IEnumerable <Region> annotations, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(physicalLocation, fullyQualifiedLogicalName, message, annotations, properties);
 }
Example #13
0
 public bool ValueEquals(PhysicalLocation other) => ValueComparer.Equals(this, other);
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Notification" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P: Id" /> property.
 /// </param>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P: RuleId" /> property.
 /// </param>
 /// <param name="ruleKey">
 /// An initialization value for the <see cref="P: RuleKey" /> property.
 /// </param>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P: PhysicalLocation" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P: Level" /> property.
 /// </param>
 /// <param name="threadId">
 /// An initialization value for the <see cref="P: ThreadId" /> property.
 /// </param>
 /// <param name="time">
 /// An initialization value for the <see cref="P: Time" /> property.
 /// </param>
 /// <param name="exception">
 /// An initialization value for the <see cref="P: Exception" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Notification(string id, string ruleId, string ruleKey, PhysicalLocation physicalLocation, string message, NotificationLevel level, int threadId, DateTime time, ExceptionData exception, IDictionary<string, SerializedPropertyInfo> properties)
 {
     Init(id, ruleId, ruleKey, physicalLocation, message, level, threadId, time, exception, properties);
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Notification" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P:Id" /> property.
 /// </param>
 /// <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="physicalLocation">
 /// An initialization value for the <see cref="P:PhysicalLocation" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P:Message" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P:Level" /> property.
 /// </param>
 /// <param name="threadId">
 /// An initialization value for the <see cref="P:ThreadId" /> property.
 /// </param>
 /// <param name="timeUtc">
 /// An initialization value for the <see cref="P:TimeUtc" /> property.
 /// </param>
 /// <param name="exception">
 /// An initialization value for the <see cref="P:Exception" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Notification(string id, string ruleId, int ruleIndex, PhysicalLocation physicalLocation, Message message, FailureLevel level, int threadId, DateTime timeUtc, ExceptionData exception, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(id, ruleId, ruleIndex, physicalLocation, message, level, threadId, timeUtc, exception, properties);
 }
Example #16
0
        private void Init(string id, string ruleId, string ruleKey, PhysicalLocation physicalLocation, string message, NotificationLevel level, int threadId, DateTime time, ExceptionData exception, IDictionary<string, SerializedPropertyInfo> properties)
        {
            Id = id;
            RuleId = ruleId;
            RuleKey = ruleKey;
            if (physicalLocation != null)
            {
                PhysicalLocation = new PhysicalLocation(physicalLocation);
            }

            Message = message;
            Level = level;
            ThreadId = threadId;
            Time = time;
            if (exception != null)
            {
                Exception = new ExceptionData(exception);
            }

            if (properties != null)
            {
                Properties = new Dictionary<string, SerializedPropertyInfo>(properties);
            }
        }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Location" /> class from the supplied values.
 /// </summary>
 /// <param name="analysisTarget">
 /// An initialization value for the <see cref="P: AnalysisTarget" /> property.
 /// </param>
 /// <param name="resultFile">
 /// An initialization value for the <see cref="P: ResultFile" /> property.
 /// </param>
 /// <param name="fullyQualifiedLogicalName">
 /// An initialization value for the <see cref="P: FullyQualifiedLogicalName" /> property.
 /// </param>
 /// <param name="logicalLocationKey">
 /// An initialization value for the <see cref="P: LogicalLocationKey" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 /// <param name="tags">
 /// An initialization value for the <see cref="P: Tags" /> property.
 /// </param>
 public Location(PhysicalLocation analysisTarget, PhysicalLocation resultFile, string fullyQualifiedLogicalName, string logicalLocationKey, IDictionary <string, string> properties, ISet <string> tags)
 {
     Init(analysisTarget, resultFile, fullyQualifiedLogicalName, logicalLocationKey, properties, tags);
 }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Location" /> class from the supplied values.
 /// </summary>
 /// <param name="analysisTarget">
 /// An initialization value for the <see cref="P: AnalysisTarget" /> property.
 /// </param>
 /// <param name="resultFile">
 /// An initialization value for the <see cref="P: ResultFile" /> property.
 /// </param>
 /// <param name="fullyQualifiedLogicalName">
 /// An initialization value for the <see cref="P: FullyQualifiedLogicalName" /> property.
 /// </param>
 /// <param name="logicalLocationKey">
 /// An initialization value for the <see cref="P: LogicalLocationKey" /> property.
 /// </param>
 /// <param name="decoratedName">
 /// An initialization value for the <see cref="P: DecoratedName" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Location(PhysicalLocation analysisTarget, PhysicalLocation resultFile, string fullyQualifiedLogicalName, string logicalLocationKey, string decoratedName, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(analysisTarget, resultFile, fullyQualifiedLogicalName, logicalLocationKey, decoratedName, properties);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotatedCodeLocation" /> class from the supplied values.
 /// </summary>
 /// <param name="id">
 /// An initialization value for the <see cref="P: Id" /> property.
 /// </param>
 /// <param name="step">
 /// An initialization value for the <see cref="P: Step" /> property.
 /// </param>
 /// <param name="physicalLocation">
 /// An initialization value for the <see cref="P: PhysicalLocation" /> property.
 /// </param>
 /// <param name="fullyQualifiedLogicalName">
 /// An initialization value for the <see cref="P: FullyQualifiedLogicalName" /> property.
 /// </param>
 /// <param name="logicalLocationKey">
 /// An initialization value for the <see cref="P: LogicalLocationKey" /> property.
 /// </param>
 /// <param name="module">
 /// An initialization value for the <see cref="P: Module" /> property.
 /// </param>
 /// <param name="threadId">
 /// An initialization value for the <see cref="P: ThreadId" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="kind">
 /// An initialization value for the <see cref="P: Kind" /> property.
 /// </param>
 /// <param name="taintKind">
 /// An initialization value for the <see cref="P: TaintKind" /> property.
 /// </param>
 /// <param name="target">
 /// An initialization value for the <see cref="P: Target" /> property.
 /// </param>
 /// <param name="values">
 /// An initialization value for the <see cref="P: Values" /> property.
 /// </param>
 /// <param name="state">
 /// An initialization value for the <see cref="P: State" /> property.
 /// </param>
 /// <param name="targetKey">
 /// An initialization value for the <see cref="P: TargetKey" /> property.
 /// </param>
 /// <param name="essential">
 /// An initialization value for the <see cref="P: Essential" /> property.
 /// </param>
 /// <param name="importance">
 /// An initialization value for the <see cref="P: Importance" /> property.
 /// </param>
 /// <param name="snippet">
 /// An initialization value for the <see cref="P: Snippet" /> property.
 /// </param>
 /// <param name="annotations">
 /// An initialization value for the <see cref="P: Annotations" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public AnnotatedCodeLocation(int id, int step, PhysicalLocation physicalLocation, string fullyQualifiedLogicalName, string logicalLocationKey, string module, int threadId, string message, AnnotatedCodeLocationKind kind, TaintKind taintKind, string target, IEnumerable<string> values, object state, string targetKey, bool essential, AnnotatedCodeLocationImportance importance, string snippet, IEnumerable<Annotation> annotations, IDictionary<string, SerializedPropertyInfo> properties)
 {
     Init(id, step, physicalLocation, fullyQualifiedLogicalName, logicalLocationKey, module, threadId, message, kind, taintKind, target, values, state, targetKey, essential, importance, snippet, annotations, properties);
 }