Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CvnNote.ParseIssue"/> class.
        /// Takes full location information for where the parse issue is located,
        /// a severity and a format string plus arguments that will produce the message.
        /// </summary>
        /// <param name="startLine">Location's start line, inclusive.</param>
        /// <param name="startCharacter">Location's start character, inclusive.</param>
        /// <param name="endLine">Location's end line, exclusive.</param>
        /// <param name="endCharacter">Location's end character, exclusive.</param>
        /// <param name="severity">Message severity.</param>
        /// <param name="format">Format string.</param>
        /// <param name="args">Formatting arguments.</param>
        public ParseIssue(
            int startLine, int startCharacter,
            int endLine, int endCharacter,
            ParseIssueSeverity severity,
            string format, params object[] args)
        {
            // Checks/assignment for location information.
            this.Location = new Location(startLine, startCharacter, endLine, endCharacter);


            // Checks/assignment for severity.
            this.Severity = severity;


            // Checks for format string and arguments,
            // assignment for message.
            if (object.ReferenceEquals(format, null))
            {
                throw new ArgumentNullException("format");
            }

            // (Try to avoid format string vulnerability.)
            if (args == null || args.Length == 0)
            {
                this.Message = format;
            }
            else
            {
                this.Message = string.Format(format, args);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CvnNote.ParseIssue"/> class.
 /// Takes a severity and a format string plus arguments that will produce the message.
 /// The location information will be set to zeroes (0).
 /// </summary>
 /// <param name="severity">Severity.</param>
 /// <param name="format">Format string.</param>
 /// <param name="args">Formatting arguments.</param>
 public ParseIssue(
     ParseIssueSeverity severity,
     string format, params object[] args)
     : this(0, 0, 0, 0, severity, format, args)
 {
 }