Exemple #1
0
		/// <summary>
		///     Gets the <see cref="DiagnosticInfo" /> corresponding to the <paramref name="id" />.
		/// </summary>
		/// <param name="id">The diagnostic identifier the <see cref="DiagnosticInfo" /> should be returned for.</param>
		public DiagnosticInfo GetDiagnosticInfo(DiagnosticIdentifier id)
		{
			Requires.InRange(id, () => id);

			var diagnostics = _diagnostics.Where(d => d.Id == id).ToArray();
			Requires.That(diagnostics.Length == 1, "Analyzer '{0}' does not emit diagnostic '{1}'.", GetType().FullName, id);

			return diagnostics[0];
		}
Exemple #2
0
 public Diagnostic(DiagnosticIdentifier identifier, string message,
                   TextSpan span, DiagnosticType type, string file)
 {
     Identifier = identifier;
     Message    = message;
     Span       = span;
     Type       = type;
     File       = file;
 }
Exemple #3
0
        /// <summary>
        ///   Gets the <see cref="DiagnosticInfo" /> corresponding to the <paramref name="id" />.
        /// </summary>
        /// <param name="id">The diagnostic identifier the <see cref="DiagnosticInfo" /> should be returned for.</param>
        public DiagnosticInfo GetDiagnosticInfo(DiagnosticIdentifier id)
        {
            Requires.InRange(id, nameof(id));

            var diagnostics = _diagnostics.Where(d => d.Id == id).ToArray();

            Requires.That(diagnostics.Length == 1, $"Analyzer '{GetType().FullName}' does not emit diagnostic '{id}'.");

            return(diagnostics[0]);
        }
Exemple #4
0
        /// <summary>
        ///   Describes the error diagnostic of the analyzer.
        /// </summary>
        /// <param name="identifier">The identifier of the analyzer's diagnostic.</param>
        /// <param name="description">The description of the diagnostic.</param>
        /// <param name="messageFormat">The message format of the diagnostic.</param>
        /// <param name="severity">The severity of the diagnostic.</param>
        private static DiagnosticInfo Initialize(DiagnosticIdentifier identifier, [NotNull] string description,
                                                 [NotNull] string messageFormat, DiagnosticSeverity severity)
        {
            Requires.NotNullOrWhitespace(description, nameof(description));
            Requires.NotNullOrWhitespace(messageFormat, nameof(messageFormat));
            Requires.InRange(severity, nameof(severity));

            return(new DiagnosticInfo
            {
                Descriptor = new DiagnosticDescriptor(Prefix + (int)identifier, description, messageFormat, Category, severity, true),
                Id = identifier
            });
        }
		/// <summary>
		///     Describes the error diagnostic of the analyzer.
		/// </summary>
		/// <param name="identifier">The identifier of the analyzer's diagnostic.</param>
		/// <param name="description">The description of the diagnostic.</param>
		/// <param name="messageFormat">The message format of the diagnostic.</param>
		/// <param name="severity">The severity of the diagnostic.</param>
		private static DiagnosticInfo Initialize(DiagnosticIdentifier identifier, [NotNull] string description,
												 [NotNull] string messageFormat, DiagnosticSeverity severity)
		{
			Requires.NotNullOrWhitespace(description, () => description);
			Requires.NotNullOrWhitespace(messageFormat, () => messageFormat);
			Requires.InRange(severity, () => severity);

			return new DiagnosticInfo
			{
				Descriptor = new DiagnosticDescriptor(Prefix + (int)identifier, description, messageFormat, Category, severity, true),
				Id = identifier
			};
		}
		/// <summary>
		///     Describes the error diagnostic of the analyzer.
		/// </summary>
		/// <param name="identifier">The identifier of the analyzer's diagnostic.</param>
		/// <param name="description">The description of the diagnostic.</param>
		/// <param name="messageFormat">The message format of the diagnostic.</param>
		public static DiagnosticInfo Warning(DiagnosticIdentifier identifier, [NotNull] string description, [NotNull] string messageFormat)
		{
			return Initialize(identifier, description, messageFormat, DiagnosticSeverity.Warning);
		}
Exemple #7
0
 /// <summary>
 ///   Describes the error diagnostic of the analyzer.
 /// </summary>
 /// <param name="identifier">The identifier of the analyzer's diagnostic.</param>
 /// <param name="description">The description of the diagnostic.</param>
 /// <param name="messageFormat">The message format of the diagnostic.</param>
 public static DiagnosticInfo Warning(DiagnosticIdentifier identifier, [NotNull] string description, [NotNull] string messageFormat)
 {
     return(Initialize(identifier, description, messageFormat, DiagnosticSeverity.Warning));
 }
Exemple #8
0
 public DiagnosticAttribute(DiagnosticIdentifier id, int line, int column, int length, params string[] arguments)
 {
 }