private void AnalyzeAttributeList(SyntaxNodeAnalysisContext context) { var attributeList = (AttributeListSyntax)context.Node; if (DeclareEachAttributeSeparatelyRefactoring.CanRefactor(attributeList)) { context.ReportDiagnostic(DiagnosticDescriptors.DeclareEachAttributeSeparately, attributeList); } }
public override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false); if (!TryFindFirstAncestorOrSelf(root, context.Span, out AttributeListSyntax attributeList)) { return; } CodeAction codeAction = CodeAction.Create( "Split attributes", ct => DeclareEachAttributeSeparatelyRefactoring.RefactorAsync(context.Document, attributeList, ct), GetEquivalenceKey(DiagnosticIdentifiers.DeclareEachAttributeSeparately)); context.RegisterCodeFix(codeAction, context.Diagnostics); }
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); AttributeListSyntax attributeList = root .FindNode(context.Span, getInnermostNodeForTie: true)? .FirstAncestorOrSelf <AttributeListSyntax>(); if (attributeList == null) { return; } CodeAction codeAction = CodeAction.Create( "Split attributes", cancellationToken => DeclareEachAttributeSeparatelyRefactoring.RefactorAsync(context.Document, attributeList, cancellationToken), DiagnosticIdentifiers.DeclareEachAttributeSeparately + EquivalenceKeySuffix); context.RegisterCodeFix(codeAction, context.Diagnostics); }