本文整理汇总了C#中SyntaxTreeAnalysisContext.GetStyleCopSettings方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTreeAnalysisContext.GetStyleCopSettings方法的具体用法?C# SyntaxTreeAnalysisContext.GetStyleCopSettings怎么用?C# SyntaxTreeAnalysisContext.GetStyleCopSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTreeAnalysisContext
的用法示例。
在下文中一共展示了SyntaxTreeAnalysisContext.GetStyleCopSettings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleSyntaxTreeAxtion
private static void HandleSyntaxTreeAxtion(SyntaxTreeAnalysisContext context, Compilation compilation)
{
var root = context.Tree.GetRoot(context.CancellationToken);
var settings = context.GetStyleCopSettings();
// don't process empty files
if (root.FullSpan.IsEmpty)
{
return;
}
if (settings.DocumentationRules.XmlHeader)
{
var fileHeader = FileHeaderHelpers.ParseXmlFileHeader(root);
if (fileHeader.IsMissing)
{
context.ReportDiagnostic(Diagnostic.Create(SA1633DescriptorMissing, fileHeader.GetLocation(context.Tree)));
return;
}
if (fileHeader.IsMalformed)
{
context.ReportDiagnostic(Diagnostic.Create(SA1633DescriptorMalformed, fileHeader.GetLocation(context.Tree)));
return;
}
if (!compilation.IsAnalyzerSuppressed(SA1634Identifier))
{
CheckCopyrightHeader(context, compilation, settings, fileHeader);
}
if (!compilation.IsAnalyzerSuppressed(SA1639Identifier))
{
CheckSummaryHeader(context, compilation, fileHeader);
}
}
else
{
var fileHeader = FileHeaderHelpers.ParseFileHeader(root);
if (fileHeader.IsMissing)
{
context.ReportDiagnostic(Diagnostic.Create(SA1633DescriptorMissing, fileHeader.GetLocation(context.Tree)));
return;
}
if (!compilation.IsAnalyzerSuppressed(SA1635Identifier))
{
if (string.IsNullOrWhiteSpace(fileHeader.CopyrightText))
{
context.ReportDiagnostic(Diagnostic.Create(SA1635Descriptor, fileHeader.GetLocation(context.Tree)));
return;
}
if (compilation.IsAnalyzerSuppressed(SA1636Identifier))
{
return;
}
// make sure that both \n and \r\n are accepted from the settings.
var reformattedCopyrightText = settings.DocumentationRules.CopyrightText.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);
if (string.CompareOrdinal(fileHeader.CopyrightText, reformattedCopyrightText) != 0)
{
context.ReportDiagnostic(Diagnostic.Create(SA1636Descriptor, fileHeader.GetLocation(context.Tree)));
}
}
}
}
示例2: HandleSyntaxTreeAction
private static void HandleSyntaxTreeAction(SyntaxTreeAnalysisContext context, Compilation compilation)
{
var root = context.Tree.GetRoot(context.CancellationToken);
var settings = context.GetStyleCopSettings();
// don't process empty files
if (root.FullSpan.IsEmpty)
{
return;
}
if (settings.DocumentationRules.XmlHeader)
{
var fileHeader = FileHeaderHelpers.ParseXmlFileHeader(root);
if (fileHeader.IsMissing)
{
context.ReportDiagnostic(Diagnostic.Create(SA1633DescriptorMissing, fileHeader.GetLocation(context.Tree)));
return;
}
if (fileHeader.IsMalformed)
{
context.ReportDiagnostic(Diagnostic.Create(SA1633DescriptorMalformed, fileHeader.GetLocation(context.Tree)));
return;
}
if (!compilation.IsAnalyzerSuppressed(SA1634Identifier))
{
CheckCopyrightHeader(context, compilation, settings, fileHeader);
}
if (!compilation.IsAnalyzerSuppressed(SA1639Identifier))
{
CheckSummaryHeader(context, compilation, fileHeader);
}
}
else
{
var fileHeader = FileHeaderHelpers.ParseFileHeader(root);
if (fileHeader.IsMissing)
{
context.ReportDiagnostic(Diagnostic.Create(SA1633DescriptorMissing, fileHeader.GetLocation(context.Tree)));
return;
}
if (!compilation.IsAnalyzerSuppressed(SA1635Identifier))
{
if (string.IsNullOrWhiteSpace(fileHeader.CopyrightText))
{
context.ReportDiagnostic(Diagnostic.Create(SA1635Descriptor, fileHeader.GetLocation(context.Tree)));
return;
}
if (compilation.IsAnalyzerSuppressed(SA1636Identifier))
{
return;
}
if (!CompareCopyrightText(fileHeader.CopyrightText, settings))
{
context.ReportDiagnostic(Diagnostic.Create(SA1636Descriptor, fileHeader.GetLocation(context.Tree)));
return;
}
}
}
}