本文整理汇总了C#中ImmutableDictionary.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableDictionary.GetValueOrDefault方法的具体用法?C# ImmutableDictionary.GetValueOrDefault怎么用?C# ImmutableDictionary.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableDictionary
的用法示例。
在下文中一共展示了ImmutableDictionary.GetValueOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleSyntaxTreeAnalysis
private static void HandleSyntaxTreeAnalysis(SyntaxTreeAnalysisContext context, ImmutableDictionary<string, ReportDiagnostic> specificDiagnosticOptions)
{
var syntaxRoot = context.Tree.GetRoot(context.CancellationToken);
foreach (var trivia in syntaxRoot.DescendantTrivia().Where(trivia => trivia.IsKind(SyntaxKind.SingleLineCommentTrivia)))
{
if (trivia.ToString().StartsWith("////", StringComparison.Ordinal))
{
// ignore commented out code
continue;
}
int triviaIndex;
var triviaList = TriviaHelper.GetContainingTriviaList(trivia, out triviaIndex);
if (!IsOnOwnLine(triviaList, triviaIndex))
{
// ignore comments after other code elements.
continue;
}
if (IsPartOfFileHeader(triviaList, triviaIndex))
{
// ignore comments that are part of the file header.
continue;
}
var trailingBlankLineCount = GetTrailingBlankLineCount(triviaList, ref triviaIndex);
if (trailingBlankLineCount == 0)
{
// ignore comments that are not followed by a blank line
continue;
}
else if (trailingBlankLineCount > 1)
{
if (specificDiagnosticOptions.GetValueOrDefault(SA1507CodeMustNotContainMultipleBlankLinesInARow.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress)
{
// ignore comments that are followed by multiple blank lines -> the multiple blank lines will be reported by SA1507
continue;
}
}
else
{
if (triviaIndex < triviaList.Count)
{
switch (triviaList[triviaIndex].Kind())
{
case SyntaxKind.SingleLineCommentTrivia:
case SyntaxKind.SingleLineDocumentationCommentTrivia:
case SyntaxKind.MultiLineCommentTrivia:
case SyntaxKind.MultiLineDocumentationCommentTrivia:
// ignore a single blank line in between two comments.
continue;
}
}
}
var diagnosticSpan = TextSpan.FromBounds(trivia.SpanStart, trivia.SpanStart + 2);
context.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.Create(context.Tree, diagnosticSpan)));
}
}
开发者ID:BeeFrog,项目名称:StyleCopAnalyzers,代码行数:61,代码来源:SA1512SingleLineCommentsMustNotBeFollowedByBlankLine.cs