Exemplo n.º 1
0
 /// <nodoc />
 public DiagnosticMessageChain(string messageText, DiagnosticCategory category, int code, DiagnosticMessageChain next)
 {
     MessageText = messageText;
     Category    = category;
     Code        = code;
     Next        = next;
 }
 public SupportedDiagnosticAttribute(DiagnosticId code, DiagnosticSeverity severity = DiagnosticSeverity.Warning,
                                     DiagnosticCategory category = DiagnosticCategory.Security)
 {
     Code     = code.ToString();
     Severity = severity;
     Category = category;
 }
Exemplo n.º 3
0
        private Diagnostic FromRoslynDiagnostic(DiagnosticData diagnostic, string fileName, IProject project)
        {
            DiagnosticCategory category = DiagnosticCategory.Compiler;

            if (diagnostic.Category == Microsoft.CodeAnalysis.Diagnostics.DiagnosticCategory.Style)
            {
                category = DiagnosticCategory.Style;
            }
            else if (diagnostic.Category == Microsoft.CodeAnalysis.Diagnostics.DiagnosticCategory.EditAndContinue)
            {
                category = DiagnosticCategory.EditAndContinue;
            }

            var result = new Diagnostic(
                diagnostic.TextSpan.Start,
                diagnostic.TextSpan.Length,
                project,
                fileName,
                diagnostic.DataLocation.MappedStartLine,
                diagnostic.Message,
                (DiagnosticLevel)diagnostic.Severity,
                category);

            return(result);
        }
Exemplo n.º 4
0
 /// <nodoc />
 public Diagnostic([NotNull] ISourceFile file, int start, int length, [NotNull] Message messageText, DiagnosticCategory category, int code)
 {
     File        = file;
     Start       = start;
     Length      = length;
     MessageText = messageText;
     Category    = category;
     Code        = code;
 }
Exemplo n.º 5
0
 public Diagnostic(int offset, int length, IProject project, string file, int line, string message, DiagnosticLevel level, DiagnosticCategory category)
 {
     StartOffset = offset;
     Length      = length;
     Project     = project;
     File        = file;
     Line        = line;
     Spelling    = message;
     Level       = level;
     Category    = category;
 }
        public DiagnosticDescriptor(string id, string messageFormat, DiagnosticCategory category, DiagnosticSeverity defaultSeverity)
        {
            if (String.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentException("Diagnostic id can't be null or whitespace", nameof(id));
            }

            Id              = id;
            MessageFormat   = messageFormat ?? throw new ArgumentNullException(nameof(messageFormat));
            Category        = category;
            DefaultSeverity = defaultSeverity;
        }
Exemplo n.º 7
0
		static TaskType GetTaskType(DiagnosticCategory category)
		{
			switch (category) {
				case DiagnosticCategory.Warning:
					return TaskType.Warning;
				case DiagnosticCategory.Error:
					return TaskType.Error;
				case DiagnosticCategory.Message:
					return TaskType.Message;
				default:
					return TaskType.Error;
			}
		}
Exemplo n.º 8
0
 public Diagnostic(int offset, int length, string project, string file, int line, string message, string code, DiagnosticLevel level,
                   DiagnosticCategory category, DiagnosticSourceKind kind = DiagnosticSourceKind.Analysis)
 {
     StartOffset = offset;
     Length      = length;
     Project     = project;
     File        = file;
     Line        = line;
     Spelling    = message;
     Level       = level;
     Category    = category;
     Code        = code;
     Source      = kind;
 }
 private static string getCategoryResource(DiagnosticCategory cateogry)
 {
     if (cateogry == DiagnosticCategory.Security)
     {
         return(Resources.Analyzer_Category_Security);
     }
     else if (cateogry == DiagnosticCategory.Syntax)
     {
         return(Resources.Analyzer_Category_Syntax);
     }
     else
     {
         return(Resources.Analyzer_Category_None);
     }
 }
Exemplo n.º 10
0
        static TaskType GetTaskType(DiagnosticCategory category)
        {
            switch (category)
            {
            case DiagnosticCategory.Warning:
                return(TaskType.Warning);

            case DiagnosticCategory.Error:
                return(TaskType.Error);

            case DiagnosticCategory.Message:
                return(TaskType.Message);

            default:
                return(TaskType.Error);
            }
        }
Exemplo n.º 11
0
        private static DiagnosticSeverity WorkspaceSeverityToDiagnostic(DiagnosticCategory diagnosticCategory)
        {
            switch (diagnosticCategory)
            {
            case DiagnosticCategory.Error:
                return(DiagnosticSeverity.Error);

            case DiagnosticCategory.Warning:
                return(DiagnosticSeverity.Warning);

            case DiagnosticCategory.Message:
                return(DiagnosticSeverity.Information);

            default:
                throw new ArgumentOutOfRangeException(nameof(diagnosticCategory), diagnosticCategory, null);
            }
        }
        public IEnumerable <DiagnosticCategory> GetDiagnosticCategoryList()
        {
            List <DiagnosticCategory> entityList = new List <DiagnosticCategory>();
            XElement element         = ReadDataFromConfig("zhenduanleixingConfig");
            var      categoriesItems = element.Element("items");

            if (categoriesItems != null)
            {
                var categories = categoriesItems.Elements("item");
                var serialNo   = 1;
                foreach (var item in categories)
                {
                    DiagnosticCategory category = new DiagnosticCategory();
                    category.CategoryId   = serialNo;
                    category.CategoryName = item.Value.Trim();
                    entityList.Add(category);
                    serialNo++;
                }
            }
            return(entityList);
        }
Exemplo n.º 13
0
 internal static DiagnosticDescriptor Warning(LocalizableString title, LocalizableString messageFormat, int id, DiagnosticCategory category, params string[] customTags)
 {
     return(Create(title, messageFormat, id, category, DiagnosticSeverity.Warning, customTags));
 }
Exemplo n.º 14
0
 internal static DiagnosticDescriptor Error(string title, string messageFormat, int id, DiagnosticCategory category, params string[] customTags)
 {
     return(Create(title, messageFormat, id, category, DiagnosticSeverity.Error, customTags));
 }
Exemplo n.º 15
0
        internal static DiagnosticDescriptor Create(string title, string messageFormat, int id, DiagnosticCategory category, DiagnosticSeverity defaultSeverity, params string[] customTags)
        {
            if (!Enum.IsDefined(typeof(DiagnosticCategory), category))
            {
                throw new ArgumentOutOfRangeException(nameof(category));
            }

            if (id < 0 || id >= 1000)
            {
                throw new ArgumentOutOfRangeException(nameof(id));
            }

            return(new DiagnosticDescriptor($"W3N{(int)category}{id:D3}", title, messageFormat, category.ToString(), defaultSeverity, true, null, null, customTags));
        }
 bool IDiagnosticProvider.IsSupported(DiagnosticCategory category)
 {
     return(category == DiagnosticCategory.SemanticInDocument);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Returns true if the specified kinds are supported by this provider.
 /// </summary>
 bool IDiagnosticProvider.IsSupported(DiagnosticCategory category)
 {
     return(category == DiagnosticCategory.Project);
 }
        public static DiagnosticDescriptor Create(string code, DiagnosticSeverity severity = DiagnosticSeverity.Warning, DiagnosticCategory category = DiagnosticCategory.Security)
        {
            LocalizableString title       = new LocalizableResourceString(string.Format("Analyzer_{0}_Title", code), Resources.ResourceManager, typeof(Resources));
            LocalizableString description = new LocalizableResourceString(string.Format("Analyzer_{0}_Description", code), Resources.ResourceManager, typeof(Resources));
            LocalizableString message     = new LocalizableResourceString(string.Format("Analyzer_{0}_MessageFormat", code), Resources.ResourceManager, typeof(Resources));
            LocalizableString anchor      = new LocalizableResourceString(string.Format("Analyzer_{0}_Anchor", code), Resources.ResourceManager, typeof(Resources));

            return(new DiagnosticDescriptor(
                       code
                       , title
                       , message
                       , getCategoryResource(category)
                       , severity
                       , true
                       , description
                       , string.Format("https://www.pumascan.com/rules/#{0}", anchor)));
        }
Exemplo n.º 19
0
 /// <nodoc />
 public Diagnostic([NotNull] string text, DiagnosticCategory category, int code)
 {
     MessageText = text;
     Category    = category;
     Code        = code;
 }