상속: ISarifNode
예제 #1
0
        private void Init(string id, string ruleId, int ruleIndex, PhysicalLocation physicalLocation, Message message, FailureLevel level, int threadId, DateTime timeUtc, ExceptionData exception, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Id        = id;
            RuleId    = ruleId;
            RuleIndex = ruleIndex;
            if (physicalLocation != null)
            {
                PhysicalLocation = new PhysicalLocation(physicalLocation);
            }

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

            Level    = level;
            ThreadId = threadId;
            TimeUtc  = timeUtc;
            if (exception != null)
            {
                Exception = new ExceptionData(exception);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
예제 #2
0
        // Retain nesting level for visiting exceptions to prevent
        // unbounded re-entrance populating exception.innerExceptions
        public override ExceptionData VisitExceptionData(ExceptionData node)
        {
            _visitingExceptionData = true;
            node = base.VisitExceptionData(node);
            _visitingExceptionData = false;

            return(node);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionData" /> 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 ExceptionData(ExceptionData other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Init(other.Kind, other.Message, other.Stack, other.InnerExceptions, other.Properties);
        }
예제 #4
0
파일: Errors.cs 프로젝트: Tawnos/sarif-sdk
        private static Notification CreateNotification(
            Uri uri,
            string notificationId,
            string ruleId,
            FailureLevel level,
            Exception exception,
            bool persistExceptionStack,
            params string[] args)
        {
            string 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);
            }

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

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

            var notification = new Notification
            {
                PhysicalLocation = physicalLocation,
                Id      = notificationId,
                RuleId  = ruleId,
                Level   = level,
                Message = new Message {
                    Text = message
                },
                Exception = exceptionData
            };

            return(notification);
        }
예제 #5
0
        private void Init(IEnumerable <Location> locations, Message message, FailureLevel level, int threadId, DateTime timeUtc, ExceptionData exception, ReportingDescriptorReference descriptor, ReportingDescriptorReference associatedRule, IDictionary <string, SerializedPropertyInfo> properties)
        {
            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;
            }

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

            Level    = level;
            ThreadId = threadId;
            TimeUtc  = timeUtc;
            if (exception != null)
            {
                Exception = new ExceptionData(exception);
            }

            if (descriptor != null)
            {
                Descriptor = new ReportingDescriptorReference(descriptor);
            }

            if (associatedRule != null)
            {
                AssociatedRule = new ReportingDescriptorReference(associatedRule);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
예제 #6
0
        public virtual ExceptionData VisitExceptionData(ExceptionData node)
        {
            if (node != null)
            {
                node.Stack = VisitNullChecked(node.Stack);
                if (node.InnerExceptions != null)
                {
                    for (int index_0 = 0; index_0 < node.InnerExceptions.Count; ++index_0)
                    {
                        node.InnerExceptions[index_0] = VisitNullChecked(node.InnerExceptions[index_0]);
                    }
                }
            }

            return(node);
        }
예제 #7
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);
            }
        }
예제 #8
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="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, PhysicalLocation physicalLocation, Message message, NotificationLevel level, int threadId, DateTime time, ExceptionData exception, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(id, ruleId, physicalLocation, message, level, threadId, time, exception, properties);
 }
예제 #9
0
 public bool ValueEquals(ExceptionData other) => ValueComparer.Equals(this, other);
예제 #10
0
파일: Errors.cs 프로젝트: yazici/sarif-sdk
        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);
            }

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

            var 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);
        }
예제 #11
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);
            }
        }
예제 #12
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);
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Notification" /> class from the supplied values.
 /// </summary>
 /// <param name="locations">
 /// An initialization value for the <see cref="P:Locations" /> 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="descriptor">
 /// An initialization value for the <see cref="P:Descriptor" /> property.
 /// </param>
 /// <param name="associatedRule">
 /// An initialization value for the <see cref="P:AssociatedRule" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Notification(IEnumerable <Location> locations, Message message, FailureLevel level, int threadId, DateTime timeUtc, ExceptionData exception, ReportingDescriptorReference descriptor, ReportingDescriptorReference associatedRule, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(locations, message, level, threadId, timeUtc, exception, descriptor, associatedRule, properties);
 }
예제 #14
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);

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

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

            if (exceptionData != null)
            {
                physicalLocation ??= exceptionData.Stack?.Frames?[0].Location?.PhysicalLocation;
            }

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

            Init(other.Kind, other.Message, other.Stack, other.InnerExceptions);
        }
예제 #16
0
 public bool ValueEquals(ExceptionData other) => ValueComparer.Equals(this, other);