本文整理汇总了C#中Microsoft.CodeAnalysis.CodeFixes.Suppression.AbstractSuppressionCodeFixProvider类的典型用法代码示例。如果您正苦于以下问题:C# AbstractSuppressionCodeFixProvider类的具体用法?C# AbstractSuppressionCodeFixProvider怎么用?C# AbstractSuppressionCodeFixProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractSuppressionCodeFixProvider类属于Microsoft.CodeAnalysis.CodeFixes.Suppression命名空间,在下文中一共展示了AbstractSuppressionCodeFixProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewStartToken
private static SyntaxToken GetNewStartToken(SyntaxToken startToken, Diagnostic diagnostic, AbstractSuppressionCodeFixProvider fixer)
{
var trivia = startToken.LeadingTrivia.ToImmutableArray();
// Insert the #pragma disable directive after all leading new line trivia but before first trivia of any other kind.
int index;
SyntaxTrivia firstNonEOLTrivia = trivia.FirstOrDefault(t => !fixer.IsEndOfLine(t));
if (firstNonEOLTrivia == default(SyntaxTrivia))
{
index = trivia.Length;
}
else
{
index = trivia.IndexOf(firstNonEOLTrivia);
}
bool needsLeadingEOL;
if (index > 0)
{
needsLeadingEOL = !fixer.IsEndOfLine(trivia[index - 1]);
}
else if (startToken.FullSpan.Start == 0)
{
needsLeadingEOL = false;
}
else
{
needsLeadingEOL = true;
}
var pragmaWarningTrivia = fixer.CreatePragmaDisableDirectiveTrivia(diagnostic, needsLeadingEOL);
return startToken.WithLeadingTrivia(trivia.InsertRange(index, pragmaWarningTrivia));
}
开发者ID:noahfalk,项目名称:roslyn,代码行数:34,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs
示例2: Create
public static AttributeRemoveAction Create(
AttributeData attribute,
Project project,
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer)
{
return new AttributeRemoveAction(attribute, project, diagnostic, fixer);
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Attribute.cs
示例3: RemoveSuppressionCodeAction
protected RemoveSuppressionCodeAction(
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer,
bool forFixMultipleContext = false)
: base(fixer, title: string.Format(FeaturesResources.Remove_Suppression_0, diagnostic.Id))
{
_diagnostic = diagnostic;
_forFixMultipleContext = forFixMultipleContext;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.cs
示例4: LocalSuppressMessageCodeAction
public LocalSuppressMessageCodeAction(AbstractSuppressionCodeFixProvider fixer, ISymbol targetSymbol, SyntaxNode targetNode, Document document, Diagnostic diagnostic)
{
_fixer = fixer;
_targetSymbol = targetSymbol;
_targetNode = targetNode;
_document = document;
_diagnostic = diagnostic;
_title = FeaturesResources.SuppressWithLocalSuppressMessage;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:10,代码来源:AbstractSuppressionCodeFixProvider.LocalSuppressMessageCodeAction.cs
示例5: PragmaRemoveAction
private PragmaRemoveAction(
SuppressionTargetInfo suppressionTargetInfo,
Document document,
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer,
bool forFixMultipleContext = false)
: base(document, diagnostic, fixer, forFixMultipleContext)
{
_suppressionTargetInfo = suppressionTargetInfo;
}
开发者ID:nemec,项目名称:roslyn,代码行数:10,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs
示例6: AttributeRemoveAction
private AttributeRemoveAction(
AttributeData attribute,
Project project,
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer,
bool forFixMultipleContext = false)
: base(diagnostic, fixer, forFixMultipleContext)
{
_project = project;
_attribute = attribute;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:11,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Attribute.cs
示例7: Create
public static PragmaWarningCodeAction Create(
SuppressionTargetInfo suppressionTargetInfo,
Document document,
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer)
{
// We need to normalize the leading trivia on start token to account for
// the trailing trivia on its previous token (and similarly normalize trailing trivia for end token).
PragmaHelpers.NormalizeTriviaOnTokens(fixer, ref document, ref suppressionTargetInfo);
return new PragmaWarningCodeAction(suppressionTargetInfo, document, diagnostic, fixer);
}
开发者ID:ralfkang,项目名称:roslyn,代码行数:12,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs
示例8: PragmaWarningCodeAction
private PragmaWarningCodeAction(
SuppressionTargetInfo suppressionTargetInfo,
Document document,
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer,
bool forFixMultipleContext = false)
: base(fixer, title: FeaturesResources.SuppressWithPragma)
{
_suppressionTargetInfo = suppressionTargetInfo;
_document = document;
_diagnostic = diagnostic;
_forFixMultipleContext = forFixMultipleContext;
}
开发者ID:ralfkang,项目名称:roslyn,代码行数:13,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs
示例9: PragmaWarningCodeAction
public PragmaWarningCodeAction(
AbstractSuppressionCodeFixProvider fixer,
SyntaxToken startToken,
SyntaxToken endToken,
SyntaxNode nodeWithTokens,
Document document,
Diagnostic diagnostic)
: base (fixer, title: FeaturesResources.SuppressWithPragma)
{
_startToken = startToken;
_endToken = endToken;
_nodeWithTokens = nodeWithTokens;
_document = document;
_diagnostic = diagnostic;
}
开发者ID:noahfalk,项目名称:roslyn,代码行数:15,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs
示例10: CreateBatchPragmaFix
public static CodeAction CreateBatchPragmaFix(
AbstractSuppressionCodeFixProvider suppressionFixProvider,
Document document,
ImmutableArray<IPragmaBasedCodeAction> pragmaActions,
ImmutableArray<Diagnostic> pragmaDiagnostics,
FixAllContext fixAllContext)
{
// This is a temporary generated code action, which doesn't need telemetry, hence suppressing RS0005.
#pragma warning disable RS0005 // Do not use generic CodeAction.Create to create CodeAction
return CodeAction.Create(
((CodeAction)pragmaActions[0]).Title,
createChangedDocument: ct =>
BatchPragmaFixesAsync(suppressionFixProvider, document, pragmaActions, pragmaDiagnostics, fixAllContext.CancellationToken),
equivalenceKey: fixAllContext.CodeActionEquivalenceKey);
#pragma warning restore RS0005 // Do not use generic CodeAction.Create to create CodeAction
}
示例11: PragmaWarningCodeAction
public PragmaWarningCodeAction(
AbstractSuppressionCodeFixProvider fixer,
SyntaxToken startToken,
SyntaxToken endToken,
SyntaxNode nodeWithTokens,
Document document,
Diagnostic diagnostic)
{
_fixer = fixer;
_startToken = startToken;
_endToken = endToken;
_nodeWithTokens = nodeWithTokens;
_document = document;
_diagnostic = diagnostic;
_title = fixer.TitleForPragmaWarningSuppressionFix;
}
开发者ID:JRobertGit,项目名称:roslyn,代码行数:17,代码来源:AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs
示例12: CreateAsync
public static async Task<RemoveSuppressionCodeAction> CreateAsync(
SuppressionTargetInfo suppressionTargetInfo,
Document document,
Diagnostic diagnostic,
AbstractSuppressionCodeFixProvider fixer,
CancellationToken cancellationToken)
{
var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var attribute = diagnostic.GetSuppressionInfo(compilation).Attribute;
if (attribute != null)
{
return AttributeRemoveAction.Create(attribute, document, diagnostic, fixer);
}
else
{
return PragmaRemoveAction.Create(suppressionTargetInfo, document, diagnostic, fixer);
}
}
开发者ID:nemec,项目名称:roslyn,代码行数:18,代码来源:AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.cs
示例13: CreateChangedSolutionAsync
private static async Task<Solution> CreateChangedSolutionAsync(AbstractSuppressionCodeFixProvider fixer, Project triggerProject, ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject, CancellationToken cancellationToken)
{
var currentSolution = triggerProject.Solution;
foreach (var kvp in diagnosticsByProject)
{
var oldProject = kvp.Key;
var currentProject = currentSolution.GetProject(oldProject.Id);
var diagnosticsBySymbol = await CreateDiagnosticsBySymbolAsync(fixer, oldProject, kvp.Value, cancellationToken).ConfigureAwait(false);
if (diagnosticsBySymbol.Any())
{
var projectCodeAction = new GlobalSuppressMessageFixAllCodeAction(fixer, diagnosticsBySymbol, currentProject);
var newDocument = await projectCodeAction.GetChangedSuppressionDocumentAsync(cancellationToken).ConfigureAwait(false);
currentSolution = newDocument.Project.Solution;
}
}
return currentSolution;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:18,代码来源:AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs
示例14: CreateDiagnosticsBySymbolAsync
private static async Task<IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>> CreateDiagnosticsBySymbolAsync(AbstractSuppressionCodeFixProvider fixer, IEnumerable<KeyValuePair<Document, ImmutableArray<Diagnostic>>> diagnosticsByDocument, CancellationToken cancellationToken)
{
var diagnosticsMapBuilder = ImmutableDictionary.CreateBuilder<ISymbol, List<Diagnostic>>();
foreach (var kvp in diagnosticsByDocument)
{
var document = kvp.Key;
var diagnostics = kvp.Value;
foreach (var diagnostic in diagnostics)
{
Contract.ThrowIfFalse(diagnostic.Location.IsInSource);
var suppressionTargetInfo = await fixer.GetSuppressionTargetInfoAsync(document, diagnostic.Location.SourceSpan, cancellationToken).ConfigureAwait(false);
if (suppressionTargetInfo != null)
{
var targetSymbol = suppressionTargetInfo.TargetSymbol;
Contract.ThrowIfNull(targetSymbol);
AddDiagnosticForSymbolIfNeeded(targetSymbol, diagnostic, diagnosticsMapBuilder);
}
}
}
return CreateDiagnosticsBySymbol(diagnosticsMapBuilder);
}
开发者ID:noahfalk,项目名称:roslyn,代码行数:22,代码来源:AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs
示例15: GetPositionForPragmaInsertion
private static int GetPositionForPragmaInsertion(ImmutableArray<SyntaxTrivia> triviaList, TextSpan currentDiagnosticSpan, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, out SyntaxTrivia triviaAtIndex)
{
// Start token: Insert the #pragma disable directive just **before** the first end of line trivia prior to diagnostic location.
// End token: Insert the #pragma disable directive just **after** the first end of line trivia after diagnostic location.
Func<int, int> getNextIndex = cur => isStartToken ? cur - 1 : cur + 1;
Func<SyntaxTrivia, bool> shouldConsiderTrivia = trivia =>
isStartToken ?
trivia.FullSpan.End <= currentDiagnosticSpan.Start :
trivia.FullSpan.Start >= currentDiagnosticSpan.End;
var walkedPastDiagnosticSpan = false;
var seenEndOfLineTrivia = false;
var index = isStartToken ? triviaList.Length - 1 : 0;
while (index >= 0 && index < triviaList.Length)
{
var trivia = triviaList[index];
walkedPastDiagnosticSpan = walkedPastDiagnosticSpan || shouldConsiderTrivia(trivia);
seenEndOfLineTrivia = seenEndOfLineTrivia ||
(fixer.IsEndOfLine(trivia) ||
(trivia.HasStructure &&
trivia.GetStructure().DescendantTrivia().Any(t => fixer.IsEndOfLine(t))));
if (walkedPastDiagnosticSpan && seenEndOfLineTrivia)
{
break;
}
index = getNextIndex(index);
}
triviaAtIndex = index >= 0 && index < triviaList.Length ?
triviaList[index] :
default(SyntaxTrivia);
return index;
}
开发者ID:robertoenbarcelona,项目名称:roslyn,代码行数:38,代码来源:AbstractSuppressionCodeFixProvider.PragmaHelpers.cs