src\Analyzers\Core\CodeFixes\ConvertToAsync\AbstractConvertToAsyncCodeFixProvider.cs (4)
20protected abstract Task<string> GetDescriptionAsync(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
21protected abstract Task<Tuple<SyntaxTree, SyntaxNode>> GetRootInOtherSyntaxTreeAsync(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
38var diagnostic = context.Diagnostics.FirstOrDefault();
62SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchCodeFixProvider.cs (7)
57var diagnostic = context.Diagnostics.First();
105Document document, Diagnostic diagnostic,
114Document document, ImmutableArray<Diagnostic> diagnostics,
124Document document, SyntaxEditor editor, ImmutableArray<Diagnostic> diagnostics,
128foreach (var diagnostic in diagnostics)
137Document document, SyntaxEditor editor, Diagnostic diagnostic,
221ImmutableArray<Diagnostic> diagnostics,
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (17)
134var diagnostic = context.Diagnostics[0];
203private static bool IsForEachIterationVariableDiagnostic(Diagnostic diagnostic, Document document, CancellationToken cancellationToken)
214private static string GetEquivalenceKey(Diagnostic diagnostic)
233protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken)
239private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
240ImmutableArray<Diagnostic> diagnostics,
252foreach (var diagnostic in diagnostics)
264private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
265ImmutableArray<Diagnostic> diagnostics,
272private static async Task<Document> PreprocessDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
284protected sealed override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CancellationToken cancellationToken)
295ImmutableArray<Diagnostic> diagnostics,
346IEnumerable<Diagnostic> diagnostics,
383IOrderedEnumerable<Diagnostic> diagnostics,
399foreach (var diagnostic in diagnostics)
442IOrderedEnumerable<Diagnostic> diagnostics,
675foreach (var diagnostic in diagnostics)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (9)
48protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, Diagnostic? diagnostic = null)
51protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, CodeActionPriority priority, Diagnostic? diagnostic = null)
54protected Func<CancellationToken, Task<Document>> GetDocumentUpdater(CodeFixContext context, Diagnostic? diagnostic = null)
61Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
89Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CancellationToken cancellationToken);
97/// This overload differs from <see cref="IncludeDiagnosticDuringFixAll(Diagnostic)"/> in that it also passes along
103protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken)
115/// cref="IFixAllState.CodeActionEquivalenceKey"/>), then <see cref="IncludeDiagnosticDuringFixAll(Diagnostic,
120protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic)
src\Analyzers\CSharp\Analyzers\MakeAnonymousFunctionStatic\MakeAnonymousFunctionStaticDiagnosticAnalyzer.cs (1)
52Diagnostic.Create(
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (7)
37protected override SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken)
44Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken)
51SyntaxToken disableOrRestoreKeyword, Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken)
103Diagnostic diagnostic,
130SyntaxNode targetNode, ISymbol targetSymbol, INamedTypeSymbol suppressMessageAttribute, Diagnostic diagnostic)
154Diagnostic diagnostic,
177private static AttributeArgumentListSyntax CreateAttributeArguments(ISymbol targetSymbol, Diagnostic diagnostic, bool isAssemblyAttribute)
src\Analyzers\CSharp\Analyzers\MakeAnonymousFunctionStatic\MakeAnonymousFunctionStaticDiagnosticAnalyzer.cs (1)
52Diagnostic.Create(
CodeFixes\Configuration\ConfigureSeverity\ConfigureSeverityLevelCodeFixProvider.cs (9)
41public bool IsFixableDiagnostic(Diagnostic diagnostic)
47public Task<ImmutableArray<CodeFix>> GetFixesAsync(TextDocument document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
50public Task<ImmutableArray<CodeFix>> GetFixesAsync(Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
53private static ImmutableArray<CodeFix> GetConfigurations(Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
56var analyzerDiagnosticsByCategory = new SortedDictionary<string, ArrayBuilder<Diagnostic>>();
57using var disposer = ArrayBuilder<Diagnostic>.GetInstance(out var analyzerDiagnostics);
58foreach (var diagnostic in diagnostics)
79var diagnosticsForCategory = analyzerDiagnosticsByCategory.GetOrAdd(diagnostic.Descriptor.Category, _ => ArrayBuilder<Diagnostic>.GetInstance());
99void AddBulkConfigurationCodeFixes(ImmutableArray<Diagnostic> diagnostics, string? category)
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (16)
45ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap,
74private async Task<ImmutableArray<(Diagnostic diagnostic, CodeAction action)>> GetDiagnosticsAndCodeActionsAsync(
75ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap,
95return await ProducerConsumer<(Diagnostic diagnostic, CodeAction action)>.RunParallelAsync(
112Document document, ImmutableArray<Diagnostic> diagnostics,
113Action<(Diagnostic diagnostic, CodeAction action)> onItemFound,
135ImmutableDictionary<Project, ImmutableArray<Diagnostic>> projectsAndDiagnosticsToFixMap,
146var bag = new ConcurrentBag<(Diagnostic diagnostic, CodeAction action)>();
175private static Action<CodeAction, ImmutableArray<Diagnostic>> GetRegisterCodeFixAction(
177Action<(Diagnostic diagnostic, CodeAction action)> onItemFound)
200Project project, ImmutableArray<Diagnostic> diagnostics,
201ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> fixes,
208ImmutableArray<(Diagnostic diagnostic, CodeAction action)> batchOfFixes,
227ImmutableArray<(Diagnostic diagnostic, CodeAction action)> diagnosticsAndCodeActions,
250ImmutableArray<(Diagnostic diagnostic, CodeAction action)> diagnosticsAndCodeActions,
273ImmutableArray<(Diagnostic diagnostic, CodeAction action)> diagnosticsAndCodeActions,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (12)
44public bool IsFixableDiagnostic(Diagnostic diagnostic)
47protected abstract SyntaxTriviaList CreatePragmaDisableDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken);
48protected abstract SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken);
54Diagnostic diagnostic,
61SyntaxNode targetNode, ISymbol targetSymbol, INamedTypeSymbol suppressMessageAttribute, Diagnostic diagnostic);
80protected static string GetOrMapDiagnosticId(Diagnostic diagnostic, out bool includeTitle)
142TextDocument textDocument, TextSpan span, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
150internal async Task<ImmutableArray<PragmaWarningCodeAction>> GetPragmaSuppressionsAsync(Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
159Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken)
172Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
188Document documentOpt, Project project, IEnumerable<Diagnostic> diagnostics, SuppressionTargetInfo suppressionTargetInfo, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken)
207foreach (var diagnostic in diagnostics)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs (22)
28private readonly IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>> _diagnosticsBySymbol;
33IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>> diagnosticsBySymbol,
41internal static CodeAction Create(string title, AbstractSuppressionCodeFixProvider fixer, Document triggerDocument, ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsByDocument)
48internal static CodeAction Create(string title, AbstractSuppressionCodeFixProvider fixer, Project triggerProject, ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject)
70ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsByDocument,
99ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject,
152private static async Task<IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>> CreateDiagnosticsBySymbolAsync(AbstractSuppressionCodeFixProvider fixer, IEnumerable<KeyValuePair<Document, ImmutableArray<Diagnostic>>> diagnosticsByDocument, CancellationToken cancellationToken)
154var diagnosticsMapBuilder = ImmutableDictionary.CreateBuilder<ISymbol, List<Diagnostic>>();
173private static async Task<IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>> CreateDiagnosticsBySymbolAsync(Project project, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
175var diagnosticsMapBuilder = ImmutableDictionary.CreateBuilder<ISymbol, List<Diagnostic>>();
179foreach (var diagnostic in diagnostics)
190private static void AddDiagnosticForSymbolIfNeeded(ISymbol targetSymbol, Diagnostic diagnostic, ImmutableDictionary<ISymbol, List<Diagnostic>>.Builder diagnosticsMapBuilder)
206private static IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>> CreateDiagnosticsBySymbol(ImmutableDictionary<ISymbol, List<Diagnostic>>.Builder diagnosticsMapBuilder)
211var builder = new List<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>();
218private static ImmutableArray<Diagnostic> GetUniqueDiagnostics(List<Diagnostic> diagnostics)
221var uniqueDiagnostics = ArrayBuilder<Diagnostic>.GetInstance();
222foreach (var diagnostic in diagnostics)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs (9)
35Document document, ImmutableArray<Diagnostic> diagnostics,
36Action<(Diagnostic diagnostic, CodeAction action)> onItemFound,
41using var _2 = ArrayBuilder<Diagnostic>.GetInstance(out var pragmaDiagnosticsBuilder);
43foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && d.IsSuppressed))
85Project project, ImmutableArray<Diagnostic> diagnostics,
86ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> bag,
89foreach (var diagnostic in diagnostics.Where(d => !d.Location.IsInSource && d.IsSuppressed))
106ImmutableArray<(Diagnostic diagnostic, CodeAction action)> batchOfFixes,
119var newBatchOfFixes = new List<(Diagnostic diagnostic, CodeAction action)>();
EditAndContinue\DebuggingSession.cs (7)
241internal Task<(Guid Mvid, Diagnostic? Error)> GetProjectModuleIdAsync(Project project, CancellationToken cancellationToken)
247(Guid Mvid, Diagnostic? Error) ReadMvid()
262return (Mvid: Guid.Empty, Error: Diagnostic.Create(descriptor, Location.None, [outputs.AssemblyDisplayPath, e.Message]));
278out ImmutableArray<Diagnostic> errors,
328out ImmutableArray<Diagnostic> errors,
382errors = [Diagnostic.Create(descriptor, Location.None, [fileBeingRead, e.Message])];
409public async ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken)
EditAndContinue\EditSession.cs (12)
118private async Task<Diagnostic?> GetUnsupportedChangesDiagnosticAsync(EmitDifferenceResult emitResult, CancellationToken cancellationToken)
140return Diagnostic.Create(descriptor, Location.None);
151public async Task<ImmutableArray<Diagnostic>?> GetModuleDiagnosticsAsync(Guid mvid, Project oldProject, Project newProject, ImmutableArray<DocumentAnalysisResults> documentAnalyses, CancellationToken cancellationToken)
163return ImmutableArray<Diagnostic>.Empty;
169using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnostics);
173diagnostics.Add(Diagnostic.Create(descriptor, location, messageArgs));
526private async Task<(ImmutableArray<DocumentAnalysisResults> results, ImmutableArray<Diagnostic> diagnostics)> AnalyzeDocumentsAsync(
531using var _1 = ArrayBuilder<Diagnostic>.GetInstance(out var documentDiagnostics);
546documentDiagnostics.Add(Diagnostic.Create(descriptor, Location.Create(newDocument.FilePath!, textSpan: default, lineSpan: default), [newDocument.FilePath]));
813Diagnostic? syntaxError = null;
999var emitDiagnostics = ImmutableArray<Diagnostic>.Empty;
1053var unsupportedChangesDiagnostic = await GetUnsupportedChangesDiagnosticAsync(emitResult, cancellationToken).ConfigureAwait(false);
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (20)
89Action<Diagnostic> reportDiagnostic,
389private static async Task<(ImmutableArray<Diagnostic> reportedDiagnostics, ImmutableArray<string> unhandledIds)> GetReportedDiagnosticsForIdsAsync(
450using var _3 = ArrayBuilder<Diagnostic>.GetInstance(out var reportedDiagnostics);
483static void AddAllDiagnostics(ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> diagnostics, ArrayBuilder<Diagnostic> reportedDiagnostics)
491static void AddAllCompilationDiagnosticsForTree(AnalysisResult analysisResult, SyntaxTree tree, ArrayBuilder<Diagnostic> reportedDiagnostics)
495foreach (var diagnostic in perAnalyzerDiagnostics)
507ImmutableArray<Diagnostic> diagnostics,
516foreach (var diagnostic in diagnostics)
544Diagnostic diagnostic,
584Diagnostic diagnostic,
612Action<Diagnostic> reportDiagnostic,
616using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnosticsBuilder);
622foreach (var diagnostic in effectiveDiagnostics)
630ArrayBuilder<Diagnostic> diagnosticsBuilder,
655var diagnostic = Diagnostic.Create(s_removeUnnecessarySuppressionDescriptor, pragma.GetLocation(), severity, additionalLocations, properties: null);
662ArrayBuilder<Diagnostic> diagnosticsBuilder,
670var diagnostic = Diagnostic.Create(s_removeUnnecessarySuppressionDescriptor, attribute.GetLocation(), severity, additionalLocations: null, properties: null);
src\Analyzers\Core\Analyzers\SimplifyTypeNames\SimplifyTypeNamesDiagnosticAnalyzerBase.cs (5)
111protected abstract ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context, SyntaxNode root);
112protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanMutableIntervalTree? codeBlockIntervalTree);
114public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, AnalyzerOptions analyzerOptions, CancellationToken cancellationToken)
135internal static Diagnostic CreateDiagnostic(SemanticModel model, TSimplifierOptions options, AnalyzerOptions analyzerOptions, TextSpan issueSpan, string diagnosticId, bool inDeclaration)
167var diagnostic = DiagnosticHelper.Create(descriptor, tree.GetLocation(issueSpan), notificationOption, analyzerOptions, additionalLocations: null, builder.ToImmutable());
src\Analyzers\Core\CodeFixes\ConvertToAsync\AbstractConvertToAsyncCodeFixProvider.cs (4)
20protected abstract Task<string> GetDescriptionAsync(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
21protected abstract Task<Tuple<SyntaxTree, SyntaxNode>> GetRootInOtherSyntaxTreeAsync(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
38var diagnostic = context.Diagnostics.FirstOrDefault();
62SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchCodeFixProvider.cs (7)
57var diagnostic = context.Diagnostics.First();
105Document document, Diagnostic diagnostic,
114Document document, ImmutableArray<Diagnostic> diagnostics,
124Document document, SyntaxEditor editor, ImmutableArray<Diagnostic> diagnostics,
128foreach (var diagnostic in diagnostics)
137Document document, SyntaxEditor editor, Diagnostic diagnostic,
221ImmutableArray<Diagnostic> diagnostics,
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (17)
134var diagnostic = context.Diagnostics[0];
203private static bool IsForEachIterationVariableDiagnostic(Diagnostic diagnostic, Document document, CancellationToken cancellationToken)
214private static string GetEquivalenceKey(Diagnostic diagnostic)
233protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken)
239private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
240ImmutableArray<Diagnostic> diagnostics,
252foreach (var diagnostic in diagnostics)
264private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
265ImmutableArray<Diagnostic> diagnostics,
272private static async Task<Document> PreprocessDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
284protected sealed override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CancellationToken cancellationToken)
295ImmutableArray<Diagnostic> diagnostics,
346IEnumerable<Diagnostic> diagnostics,
383IOrderedEnumerable<Diagnostic> diagnostics,
399foreach (var diagnostic in diagnostics)
442IOrderedEnumerable<Diagnostic> diagnostics,
675foreach (var diagnostic in diagnostics)