当前位置: 首页>>代码示例>>C#>>正文


C# Common.AnalyzerLanguage类代码示例

本文整理汇总了C#中SonarLint.Common.AnalyzerLanguage的典型用法代码示例。如果您正苦于以下问题:C# AnalyzerLanguage类的具体用法?C# AnalyzerLanguage怎么用?C# AnalyzerLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AnalyzerLanguage类属于SonarLint.Common命名空间,在下文中一共展示了AnalyzerLanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNumberOfCrossReferences

 private static int GetNumberOfCrossReferences(AnalyzerLanguage language)
 {
     return RuleDetailBuilder.GetParameterlessRuleDetails(language)
         .Select(rule => rule.Description)
         .Select(description => Regex.Matches(description, RuleImplementationMeta.CrosslinkPattern).Count)
         .Sum();
 }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:7,代码来源:DocGeneratorTest.cs

示例2: GetParameterlessAnalyzerTypes

 public IEnumerable<Type> GetParameterlessAnalyzerTypes(AnalyzerLanguage language)
 {
     return diagnosticAnalyzers
         .Where(analyzerType =>
             !analyzerType.GetProperties()
                 .Any(p => p.GetCustomAttributes<RuleParameterAttribute>().Any()))
         .Where(type => GetTargetLanguages(type).IsAlso(language));
 }
开发者ID:ozgurkayaist,项目名称:sonarlint-vs,代码行数:8,代码来源:RuleFinder.cs

示例3: GetSolutionWithEmptyFile

 public static Solution GetSolutionWithEmptyFile(AnalyzerLanguage language)
 {
     using (var workspace = new AdhocWorkspace())
     {
         var lang = language == AnalyzerLanguage.CSharp ? LanguageNames.CSharp : LanguageNames.VisualBasic;
         return workspace.CurrentSolution.AddProject("foo", "foo.dll", lang)
             .AddMetadataReference(SystemMetadataReference)
             .AddDocument($"foo.{language.GetFileExtension()}", string.Empty)
             .Project
             .Solution;
     }
 }
开发者ID:duncanpMS,项目名称:sonarlint-vs,代码行数:12,代码来源:CompilationHelper.cs

示例4: WriteQualityProfileFile

        private static void WriteQualityProfileFile(string filePath, IEnumerable<RuleDetail> ruleDetails, AnalyzerLanguage language)
        {
            var root = new QualityProfileRoot(language);
            root.Rules.AddRange(ruleDetails
                .Where(descriptor => descriptor.IsActivatedByDefault)
                .Select(descriptor => new QualityProfileRuleDescriptor(language)
                {
                    Key = descriptor.Key
                }));

            SerializeObjectToFile(filePath, root);
        }
开发者ID:ozgurkayaist,项目名称:sonarlint-vs,代码行数:12,代码来源:Program.cs

示例5: CheckRuleDescriptorsNotEmpty

        private static void CheckRuleDescriptorsNotEmpty(AnalyzerLanguage language)
        {
            var ruleDetails = RuleDetailBuilder.GetAllRuleDetails(language).ToList();
            foreach (var ruleDetail in ruleDetails)
            {
                Assert.IsNotNull(ruleDetail);
                Assert.IsNotNull(ruleDetail.Description);
                Assert.IsNotNull(ruleDetail.Key);
                Assert.IsNotNull(ruleDetail.Title);
            }

            Assert.AreEqual(ruleDetails.Count,
                ruleDetails.Select(descriptor => descriptor.Key).Distinct().Count());
        }
开发者ID:jakobehn,项目名称:sonarlint-vs,代码行数:14,代码来源:RuleDescriptorTest.cs

示例6: Convert

 public static RuleImplementationMeta Convert(RuleDetail detail, string productVersion, AnalyzerLanguage language)
 {
     return new RuleImplementationMeta
     {
         Id = detail.Key,
         Language = language.GetFriendlyName(),
         Severity = detail.Severity,
         Title = detail.Title,
         Description = GetParameterDescription(detail.Parameters) +
             AddLinksBetweenRulesToDescription(detail.Description, productVersion) +
             GetCodeFixDescription(detail),
         Tags = detail.Tags
     };
 }
开发者ID:duncanpMS,项目名称:sonarlint-vs,代码行数:14,代码来源:RuleImplementationMeta.cs

示例7: IsAlso

        public bool IsAlso(AnalyzerLanguage other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            if (other == None)
            {
                throw new NotSupportedException("IsAlso doesn't support AnalyzerLanguage.None.");
            }

            return this == other || this == Both;
        }
开发者ID:jakobehn,项目名称:sonarlint-vs,代码行数:14,代码来源:AnalyzerLanguage.cs

示例8: GetSolutionFromFiles

        public static Solution GetSolutionFromFiles(string filePath, AnalyzerLanguage language)
        {
            using (var workspace = new AdhocWorkspace())
            {
                var file = new FileInfo(filePath);
                var lang = language == AnalyzerLanguage.CSharp ? LanguageNames.CSharp : LanguageNames.VisualBasic;
                var project = workspace.CurrentSolution.AddProject("foo", "foo.dll", lang)
                    .AddMetadataReference(SystemMetadataReference);

                var document = project.AddDocument(file.Name, File.ReadAllText(file.FullName, Encoding.UTF8));
                project = document.Project;

                return project.Solution;
            }
        }
开发者ID:ozgurkayaist,项目名称:sonarlint-vs,代码行数:15,代码来源:CompilationHelper.cs

示例9: AddLanguage

        public AnalyzerLanguage AddLanguage(AnalyzerLanguage other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            if (this == None ||
                this == other)
            {
                return other;
            }

            return Both;
        }
开发者ID:jakobehn,项目名称:sonarlint-vs,代码行数:15,代码来源:AnalyzerLanguage.cs

示例10: Configuration

        public Configuration(string path, AnalyzerLanguage language)
        {
            if (!ParameterLoader.ConfigurationFilePathMatchesExpected(path))
            {
                throw new ArgumentException(
                    $"Input configuration doesn't match expected file name: '{ParameterLoader.ParameterConfigurationFileName}'",
                    nameof(path));
            }

            Path = path;
            analyzers = ImmutableArray.Create(GetAnalyzers(language).ToArray());

            var xml = XDocument.Load(path);
            var settings = ParseSettings(xml);
            IgnoreHeaderComments = "true".Equals(settings[$"sonar.{language}.ignoreHeaderComments"], StringComparison.OrdinalIgnoreCase);

            Files = xml.Descendants("File").Select(e => e.Value).ToImmutableList();

            AnalyzerIds = xml.Descendants("Rule").Select(e => e.Elements("Key").Single().Value).ToImmutableHashSet();
        }
开发者ID:duncanpMS,项目名称:sonarlint-vs,代码行数:20,代码来源:Configuration.cs

示例11: GetRuleDetail

        private static RuleDetail GetRuleDetail(Type analyzerType, AnalyzerLanguage language)
        {
            var rule = analyzerType.GetCustomAttributes<RuleAttribute>().Single();

            var ruleDetail = new RuleDetail
            {
                Key = rule.Key,
                Title = rule.Title,
                Severity = rule.Severity.ToString(),
                IsActivatedByDefault = rule.IsActivatedByDefault,
                Description = GetResourceHtml(rule, language)
            };

            GetParameters(analyzerType, ruleDetail);
            GetTags(analyzerType, ruleDetail);
            GetSqale(analyzerType, ruleDetail);
            GetCodeFixNames(analyzerType, ruleDetail);

            return ruleDetail;
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:20,代码来源:RuleDetailBuilder.cs

示例12: Convert

 public static RuleDescription Convert(RuleDetail detail, string productVersion, AnalyzerLanguage language)
 {
     return new RuleDescription
     {
         Key = detail.Key,
         Data = new Dictionary<string, RuleMetaData>
         {
             {
                 language.ToString(),
                 new RuleMetaData
                 {
                     Title = detail.Title,
                     Description =
                         GetParameterDescription(detail.Parameters) +
                         AddLinksBetweenRulesToDescription(detail.Description, productVersion) +
                         GetCodeFixDescription(detail),
                     Tags = detail.Tags,
                     Severity = detail.Severity,
                     IdeSeverity = detail.IdeSeverity
                 }
             }
         }
     };
 }
开发者ID:ozgurkayaist,项目名称:sonarlint-vs,代码行数:24,代码来源:RuleDescription.cs

示例13: Configuration

        public Configuration(XContainer xml, AnalyzerLanguage language)
        {
            this.language = language;
            nonTemplateAnalyzers = ImmutableArray.Create(GetNonTemplateAnalyzers(language).ToArray());

            var settings = ParseSettings(xml);
            IgnoreHeaderComments = "true".Equals(settings["sonar.cs.ignoreHeaderComments"]);

            Files = xml.Descendants("File").Select(e => e.Value).ToImmutableList();

            AnalyzerIds = xml.Descendants("Rule").Select(e => e.Elements("Key").Single().Value).ToImmutableHashSet();

            var builder = ImmutableList.CreateBuilder<RuleParameterValues>();
            foreach (var rule in xml.Descendants("Rule").Where(e => e.Elements("Parameters").Any()))
            {
                var analyzerId = rule.Elements("Key").Single().Value;

                var parameterValues = rule
                    .Elements("Parameters").Single()
                    .Elements("Parameter")
                    .Select(e => new RuleParameterValue
                    {
                        ParameterKey = e.Elements("Key").Single().Value,
                        ParameterValue = e.Elements("Value").Single().Value
                    });

                var pvs = new RuleParameterValues
                {
                    RuleId = analyzerId
                };
                pvs.ParameterValues.AddRange(parameterValues);

                builder.Add(pvs);
            }
            parameters = builder.ToImmutable();
        }
开发者ID:jango2015,项目名称:sonarlint-vs,代码行数:36,代码来源:Configuration.cs

示例14: Lines

 private static int Lines(AnalyzerLanguage language, string text) => MetricsFor(language, text).LineCount;
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:1,代码来源:MetricsTest.cs

示例15: FunctionComplexityDistribution

 private static Distribution FunctionComplexityDistribution(AnalyzerLanguage language, string text) =>
     MetricsFor(language, text).FunctionComplexityDistribution;
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:2,代码来源:MetricsTest.cs


注:本文中的SonarLint.Common.AnalyzerLanguage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。