示例#1
0
        public static string GenerateRuleJson(string productVersion)
        {
            var cs = RuleDetailBuilder.GetAllRuleDetails(AnalyzerLanguage.CSharp)
                     .Select(ruleDetail => RuleDescription.Convert(ruleDetail, productVersion, AnalyzerLanguage.CSharp))
                     .ToList();

            var vb = RuleDetailBuilder.GetAllRuleDetails(AnalyzerLanguage.VisualBasic)
                     .Select(ruleDetail => RuleDescription.Convert(ruleDetail, productVersion, AnalyzerLanguage.VisualBasic))
                     .ToList();

            foreach (var vbRuleDescription in vb)
            {
                var csEquivalent = cs.FirstOrDefault(rd => rd.Key == vbRuleDescription.Key);
                if (csEquivalent == null)
                {
                    cs.Add(vbRuleDescription);
                }
                else
                {
                    foreach (var item in vbRuleDescription.Data)
                    {
                        csEquivalent.Data.Add(item.Key, item.Value);
                    }
                }
            }

            return(JsonConvert.SerializeObject(cs,
                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting = Formatting.Indented
            }));
        }
示例#2
0
        public static string GenerateRuleJson(string productVersion)
        {
            var ruleDetails = RuleDetailBuilder.GetParameterlessRuleDetails()
                              .Select(ruleDetail =>
                                      RuleDescription.Convert(ruleDetail, productVersion))
                              .ToList();

            return(JsonConvert.SerializeObject(ruleDetails,
                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting = Formatting.Indented
            }));
        }