本文整理汇总了C#中Microsoft.CodeAnalysis.CodeFixes.Suppression.AbstractSuppressionCodeFixProvider.IsAnyPragmaDirectiveForId方法的典型用法代码示例。如果您正苦于以下问题:C# AbstractSuppressionCodeFixProvider.IsAnyPragmaDirectiveForId方法的具体用法?C# AbstractSuppressionCodeFixProvider.IsAnyPragmaDirectiveForId怎么用?C# AbstractSuppressionCodeFixProvider.IsAnyPragmaDirectiveForId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CodeFixes.Suppression.AbstractSuppressionCodeFixProvider
的用法示例。
在下文中一共展示了AbstractSuppressionCodeFixProvider.IsAnyPragmaDirectiveForId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanRemovePragmaTrivia
private static bool CanRemovePragmaTrivia(SyntaxToken token, Diagnostic diagnostic, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, out int indexOfTriviaToRemove)
{
indexOfTriviaToRemove = -1;
var triviaList = GetTriviaListForSuppression(token, isStartToken, fixer);
var diagnosticSpan = diagnostic.Location.SourceSpan;
Func<SyntaxTrivia, bool> shouldIncludeTrivia = t => isStartToken ? t.FullSpan.End <= diagnosticSpan.Start : t.FullSpan.Start >= diagnosticSpan.End;
var filteredTriviaList = triviaList.Where(shouldIncludeTrivia);
if (isStartToken)
{
// Walk bottom up for leading trivia.
filteredTriviaList = filteredTriviaList.Reverse();
}
foreach (var trivia in filteredTriviaList)
{
bool isEnableDirective, hasMultipleIds;
if (fixer.IsAnyPragmaDirectiveForId(trivia, diagnostic.Id, out isEnableDirective, out hasMultipleIds))
{
if (hasMultipleIds)
{
// Handle only simple cases where we have a single pragma directive with single ID matching ours in the trivia.
return false;
}
// We want to look for leading disable directive and trailing enable directive.
if ((isStartToken && !isEnableDirective) ||
(!isStartToken && isEnableDirective))
{
indexOfTriviaToRemove = triviaList.IndexOf(trivia);
return true;
}
return false;
}
}
return false;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:40,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs