src\roslyn\src\Analyzers\Core\CodeFixes\ConvertToAsync\AbstractConvertToAsyncCodeFixProvider.cs (3)
18protected abstract Task<string> GetDescriptionAsync(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
19protected abstract Task<(SyntaxTree syntaxTree, SyntaxNode root)?> GetRootInOtherSyntaxTreeAsync(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
52SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
src\roslyn\src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchCodeFixProvider.cs (7)
52var diagnostic = context.Diagnostics.First();
98Document document, Diagnostic diagnostic,
107Document document, ImmutableArray<Diagnostic> diagnostics,
117Document document, SyntaxEditor editor, ImmutableArray<Diagnostic> diagnostics,
121foreach (var diagnostic in diagnostics)
130Document document, SyntaxEditor editor, Diagnostic diagnostic,
213ImmutableArray<Diagnostic> diagnostics,
src\roslyn\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\roslyn\src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForReturn\AbstractUseConditionalExpressionForReturnCodeFixProvider.cs (1)
45Diagnostic diagnostic,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (9)
57protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, Diagnostic? diagnostic = null)
60protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, CodeActionPriority priority, Diagnostic? diagnostic = null)
63protected Func<CancellationToken, Task<Document>> GetDocumentUpdater(CodeFixContext context, Diagnostic? diagnostic = null)
70Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
98Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CancellationToken cancellationToken);
105/// <para/> This overload differs from <see cref="IncludeDiagnosticDuringFixAll(Diagnostic)"/> in that it also
111protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken)
122/// cref="IncludeDiagnosticDuringFixAll(Diagnostic, Document, string, CancellationToken)"/> should be overridden
127protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic)
src\roslyn\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\roslyn\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\Service\CodeFixService.cs (14)
505var uniqueDiagnosticToEquivalenceKeysMap = new Dictionary<Diagnostic, PooledHashSet<string?>>();
510var diagnosticAndEquivalenceKeyToFixersMap = new Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider>();
550var primaryDiagnostic = dxs.First();
658ImmutableArray<Diagnostic> diagnostics,
659Dictionary<Diagnostic, PooledHashSet<string?>> uniqueDiagosticToEquivalenceKeysMap,
660Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider> diagnosticAndEquivalenceKeyToFixersMap,
694static ImmutableArray<Diagnostic> FilterApplicableDiagnostics(
695ImmutableArray<Diagnostic> applicableDiagnostics,
698Dictionary<Diagnostic, PooledHashSet<string?>> uniqueDiagosticToEquivalenceKeysMap,
699Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider> diagnosticAndEquivalenceKeyToFixersMap)
701using var disposer = ArrayBuilder<Diagnostic>.GetInstance(out var newApplicableDiagnostics);
702foreach (var diagnostic in applicableDiagnostics)
777Func<Diagnostic, bool> hasFix,
778Func<ImmutableArray<Diagnostic>, Task<ImmutableArray<CodeFix>>> getFixes,
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)
157Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken)
170Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
186Document? documentOpt, Project project, IEnumerable<Diagnostic> diagnostics, SuppressionTargetInfo suppressionTargetInfo, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken)
205foreach (var diagnostic in diagnostics)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs (24)
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,
138foreach (var diagnostic in diagnostics)
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>>();
157foreach (var diagnostic in diagnostics)
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)>();
Diagnostics\Service\DocumentAnalysisExecutor_Helpers.cs (13)
28internal static Diagnostic CreateAnalyzerExceptionDiagnostic(DiagnosticAnalyzer analyzer, Exception e)
44return Diagnostic.Create(descriptor, Location.None, analyzerName, e.GetType(), e.Message);
78public static async Task<ImmutableArray<Diagnostic>> ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync(
88ImmutableArray<Diagnostic> diagnostics;
124private static async Task VerifyDiagnosticLocationsAsync(ImmutableArray<Diagnostic> diagnostics, Project project, CancellationToken cancellationToken)
126foreach (var diagnostic in diagnostics)
209internal static bool AreEquivalent(Diagnostic[] diagnosticsA, Diagnostic[] diagnosticsB)
211var set = new HashSet<Diagnostic>(diagnosticsA, DiagnosticComparer.Instance);
215private sealed class DiagnosticComparer : IEqualityComparer<Diagnostic?>
219public bool Equals(Diagnostic? x, Diagnostic? y)
229public int GetHashCode(Diagnostic? obj)
EditAndContinue\DebuggingSession.cs (7)
275internal Task<(Guid Mvid, Diagnostic? Error)> GetProjectModuleIdAsync(Project project, CancellationToken cancellationToken)
282(Guid Mvid, Diagnostic? Error) ReadMvid()
297return (Mvid: Guid.Empty, Error: Diagnostic.Create(descriptor, Location.None, [outputs.AssemblyDisplayPath, e.Message]));
313ArrayBuilder<Diagnostic> diagnostics,
374ArrayBuilder<Diagnostic> diagnostics,
427diagnostics.Add(Diagnostic.Create(descriptor, Location.None, [fileBeingRead, e.Message]));
454public async ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken)
EditAndContinue\EditSession.cs (23)
122private async Task<Diagnostic?> GetUnsupportedChangesDiagnosticAsync(EmitDifferenceResult emitResult, CancellationToken cancellationToken)
144return Diagnostic.Create(descriptor, Location.None);
155public async Task<string?> ReportModuleDiagnosticsAsync(Guid mvid, Project oldProject, Project newProject, ImmutableArray<DocumentAnalysisResults> documentAnalyses, ArrayBuilder<Diagnostic> diagnostics, CancellationToken cancellationToken)
168diagnostics.Add(Diagnostic.Create(descriptor, location, messageArgs));
497internal static async Task GetProjectDifferencesAsync(TraceLog log, Project? oldProject, Project newProject, ProjectDifferences documentDifferences, ArrayBuilder<Diagnostic> diagnostics, CancellationToken cancellationToken)
551private static async ValueTask<TextDocumentStates<SourceGeneratedDocumentState>> GetSourceGeneratedDocumentStatesAsync(TraceLog log, Project project, ArrayBuilder<Diagnostic>? diagnostics, CancellationToken cancellationToken)
559foreach (var generatorDiagnostic in generatorDiagnostics)
617ArrayBuilder<Diagnostic> diagnostics,
634diagnostics.Add(Diagnostic.Create(descriptor, Location.Create(newDocument.FilePath!, textSpan: default, lineSpan: default), [newDocument.FilePath]));
682diagnostics.Add(Diagnostic.Create(
733private static bool HasProjectSettingsBlockingRudeEdits(Project oldProject, Project newProject, ArrayBuilder<Diagnostic> diagnostics)
741foreach (var diagnostic in analyzer.GetProjectSettingRudeEdits(oldProject, newProject))
750private static bool HasReferenceRudeEdits(ImmutableDictionary<string, OneOrMany<AssemblyIdentity>> oldReferencedAssemblies, Compilation newCompilation, ArrayBuilder<Diagnostic> projectDiagnostics)
771projectDiagnostics.Add(Diagnostic.Create(
781projectDiagnostics.Add(Diagnostic.Create(
1092var projectDiagnostics = ArrayBuilder<Diagnostic>.GetInstance();
1103using var _6 = PooledDictionary<ProjectId, ArrayBuilder<Diagnostic>>.GetInstance(out var diagnosticBuilders);
1131Diagnostic? syntaxError = null;
1418foreach (var emitDiagnostic in emitResult.Diagnostics)
1439var unsupportedChangesDiagnostic = await GetUnsupportedChangesDiagnosticAsync(emitResult, cancellationToken).ConfigureAwait(false);
1513projectDiagnostics = ArrayBuilder<Diagnostic>.GetInstance();
1530var diagnostic = Diagnostic.Create(
src\roslyn\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\roslyn\src\Analyzers\Core\Analyzers\SimplifyTypeNames\SimplifyTypeNamesDiagnosticAnalyzerBase.cs (7)
97protected abstract ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context, SyntaxNode root);
98protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanMutableIntervalTree? codeBlockIntervalTree);
100public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, AnalyzerOptions analyzerOptions, CancellationToken cancellationToken)
121internal static Diagnostic CreateDiagnostic(SemanticModel model, TSimplifierOptions options, AnalyzerOptions analyzerOptions, TextSpan issueSpan, string diagnosticId, bool inDeclaration)
153var diagnostic = DiagnosticHelper.Create(descriptor, tree.GetLocation(issueSpan), notificationOption, analyzerOptions, additionalLocations: null, builder.ToImmutable());
230foreach (var diagnostic in diagnostics)
283foreach (var diagnostic in diagnostics)
src\roslyn\src\Analyzers\Core\CodeFixes\ConvertToAsync\AbstractConvertToAsyncCodeFixProvider.cs (3)
18protected abstract Task<string> GetDescriptionAsync(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
19protected abstract Task<(SyntaxTree syntaxTree, SyntaxNode root)?> GetRootInOtherSyntaxTreeAsync(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
52SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
src\roslyn\src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchCodeFixProvider.cs (7)
52var diagnostic = context.Diagnostics.First();
98Document document, Diagnostic diagnostic,
107Document document, ImmutableArray<Diagnostic> diagnostics,
117Document document, SyntaxEditor editor, ImmutableArray<Diagnostic> diagnostics,
121foreach (var diagnostic in diagnostics)
130Document document, SyntaxEditor editor, Diagnostic diagnostic,
213ImmutableArray<Diagnostic> diagnostics,
src\roslyn\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\roslyn\src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForReturn\AbstractUseConditionalExpressionForReturnCodeFixProvider.cs (1)
45Diagnostic diagnostic,
Microsoft.CodeQuality.Analyzers\ApiDesignGuidelines\DefineAccessorsForAttributeArguments.cs (5)
86private static void AnalyzeSymbol(INamedTypeSymbol symbol, INamedTypeSymbol attributeType, Compilation compilation, Action<Diagnostic> addDiagnostic)
140private static void AnalyzeParameters(Compilation compilation, IEnumerable<IParameterSymbol> parameters, IDictionary<string, IPropertySymbol> propertiesMap, INamedTypeSymbol attributeType, Action<Diagnostic> addDiagnostic)
190private static Diagnostic GetDefaultDiagnostic(IParameterSymbol parameter, INamedTypeSymbol attributeType)
196private static Diagnostic GetIncreaseVisibilityDiagnostic(IParameterSymbol parameter, IPropertySymbol property)
202private static Diagnostic GetRemoveSetterDiagnostic(IParameterSymbol parameter, IPropertySymbol property)
Microsoft.CodeQuality.Analyzers\ApiDesignGuidelines\IdentifiersShouldHaveCorrectPrefix.cs (3)
96private static void AnalyzeNamedTypeSymbol<TContext>(INamedTypeSymbol symbol, bool allowSingleLetterTypeParameters, Action<TContext, Diagnostic> addDiagnostic, TContext context)
108private static void AnalyzeMethodSymbol<TContext>(IMethodSymbol symbol, bool allowSingleLetterTypeParameters, Action<TContext, Diagnostic> addDiagnostic, TContext context)
111private static void AnalyzeTypeParameters<TContext>(ImmutableArray<ITypeParameterSymbol> typeParameters, bool allowSingleLetterTypeParameters, Action<TContext, Diagnostic> addDiagnostic, TContext context)
Microsoft.CodeQuality.Analyzers\Maintainability\CodeMetricsAnalyzer.cs (11)
132out List<Diagnostic>? invalidFileDiagnostics) &&
136foreach (var diagnostic in invalidFileDiagnostics)
166var diagnostic = symbol.CreateDiagnostic(CA1501Rule, arg1, arg2, arg3, arg4);
179var diagnostic = symbol.CreateDiagnostic(CA1502Rule, arg1, arg2, arg3);
191var diagnostic = symbol.CreateDiagnostic(CA1505Rule, arg1, arg2, arg3);
204var diagnostic = symbol.CreateDiagnostic(CA1506Rule, arg1, arg2, arg3, arg4);
288out List<Diagnostic>? invalidFileDiagnostics)
321out List<Diagnostic>? invalidFileDiagnostics)
434invalidFileDiagnostics ??= new List<Diagnostic>();
435var diagnostic = Diagnostic.Create(InvalidEntryInCodeMetricsConfigFileRule, location, arg1, arg2);
Microsoft.NetCore.Analyzers\InteropServices\UseValidPlatformString.cs (3)
168private static void AnalyzeSymbol<TContext>(Action<TContext, Diagnostic> reportDiagnostic, TContext context, ISymbol symbol, INamedTypeSymbol supportedAttribute,
177private static void AnalyzeAttribute<TContext>(Action<TContext, Diagnostic> reportDiagnostic, TContext context, AttributeData attributeData, PooledDictionary<string, int> knownPlatforms, CancellationToken token)
194static void AnalyzeStringParameter(Action<TContext, Diagnostic> reportDiagnostic, TContext context, SyntaxNode syntax, PooledDictionary<string, int> knownPlatforms, string value)
Microsoft.NetCore.Analyzers\Performance\ConstantExpectedAnalyzer.cs (33)
169foreach (var diagnostic in diagnostics)
191if (!argConstantParameter.ValidateParameterIsWithinRange(currConstantParameter, argument, out var parameterCheckDiagnostic))
200!argConstantParameter.ValidateValue(argument, constantValue, out var valueDiagnostic))
209protected void OnParameterWithConstantExpectedAttribute(IParameterSymbol parameter, ConstantExpectedContext constantExpectedContext, Action<Diagnostic> reportAction)
211if (!constantExpectedContext.ValidateConstantExpectedParameter(parameter, Helper, out ImmutableArray<Diagnostic> diagnostics))
213foreach (var diagnostic in diagnostics)
235public bool ValidatesAttributeImplementedFromParent(ImmutableArray<IParameterSymbol> parameters, ImmutableArray<IParameterSymbol> baseParameters, out ImmutableArray<Diagnostic> diagnostics)
237var arraybuilder = ImmutableArray.CreateBuilder<Diagnostic>();
250var diagnostic = parameter.DeclaringSyntaxReferences[0].GetSyntax().CreateDiagnostic(CA1857.AttributeExpectedRule);
339public bool ValidateConstantExpectedParameter(IParameterSymbol parameterSymbol, DiagnosticHelper helper, out ImmutableArray<Diagnostic> diagnostics)
346diagnostics = ImmutableArray<Diagnostic>.Empty;
386static bool ValidateMinMaxIsNull(IParameterSymbol parameterSymbol, AttributeData attributeData, DiagnosticHelper helper, out ImmutableArray<Diagnostic> diagnostics)
411diagnostics = ImmutableArray<Diagnostic>.Empty;
474public abstract bool ValidateValue(IArgumentOperation argument, Optional<object?> constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics);
476public static bool ValidateConstant(IArgumentOperation argument, Optional<object?> constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics)
488public abstract bool ValidateParameterIsWithinRange(ConstantExpectedParameter subsetCandidate, IArgumentOperation argument, [NotNullWhen(false)] out Diagnostic? validationDiagnostics);
489protected Diagnostic CreateConstantInvalidConstantRuleDiagnostic(IArgumentOperation argument) => argument.CreateDiagnostic(CA1857.ConstantInvalidConstantRule, Parameter.Type.ToDisplayString());
490protected static Diagnostic CreateConstantOutOfBoundsRuleDiagnostic(IArgumentOperation argument, string minText, string maxText) => argument.CreateDiagnostic(CA1857.ConstantOutOfBoundsRule, minText, maxText);
497public override bool ValidateParameterIsWithinRange(ConstantExpectedParameter subsetCandidate, IArgumentOperation argument, [NotNullWhen(false)] out Diagnostic? validationDiagnostics)
509public override bool ValidateValue(IArgumentOperation argument, Optional<object?> constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics)
589public static ImmutableArray<Diagnostic> ParameterIsInvalid(string expectedTypeName, SyntaxNode attributeSyntax) => ImmutableArray.Create(Diagnostic.Create(CA1856.UnsupportedTypeRule, attributeSyntax.GetLocation(), expectedTypeName));
591public Diagnostic MinIsIncompatible(string expectedTypeName, SyntaxNode attributeSyntax) => Diagnostic.Create(CA1856.IncompatibleConstantTypeRule, GetMinLocation(attributeSyntax)!, ConstantExpectedMin, expectedTypeName);
593public Diagnostic MaxIsIncompatible(string expectedTypeName, SyntaxNode attributeSyntax) => Diagnostic.Create(CA1856.IncompatibleConstantTypeRule, GetMaxLocation(attributeSyntax)!, ConstantExpectedMax, expectedTypeName);
595public Diagnostic MinIsOutOfRange(SyntaxNode attributeSyntax, string typeMinValue, string typeMaxValue) => Diagnostic.Create(CA1856.InvalidBoundsRule, GetMinLocation(attributeSyntax)!, ConstantExpectedMin, typeMinValue, typeMaxValue);
597public Diagnostic MaxIsOutOfRange(SyntaxNode attributeSyntax, string typeMinValue, string typeMaxValue) => Diagnostic.Create(CA1856.InvalidBoundsRule, GetMaxLocation(attributeSyntax)!, ConstantExpectedMax, typeMinValue, typeMaxValue);
599public static Diagnostic MinMaxIsInverted(SyntaxNode attributeSyntax) => Diagnostic.Create(CA1856.InvertedRangeRule, attributeSyntax.GetLocation());
601public ImmutableArray<Diagnostic> GetError(ErrorKind errorFlags, IParameterSymbol parameterSymbol, SyntaxNode attributeSyntax, string typeMinValue, string typeMaxValue)
Microsoft.NetCore.Analyzers\Performance\ConstantExpectedAnalyzer.UnmanagedHelper.cs (5)
59public static bool Validate(IParameterSymbol parameterSymbol, AttributeData attributeData, T typeMin, T typeMax, DiagnosticHelper diagnosticHelper, out ImmutableArray<Diagnostic> diagnostics)
109public bool Validate(IParameterSymbol parameterSymbol, AttributeData attributeData, T typeMin, T typeMax, DiagnosticHelper diagnosticHelper, out ImmutableArray<Diagnostic> diagnostics)
118diagnostics = ImmutableArray<Diagnostic>.Empty;
184public override bool ValidateParameterIsWithinRange(ConstantExpectedParameter subsetCandidate, IArgumentOperation argument, [NotNullWhen(false)] out Diagnostic? validationDiagnostics)
204public override bool ValidateValue(IArgumentOperation argument, Optional<object?> constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics)
Microsoft.NetCore.Analyzers\Performance\PreferHashDataOverComputeHash.Fixer.cs (20)
29var diagnostic = context.Diagnostics[0];
82private readonly List<KeyValuePair<Project, ImmutableArray<Diagnostic>>> _diagnosticsToFix;
86public PreferHashDataOverComputeHashFixAllCodeAction(string title, Solution solution, List<KeyValuePair<Project, ImmutableArray<Diagnostic>>> diagnosticsToFix, PreferHashDataOverComputeHashFixHelper helper)
98foreach (KeyValuePair<Project, ImmutableArray<Diagnostic>> pair in _diagnosticsToFix)
101ImmutableArray<Diagnostic> diagnostics = pair.Value;
103IEnumerable<IGrouping<SyntaxTree, Diagnostic>> groupedDiagnostics =
108foreach (IGrouping<SyntaxTree, Diagnostic> grouping in groupedDiagnostics)
138private HashInstanceTarget[]? CollectTargets(SyntaxNode root, IGrouping<SyntaxTree, Diagnostic> grouping, CancellationToken cancellationToken)
155foreach (var d in grouping)
232var diagnosticsToFix = new List<KeyValuePair<Project, ImmutableArray<Diagnostic>>>();
238ImmutableArray<Diagnostic> diagnostics = await fixAllContext.GetDocumentDiagnosticsAsync(fixAllContext.Document!).ConfigureAwait(false);
239diagnosticsToFix.Add(new KeyValuePair<Project, ImmutableArray<Diagnostic>>(fixAllContext.Project, diagnostics));
244ImmutableArray<Diagnostic> diagnostics = await fixAllContext.GetAllDiagnosticsAsync(fixAllContext.Project).ConfigureAwait(false);
245diagnosticsToFix.Add(new KeyValuePair<Project, ImmutableArray<Diagnostic>>(fixAllContext.Project, diagnostics));
252ImmutableArray<Diagnostic> diagnostics = await fixAllContext.GetAllDiagnosticsAsync(project).ConfigureAwait(false);
253diagnosticsToFix.Add(new KeyValuePair<Project, ImmutableArray<Diagnostic>>(project, diagnostics));
269public bool TryComputeHashNode(SyntaxNode root, Diagnostic diagnostic, [NotNullWhen(true)] out ComputeHashSyntaxHolder? computeHashHolder)
291public bool TryGetHashCreationNodes(SyntaxNode root, Diagnostic diagnostic, [NotNullWhen(true)] out SyntaxNode? createNode, out SyntaxNode[]? disposeNodes)
303public bool TryGetHashCreationNode(SyntaxNode root, Diagnostic diagnostic, [NotNullWhen(true)] out SyntaxNode? createNode, out int hashCreationIndex)
317public SyntaxNode[]? GetDisposeNodes(SyntaxNode root, Diagnostic diagnostic, int hashCreationIndex)
Microsoft.NetCore.Analyzers\Security\DataSetDataTableInIFormatterSerializableObjectGraphAnalyzer.cs (1)
127Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DataSetDataTableInSerializableObjectGraphAnalyzer.cs (1)
296Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DataSetDataTableInSerializableTypeAnalyzer.cs (1)
189Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DataSetDataTableInWebSerializableObjectGraphAnalyzer.cs (1)
119Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DoNotUseCreateEncryptorWithNonDefaultIV.cs (1)
203Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DoNotUseInsecureCryptographicAlgorithms.cs (1)
151Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs (1)
262Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DoNotUseInsecureDeserializerJsonNetWithoutBinder.cs (1)
241Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DoNotUseInsecureDeserializerWithoutBinderBase.cs (1)
226Diagnostic.Create(
Microsoft.NetCore.Analyzers\Security\DoNotUseWeakKDFInsufficientIterationCount.cs (1)
222Diagnostic.Create(