1 using System; 2 using System.Collections.Generic; 3 using System.IO; 4 using System.Linq; 5 using System.Text; 6 using YamlDotNet.Serialization; 7 using YamlDotNet.Serialization.NamingConventions; 8 9 namespace LLVM.ClangTidy 10 { 11 public class CheckInfo 12 { 13 [YamlAlias("Name")] 14 public string Name { get; set; } 15 16 [YamlAlias("Label")] 17 public string Label { get; set; } 18 19 [YamlAlias("Description")] 20 public string Desc { get; set; } 21 22 [YamlAlias("Category")] 23 public string Category { get; set; } 24 } 25 26 /// <summary> 27 /// Reads the list of checks from Yaml and builds a description of each one. 28 /// This list of checks is then used by the PropertyGrid to determine what 29 /// items to display. 30 /// </summary> 31 public static class CheckDatabase 32 { 33 static CheckInfo[] Checks_ = null; 34 35 class CheckRoot 36 { 37 [YamlAlias("Checks")] 38 public CheckInfo[] Checks { get; set; } 39 } 40 CheckDatabase()41 static CheckDatabase() 42 { 43 using (StringReader Reader = new StringReader(Resources.ClangTidyChecks)) 44 { 45 Deserializer D = new Deserializer(namingConvention: new PascalCaseNamingConvention()); 46 var Root = D.Deserialize<CheckRoot>(Reader); 47 Checks_ = Root.Checks; 48 49 HashSet<string> Names = new HashSet<string>(); 50 foreach (var Check in Checks_) 51 { 52 if (Names.Contains(Check.Name)) 53 continue; 54 Names.Add(Check.Name); 55 } 56 } 57 } 58 59 public static IEnumerable<CheckInfo> Checks 60 { 61 get 62 { 63 return Checks_; 64 } 65 } 66 } 67 } 68