6 types derived from Diagnostic
Microsoft.CodeAnalysis (5)
CommandLine\CommonCompiler.SuppressionDiagnostic.cs (1)
18private sealed class SuppressionDiagnostic : Diagnostic
Diagnostic\Diagnostic.DiagnosticWithProgrammaticSuppression.cs (1)
16private sealed class DiagnosticWithProgrammaticSuppression : Diagnostic
Diagnostic\Diagnostic_SimpleDiagnostic.cs (1)
19internal sealed class SimpleDiagnostic : Diagnostic
Diagnostic\DiagnosticWithInfo.cs (1)
18internal class DiagnosticWithInfo : Diagnostic
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (1)
76private sealed class CompilerDiagnostic : Diagnostic
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (1)
EvaluationContextBase.cs (1)
102protected sealed class SimpleMessageDiagnostic : Diagnostic
3320 references to Diagnostic
AnalyzerRunner (3)
DiagnosticAnalyzerRunner.cs (2)
164foreach (var item in group) 201private static void WriteDiagnosticResults(ImmutableArray<Tuple<ProjectId, Diagnostic>> diagnostics, string fileName)
Program.cs (1)
151foreach (var diagnostic in compilation.GetDiagnostics(cancellationToken))
BuildActionTelemetryTable (1)
TelemetryExtensions.cs (1)
53public static string GetTelemetryDiagnosticID(this Diagnostic diagnostic)
BuildValidator (6)
CompilationDiff.cs (6)
48private readonly ImmutableArray<Diagnostic> _diagnostics; 63public ImmutableArray<Diagnostic> Diagnostics 85ImmutableArray<Diagnostic> diagnostics = default, 145foreach (var diag in emitResult.Diagnostics) 225void writeDiagnostics(ImmutableArray<Diagnostic> diagnostics) 228foreach (var diagnostic in diagnostics)
Microsoft.CodeAnalysis (695)
Binding\BindingDiagnosticBag.cs (6)
33internal void AddRange<T>(ImmutableArray<T> diagnostics) where T : Diagnostic 38internal void AddRange(IEnumerable<Diagnostic> diagnostics) 55internal void Add(Diagnostic diag) 303private readonly ImmutableArray<Diagnostic> _diagnostics; 306public ImmutableArray<Diagnostic> Diagnostics => _diagnostics.NullToEmpty(); 311public ImmutableBindingDiagnostic(ImmutableArray<Diagnostic> diagnostics, ImmutableArray<TAssemblySymbol> dependencies)
Collections\ImmutableArrayExtensions.cs (1)
649internal static bool HasAnyErrors<T>(this ImmutableArray<T> diagnostics) where T : Diagnostic
CommandLine\AnalyzerConfigOptionsResult.cs (2)
30public ImmutableArray<Diagnostic> Diagnostics { get; } 35ImmutableArray<Diagnostic> diagnostics)
CommandLine\AnalyzerConfigSet.cs (8)
125public static AnalyzerConfigSet Create<TList>(TList analyzerConfigs, out ImmutableArray<Diagnostic> diagnostics) where TList : IReadOnlyCollection<AnalyzerConfig> 256var diagnosticBuilder = ArrayBuilder<Diagnostic>.GetInstance(); 384var diagnosticBuilder = ArrayBuilder<Diagnostic>.GetInstance(); 406private static void ParseSectionOptions(Section section, TreeOptions.Builder treeBuilder, AnalyzerOptions.Builder analyzerBuilder, ArrayBuilder<Diagnostic> diagnosticBuilder, string analyzerConfigPath, ConcurrentDictionary<ReadOnlyMemory<char>, string> diagIdCache) 443diagnosticBuilder.Add(Diagnostic.Create( 464internal static GlobalAnalyzerConfig MergeGlobalConfigs(ArrayBuilder<AnalyzerConfig> analyzerConfigs, out ImmutableArray<Diagnostic> diagnostics) 514diagnostics.Add(Diagnostic.Create( 537diagnostics.Add(Diagnostic.Create(
CommandLine\CommandLineArguments.cs (2)
151public ImmutableArray<Diagnostic> Errors { get; internal set; } 432var diagnostic = PortableExecutableReference.ExceptionToDiagnostic(e, messageProviderOpt!, Location.None, cmdReference.Reference, cmdReference.Properties.Kind);
CommandLine\CommandLineParser.cs (27)
206IList<Diagnostic> diagnostics, 338protected ImmutableArray<KeyValuePair<string, string>> ParsePathMap(string pathMap, IList<Diagnostic> errors) 357errors.Add(Diagnostic.Create(_messageProvider, _messageProvider.ERR_InvalidPathMap)); 366errors.Add(Diagnostic.Create(_messageProvider, _messageProvider.ERR_InvalidPathMap)); 424IList<Diagnostic> errors, 434errors.Add(Diagnostic.Create(_messageProvider, _messageProvider.FTL_InvalidInputFileName, invalidPath)); 442IList<Diagnostic> errors, 452errors.Add(Diagnostic.Create(_messageProvider, _messageProvider.FTL_InvalidInputFileName, invalidPath)); 466IList<Diagnostic> errors, 477errors.Add(Diagnostic.Create(_messageProvider, _messageProvider.FTL_InvalidInputFileName, invalidPath)); 491IList<Diagnostic> diagnostics, 559diagnostics.Add(Diagnostic.Create(_messageProvider, _messageProvider.FTL_InvalidInputFileName, path)); 569diagnostics.Add(Diagnostic.Create(_messageProvider, _messageProvider.FTL_InvalidInputFileName, path)); 641diagnostics.Add(Diagnostic.Create(_messageProvider, _messageProvider.ERR_OpenResponseFile, fullPath)); 663diagnostics.Add(Diagnostic.Create(_messageProvider, _messageProvider.WRN_NoConfigNotOnCommandLine)); 1087internal IEnumerable<string> ResolveRelativePaths(IEnumerable<string> paths, string baseDirectory, IList<Diagnostic> errors) 1094errors.Add(Diagnostic.Create(_messageProvider, _messageProvider.FTL_InvalidInputFileName, path)); 1121internal void ParseFileArgument(ReadOnlyMemory<char> arg, string? baseDirectory, ArrayBuilder<string> filePathBuilder, IList<Diagnostic> errors) 1144errors.Add(Diagnostic.Create(MessageProvider, (int)MessageProvider.FTL_InvalidInputFileName, path)); 1153private protected void ParseSeparatedFileArgument(ReadOnlyMemory<char> value, string? baseDirectory, ArrayBuilder<string> filePathBuilder, IList<Diagnostic> errors) 1169private protected IEnumerable<string> ParseSeparatedFileArgument(string value, string? baseDirectory, IList<Diagnostic> errors) 1180internal IEnumerable<CommandLineSourceFile> ParseRecurseArgument(string arg, string? baseDirectory, IList<Diagnostic> errors) 1228IList<Diagnostic> errors) 1280errors.Add(Diagnostic.Create(MessageProvider, (int)MessageProvider.FTL_InvalidInputFileName, path)); 1300errors.Add(Diagnostic.Create(MessageProvider, (int)MessageProvider.ERR_FileNotFound, path)); 1313internal abstract void GenerateErrorForNoFilesFoundInRecurse(string path, IList<Diagnostic> errors); 1315internal ReportDiagnostic GetDiagnosticOptionsFromRulesetFile(string? fullPath, out Dictionary<string, ReportDiagnostic> diagnosticOptions, IList<Diagnostic> diagnostics)
CommandLine\CommonCompiler.cs (11)
91private readonly HashSet<Diagnostic> _reportedDiagnostics = new HashSet<Diagnostic>(); 322diagnostics.Add(Diagnostic.Create( 376diagnostics.Add(Diagnostic.Create(ToFileReadDiagnostics(MessageProvider, e, filePath))); 523internal bool ReportDiagnostics(IEnumerable<Diagnostic> diagnostics, TextWriter consoleOutput, ErrorLogger? errorLoggerOpt, Compilation? compilation) 526foreach (var diag in diagnostics) 534void reportDiagnostic(Diagnostic diag, SuppressionInfo? suppressionInfo) 599=> ReportDiagnostics(diagnostics.Select(info => Diagnostic.Create(info)), consoleOutput, errorLoggerOpt, compilation); 609foreach (var diag in diagnostics.AsEnumerable()) 625foreach (Diagnostic diagnostic in diagnostics.AsEnumerable()) 636protected virtual void PrintError(Diagnostic diagnostic, TextWriter consoleOutput)
CommandLine\CommonCompiler.SuppressionDiagnostic.cs (6)
28private readonly Diagnostic _originalDiagnostic; 33Diagnostic originalDiagnostic, 70public override bool Equals(Diagnostic? obj) 94internal override Diagnostic WithLocation(Location location) 99internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 104internal override Diagnostic WithIsSuppressed(bool isSuppressed)
CommandLine\ErrorLogger.cs (1)
15public abstract void LogDiagnostic(Diagnostic diagnostic, SuppressionInfo? suppressionInfo);
CommandLine\SarifErrorLogger.cs (1)
83protected void WriteResultProperties(Diagnostic diagnostic)
CommandLine\SarifV1ErrorLogger.cs (1)
55public override void LogDiagnostic(Diagnostic diagnostic, SuppressionInfo? suppressionInfo)
CommandLine\SarifV2ErrorLogger.cs (1)
53public override void LogDiagnostic(Diagnostic diagnostic, SuppressionInfo? suppressionInfo)
Compilation\Compilation.cs (11)
1739public abstract ImmutableArray<Diagnostic> GetParseDiagnostics(CancellationToken cancellationToken = default(CancellationToken)); 1744public abstract ImmutableArray<Diagnostic> GetDeclarationDiagnostics(CancellationToken cancellationToken = default(CancellationToken)); 1749public abstract ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(CancellationToken cancellationToken = default(CancellationToken)); 1756public abstract ImmutableArray<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = default(CancellationToken)); 1829internal bool FilterAndAppendDiagnostics(DiagnosticBag accumulator, IEnumerable<Diagnostic> incoming, HashSet<int>? exclude, CancellationToken cancellationToken) 1834foreach (Diagnostic d in incoming) 1841var filtered = Options.FilterDiagnostic(d, cancellationToken); 3687/// Given a <see cref="Diagnostic"/> reporting unreferenced <see cref="AssemblyIdentity"/>s, returns 3690public ImmutableArray<AssemblyIdentity> GetUnreferencedAssemblyIdentities(Diagnostic diagnostic) 3718/// Returns the required language version found in a <see cref="Diagnostic"/>, if any is found. 3721public static string? GetRequiredLanguageVersion(Diagnostic diagnostic)
Compilation\CompilationOptions.cs (9)
190internal abstract Diagnostic? FilterDiagnostic(Diagnostic diagnostic, CancellationToken cancellationToken); 203/// Whether diagnostics suppressed in source, i.e. <see cref="Diagnostic.IsSuppressed"/> is true, should be reported. 262private readonly Lazy<ImmutableArray<Diagnostic>> _lazyErrors; 326_lazyErrors = new Lazy<ImmutableArray<Diagnostic>>(() => 328var builder = ArrayBuilder<Diagnostic>.GetInstance(); 562internal abstract void ValidateOptions(ArrayBuilder<Diagnostic> builder); 564internal void ValidateOptions(ArrayBuilder<Diagnostic> builder, CommonMessageProvider messageProvider) 606public ImmutableArray<Diagnostic> Errors
Compilation\EmitResult.cs (2)
27public ImmutableArray<Diagnostic> Diagnostics { get; } 29internal EmitResult(bool success, ImmutableArray<Diagnostic> diagnostics)
Compilation\LoadDirective.cs (2)
16public readonly ImmutableArray<Diagnostic> Diagnostics; 18public LoadDirective(string? resolvedPath, ImmutableArray<Diagnostic> diagnostics)
Compilation\ParseOptions.cs (6)
21private readonly Lazy<ImmutableArray<Diagnostic>> _lazyErrors; 45_lazyErrors = new Lazy<ImmutableArray<Diagnostic>>(() => 47var builder = ArrayBuilder<Diagnostic>.GetInstance(); 61public ImmutableArray<Diagnostic> Errors 77internal abstract void ValidateOptions(ArrayBuilder<Diagnostic> builder); 79internal void ValidateOptions(ArrayBuilder<Diagnostic> builder, CommonMessageProvider messageProvider)
Compilation\SemanticModel.cs (4)
328public abstract ImmutableArray<Diagnostic> GetSyntaxDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)); 342public abstract ImmutableArray<Diagnostic> GetDeclarationDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)); 356public abstract ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)); 373public abstract ImmutableArray<Diagnostic> GetDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken));
Diagnostic\CommonDiagnosticComparer.cs (4)
10internal sealed class CommonDiagnosticComparer : IEqualityComparer<Diagnostic> 18public bool Equals(Diagnostic? x, Diagnostic? y) 33public int GetHashCode(Diagnostic obj)
Diagnostic\CommonMessageProvider.cs (4)
57/// Default category is <see cref="Diagnostic.CompilerDiagnosticCategory"/>. 80public Diagnostic CreateDiagnostic(int code, Location location) 88public abstract Diagnostic CreateDiagnostic(DiagnosticInfo info); 93public abstract Diagnostic CreateDiagnostic(int code, Location location, params object[] args);
Diagnostic\Diagnostic.cs (33)
20public abstract partial class Diagnostic : IEquatable<Diagnostic?>, IFormattable 40/// Creates a <see cref="Diagnostic"/> instance. 45/// <returns>The <see cref="Diagnostic"/> instance.</returns> 46public static Diagnostic Create( 55/// Creates a <see cref="Diagnostic"/> instance. 65/// <returns>The <see cref="Diagnostic"/> instance.</returns> 66public static Diagnostic Create( 76/// Creates a <see cref="Diagnostic"/> instance. 86/// <returns>The <see cref="Diagnostic"/> instance.</returns> 87public static Diagnostic Create( 97/// Creates a <see cref="Diagnostic"/> instance. 112/// <returns>The <see cref="Diagnostic"/> instance.</returns> 113public static Diagnostic Create( 124/// Creates a <see cref="Diagnostic"/> instance. 140/// <returns>The <see cref="Diagnostic"/> instance.</returns> 141public static Diagnostic Create( 166/// Creates a <see cref="Diagnostic"/> instance which is localizable. 193/// <returns>The <see cref="Diagnostic"/> instance.</returns> 194public static Diagnostic Create( 215/// Creates a <see cref="Diagnostic"/> instance which is localizable. 243/// <returns>The <see cref="Diagnostic"/> instance.</returns> 244public static Diagnostic Create( 280internal static Diagnostic Create(CommonMessageProvider messageProvider, int errorCode) 285internal static Diagnostic Create(CommonMessageProvider messageProvider, int errorCode, params object[] arguments) 290internal static Diagnostic Create(DiagnosticInfo info) 296/// Gets the diagnostic descriptor, which provides a description about a <see cref="Diagnostic"/>. 422=> obj is Diagnostic diagnostic && Equals(diagnostic); 426public abstract bool Equals(Diagnostic? obj); 451internal abstract Diagnostic WithLocation(Location location); 456internal abstract Diagnostic WithSeverity(DiagnosticSeverity severity); 461internal abstract Diagnostic WithIsSuppressed(bool isSuppressed); 466internal Diagnostic WithProgrammaticSuppression(ProgrammaticSuppressionInfo programmaticSuppressionInfo) 525internal Diagnostic? WithReportDiagnostic(ReportDiagnostic reportAction)
Diagnostic\Diagnostic.DiagnosticWithProgrammaticSuppression.cs (6)
18private readonly Diagnostic _originalUnsuppressedDiagnostic; 22Diagnostic originalUnsuppressedDiagnostic, 86public override bool Equals(Diagnostic? obj) 108internal override Diagnostic WithLocation(Location location) 123internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 133internal override Diagnostic WithIsSuppressed(bool isSuppressed)
Diagnostic\Diagnostic_SimpleDiagnostic.cs (4)
145public override bool Equals(Diagnostic? obj) 179internal override Diagnostic WithLocation(Location location) 194internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 205internal override Diagnostic WithIsSuppressed(bool isSuppressed)
Diagnostic\DiagnosticBag.cs (34)
33private ConcurrentQueue<Diagnostic>? _lazyBag; 50ConcurrentQueue<Diagnostic>? bag = _lazyBag; 72foreach (Diagnostic diagnostic in Bag) 100foreach (Diagnostic diagnostic in Bag) 114public void Add(Diagnostic diag) 116ConcurrentQueue<Diagnostic> bag = this.Bag; 123public void AddRange<T>(ImmutableArray<T> diagnostics) where T : Diagnostic 127ConcurrentQueue<Diagnostic> bag = this.Bag; 138public void AddRange(IEnumerable<Diagnostic> diagnostics) 140foreach (Diagnostic diagnostic in diagnostics) 170public ImmutableArray<TDiagnostic> ToReadOnlyAndFree<TDiagnostic>() where TDiagnostic : Diagnostic 172ConcurrentQueue<Diagnostic>? oldBag = _lazyBag; 178public ImmutableArray<Diagnostic> ToReadOnlyAndFree() 180return ToReadOnlyAndFree<Diagnostic>(); 183public ImmutableArray<TDiagnostic> ToReadOnly<TDiagnostic>() where TDiagnostic : Diagnostic 185ConcurrentQueue<Diagnostic>? oldBag = _lazyBag; 189public ImmutableArray<Diagnostic> ToReadOnly() 191return ToReadOnly<Diagnostic>(); 194private static ImmutableArray<TDiagnostic> ToReadOnlyCore<TDiagnostic>(ConcurrentQueue<Diagnostic>? oldBag) where TDiagnostic : Diagnostic 219public IEnumerable<Diagnostic> AsEnumerable() 221ConcurrentQueue<Diagnostic> bag = this.Bag; 225foreach (Diagnostic diagnostic in bag) 243private IEnumerable<Diagnostic> AsEnumerableFiltered() 245foreach (Diagnostic diagnostic in this.Bag) 255internal IEnumerable<Diagnostic> AsEnumerableWithoutResolution() 258return _lazyBag ?? SpecializedCollections.EmptyEnumerable<Diagnostic>(); 273foreach (Diagnostic diag in Bag) // NOTE: don't force resolution 287private ConcurrentQueue<Diagnostic> Bag 291ConcurrentQueue<Diagnostic>? bag = _lazyBag; 297ConcurrentQueue<Diagnostic> newBag = new ConcurrentQueue<Diagnostic>(); 308ConcurrentQueue<Diagnostic>? bag = _lazyBag; 353ConcurrentQueue<Diagnostic>? lazyBag = _bag._lazyBag;
Diagnostic\DiagnosticDescriptor.cs (5)
16/// Provides a description about a <see cref="Diagnostic"/> 76/// Create a DiagnosticDescriptor, which provides description about a <see cref="Diagnostic"/>. 105/// Create a DiagnosticDescriptor, which provides description about a <see cref="Diagnostic"/>. 234var effectiveDiagnostic = compilationOptions.FilterDiagnostic(Diagnostic.Create(this, Location.None), CancellationToken.None);
Diagnostic\DiagnosticFormatter.cs (4)
13/// Formats <see cref="Diagnostic"/> messages. 18/// Formats the <see cref="Diagnostic"/> message using the optional <see cref="IFormatProvider"/>. 23public virtual string Format(Diagnostic diagnostic, IFormatProvider? formatter = null) 80internal string GetMessagePrefix(Diagnostic diagnostic)
Diagnostic\DiagnosticInfo.cs (2)
286return Diagnostic.GetDefaultWarningLevel(_effectiveSeverity); 311/// Default category is <see cref="Diagnostic.CompilerDiagnosticCategory"/>.
Diagnostic\DiagnosticWithInfo.cs (4)
155public override bool Equals(Diagnostic? obj) 195internal override Diagnostic WithLocation(Location location) 210internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 220internal override Diagnostic WithIsSuppressed(bool isSuppressed)
Diagnostic\SuppressionDescriptor.cs (6)
12/// Provides a description about a programmatic suppression of a <see cref="Diagnostic"/> by a <see cref="DiagnosticSuppressor"/>. 22/// Identifier of the suppressed diagnostic, i.e. <see cref="Diagnostic.Id"/>. 32/// Create a SuppressionDescriptor, which provides a justification about a programmatic suppression of a <see cref="Diagnostic"/>. 37/// <param name="suppressedDiagnosticId">Identifier of the suppressed diagnostic, i.e. <see cref="Diagnostic.Id"/>. For example, compiler warning Id "CS0649".</param> 48/// Create a SuppressionDescriptor, which provides a localizable justification about a programmatic suppression of a <see cref="Diagnostic"/>. 51/// <param name="suppressedDiagnosticId">Identifier of the suppressed diagnostic, i.e. <see cref="Diagnostic.Id"/>. For example, compiler warning Id "CS0649".</param>
Diagnostic\SuppressionInfo.cs (1)
13/// <see cref="Diagnostic.Id"/> of the suppressed diagnostic.
DiagnosticAnalyzer\AnalysisResult.cs (18)
23ImmutableDictionary<SyntaxTree, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localSyntaxDiagnostics, 24ImmutableDictionary<SyntaxTree, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localSemanticDiagnostics, 25ImmutableDictionary<AdditionalText, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localAdditionalFileDiagnostics, 26ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> nonLocalDiagnostics, 45public ImmutableDictionary<SyntaxTree, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> SyntaxDiagnostics { get; } 50public ImmutableDictionary<SyntaxTree, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> SemanticDiagnostics { get; } 55public ImmutableDictionary<AdditionalText, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> AdditionalFileDiagnostics { get; } 60public ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> CompilationDiagnostics { get; } 70public ImmutableArray<Diagnostic> GetAllDiagnostics(DiagnosticAnalyzer analyzer) 83public ImmutableArray<Diagnostic> GetAllDiagnostics() 88private ImmutableArray<Diagnostic> GetDiagnostics(IEnumerable<DiagnosticAnalyzer> analyzers) 95private ImmutableArray<Diagnostic> GetDiagnostics(ImmutableHashSet<DiagnosticAnalyzer> excludedAnalyzers) 99var builder = ImmutableArray.CreateBuilder<Diagnostic>(); 108return ImmutableArray<Diagnostic>.Empty; 112ImmutableDictionary<T, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localDiagnostics, 114ImmutableArray<Diagnostic>.Builder builder) 132ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> nonLocalDiagnostics, 134ImmutableArray<Diagnostic>.Builder builder)
DiagnosticAnalyzer\AnalysisResultBuilder.cs (50)
36private Dictionary<SyntaxTree, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? _localSemanticDiagnosticsOpt = null; 37private Dictionary<SyntaxTree, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? _localSyntaxDiagnosticsOpt = null; 38private Dictionary<AdditionalText, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? _localAdditionalFileDiagnosticsOpt = null; 39private Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>? _nonLocalDiagnosticsOpt = null; 302static SyntaxTree? getSourceTree(Diagnostic diagnostic) 305AdditionalText? getAdditionalTextKey(Diagnostic diagnostic) 328ImmutableArray<Diagnostic> diagnostics, 330Func<Diagnostic, TKey?> getKeyFunc, 331ref Dictionary<TKey, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? lazyLocalDiagnostics) 339lazyLocalDiagnostics = lazyLocalDiagnostics ?? new Dictionary<TKey, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>(); 349Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>? allDiagnostics; 352allDiagnostics = new Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>(); 356ImmutableArray<Diagnostic>.Builder? analyzerDiagnostics; 359analyzerDiagnostics = ImmutableArray.CreateBuilder<Diagnostic>(); 363IEnumerable<Diagnostic> diagsToAdd = diagsByKey; 378private void UpdateNonLocalDiagnostics_NoLock(DiagnosticAnalyzer analyzer, ImmutableArray<Diagnostic> diagnostics, bool overwrite) 385_nonLocalDiagnosticsOpt = _nonLocalDiagnosticsOpt ?? new Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>(); 387ImmutableArray<Diagnostic>.Builder? currentDiagnostics; 390currentDiagnostics = ImmutableArray.CreateBuilder<Diagnostic>(); 402internal ImmutableArray<Diagnostic> GetDiagnostics(AnalysisScope analysisScope, bool getLocalDiagnostics, bool getNonLocalDiagnostics) 410private ImmutableArray<Diagnostic> GetDiagnostics_NoLock(AnalysisScope analysisScope, bool getLocalDiagnostics, bool getNonLocalDiagnostics) 414var builder = ImmutableArray.CreateBuilder<Diagnostic>(); 443Dictionary<TKey, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? lazyLocalDiagnostics, 445ImmutableArray<Diagnostic>.Builder builder) 458Dictionary<SyntaxTree, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? localDiagnostics, 460ImmutableArray<Diagnostic>.Builder builder) 464Dictionary<AdditionalText, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? localDiagnostics, 466ImmutableArray<Diagnostic>.Builder builder) 470Dictionary<TKey, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? localDiagnostics, 473ImmutableArray<Diagnostic>.Builder builder) 476Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>? diagnosticsForTree; 484Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder> diagnostics, 486ImmutableArray<Diagnostic>.Builder builder) 492ImmutableArray<Diagnostic>.Builder? diagnosticsByAnalyzer; 504ImmutableDictionary<SyntaxTree, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localSyntaxDiagnostics; 505ImmutableDictionary<SyntaxTree, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localSemanticDiagnostics; 506ImmutableDictionary<AdditionalText, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> localAdditionalFileDiagnostics; 507ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> nonLocalDiagnostics; 510Func<Diagnostic, bool> shouldInclude = analysisScope.ShouldInclude; 524private static ImmutableDictionary<TKey, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>> GetImmutable<TKey>( 526Func<Diagnostic, bool> shouldInclude, 527Dictionary<TKey, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>? localDiagnosticsOpt) 532return ImmutableDictionary<TKey, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>>.Empty; 535var builder = ImmutableDictionary.CreateBuilder<TKey, ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>>(); 536var perTreeBuilder = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>(); 560private static ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> GetImmutable( 562Func<Diagnostic, bool> shouldInclude, 563Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>? nonLocalDiagnosticsOpt) 567return ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>.Empty; 570var builder = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>();
DiagnosticAnalyzer\AnalysisScope.cs (1)
218public bool ShouldInclude(Diagnostic diagnostic)
DiagnosticAnalyzer\AnalyzerDriver.cs (55)
48private readonly ConcurrentSet<Diagnostic>? _diagnosticsProcessedForProgrammaticSuppressions; 380_diagnosticsProcessedForProgrammaticSuppressions = _hasDiagnosticSuppressors ? new ConcurrentSet<Diagnostic>(ReferenceEqualityComparer.Instance) : null; 467Action<Diagnostic, CancellationToken>? addNotCategorizedDiagnostic = null; 468Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? addCategorizedLocalDiagnostic = null; 469Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? addCategorizedNonLocalDiagnostic = null; 481Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> newOnAnalyzerException = (ex, analyzer, diagnostic, cancellationToken) => 483var filteredDiagnostic = GetFilteredDiagnostic(diagnostic, compilation, analysisOptions.Options, _severityFilter, suppressedDiagnosticIds, cancellationToken); 607private bool ShouldSuppressGeneratedCodeDiagnostic(Diagnostic diagnostic, DiagnosticAnalyzer analyzer, Compilation compilation, CancellationToken cancellationToken) 722var diagnostic = AnalyzerExecutor.CreateDriverExceptionDiagnostic(innerException); 813Action<Diagnostic> addExceptionDiagnostic, 820Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = 833Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException, 860public async Task<ImmutableArray<Diagnostic>> GetDiagnosticsAsync(Compilation compilation) 875while (DiagnosticQueue.TryDequeue(out var diagnostic)) 953public ImmutableArray<Diagnostic> ApplyProgrammaticSuppressions(ImmutableArray<Diagnostic> reportedDiagnostics, Compilation compilation) 964private ImmutableArray<Diagnostic> ApplyProgrammaticSuppressionsCore(ImmutableArray<Diagnostic> reportedDiagnostics, Compilation compilation) 993var builder = ArrayBuilder<Diagnostic>.GetInstance(reportedDiagnostics.Length); 994ImmutableDictionary<Diagnostic, ProgrammaticSuppressionInfo> programmaticSuppressionsByDiagnostic = createProgrammaticSuppressionsByDiagnosticMap(_programmaticSuppressions); 995foreach (var diagnostic in reportedDiagnostics) 1001var suppressedDiagnostic = diagnostic.WithProgrammaticSuppression(programmaticSuppressionInfo); 1019void executeSuppressionActions(IEnumerable<Diagnostic> reportedDiagnostics, bool concurrent) 1055ImmutableArray<Diagnostic> getSuppressableDiagnostics(DiagnosticSuppressor suppressor) 1060return ImmutableArray<Diagnostic>.Empty; 1063var builder = ArrayBuilder<Diagnostic>.GetInstance(); 1064foreach (var diagnostic in reportedDiagnostics) 1076static ImmutableDictionary<Diagnostic, ProgrammaticSuppressionInfo> createProgrammaticSuppressionsByDiagnosticMap(ConcurrentSet<Suppression> programmaticSuppressions) 1078var programmaticSuppressionsBuilder = PooledDictionary<Diagnostic, ImmutableHashSet<(string, LocalizableString)>.Builder>.GetInstance(); 1090var mapBuilder = ImmutableDictionary.CreateBuilder<Diagnostic, ProgrammaticSuppressionInfo>(); 1100public ImmutableArray<Diagnostic> DequeueLocalDiagnosticsAndApplySuppressions(DiagnosticAnalyzer analyzer, bool syntax, Compilation compilation) 1106public ImmutableArray<Diagnostic> DequeueNonLocalDiagnosticsAndApplySuppressions(DiagnosticAnalyzer analyzer, Compilation compilation) 1112private ImmutableArray<Diagnostic> FilterDiagnosticsSuppressedInSourceOrByAnalyzers(ImmutableArray<Diagnostic> diagnostics, Compilation compilation) 1118private static ImmutableArray<Diagnostic> FilterDiagnosticsSuppressedInSource( 1119ImmutableArray<Diagnostic> diagnostics, 1129var builder = ImmutableArray.CreateBuilder<Diagnostic>(); 1137var diagnostic = suppressMessageState.ApplySourceSuppressions(diagnostics[i]); 1150internal ImmutableArray<Diagnostic> ApplyProgrammaticSuppressionsAndFilterDiagnostics(ImmutableArray<Diagnostic> reportedDiagnostics, Compilation compilation) 1864internal static Action<Diagnostic, CancellationToken> GetDiagnosticSink(Action<Diagnostic> addDiagnosticCore, Compilation compilation, AnalyzerOptions? analyzerOptions, SeverityFilter severityFilter, ConcurrentSet<string>? suppressedDiagnosticIds) 1868var filteredDiagnostic = GetFilteredDiagnostic(diagnostic, compilation, analyzerOptions, severityFilter, suppressedDiagnosticIds, cancellationToken); 1876internal static Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken> GetDiagnosticSink(Action<Diagnostic, DiagnosticAnalyzer, bool> addLocalDiagnosticCore, Compilation compilation, AnalyzerOptions? analyzerOptions, SeverityFilter severityFilter, ConcurrentSet<string>? suppressedDiagnosticIds) 1880var filteredDiagnostic = GetFilteredDiagnostic(diagnostic, compilation, analyzerOptions, severityFilter, suppressedDiagnosticIds, cancellationToken); 1888internal static Action<Diagnostic, DiagnosticAnalyzer, CancellationToken> GetDiagnosticSink(Action<Diagnostic, DiagnosticAnalyzer> addDiagnosticCore, Compilation compilation, AnalyzerOptions? analyzerOptions, SeverityFilter severityFilter, ConcurrentSet<string>? suppressedDiagnosticIds) 1892var filteredDiagnostic = GetFilteredDiagnostic(diagnostic, compilation, analyzerOptions, severityFilter, suppressedDiagnosticIds, cancellationToken); 1900private static Diagnostic? GetFilteredDiagnostic(Diagnostic diagnostic, Compilation compilation, AnalyzerOptions? analyzerOptions, SeverityFilter severityFilter, ConcurrentSet<string>? suppressedDiagnosticIds, CancellationToken cancellationToken) 1902var filteredDiagnostic = compilation.Options.FilterDiagnostic(diagnostic, cancellationToken); 1911Diagnostic? applyFurtherFiltering(Diagnostic? diagnostic) 2600var diagnostic = AnalyzerExecutor.CreateDriverExceptionDiagnostic(ex);
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (11)
22public readonly Action<Diagnostic> AddDiagnosticAction; 33Action<Diagnostic, CancellationToken>? addNonCategorizedDiagnostic, 34Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? addCategorizedLocalDiagnostic, 35Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? addCategorizedNonLocalDiagnostic, 36Func<Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> shouldSuppressGeneratedCodeDiagnostic, 73private Action<Diagnostic, CancellationToken>? _addNonCategorizedDiagnostic; 74private Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? _addCategorizedLocalDiagnostic; 75private Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? _addCategorizedNonLocalDiagnostic; 76private Func<Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> _shouldSuppressGeneratedCodeDiagnostic; 87private void AddDiagnostic(Diagnostic diagnostic) 116bool isLocalDiagnostic(Diagnostic diagnostic)
DiagnosticAnalyzer\AnalyzerExecutor.cs (53)
36private readonly Action<Diagnostic, CancellationToken>? _addNonCategorizedDiagnostic; 37private readonly Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? _addCategorizedLocalDiagnostic; 38private readonly Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? _addCategorizedNonLocalDiagnostic; 40private readonly Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> _onAnalyzerException; 47private readonly Func<Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> _shouldSuppressGeneratedCodeDiagnostic; 106Action<Diagnostic, CancellationToken>? addNonCategorizedDiagnostic, 107Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> onAnalyzerException, 112Func<Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> shouldSuppressGeneratedCodeDiagnostic, 118Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? addCategorizedLocalDiagnostic = null, 119Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? addCategorizedNonLocalDiagnostic = null, 145Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken>? onAnalyzerException, 174Action<Diagnostic, CancellationToken>? addNonCategorizedDiagnosticOpt, 175Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> onAnalyzerException, 180Func<Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> shouldSuppressGeneratedCodeDiagnostic, 186Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? addCategorizedLocalDiagnostic, 187Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? addCategorizedNonLocalDiagnostic, 253internal Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> OnAnalyzerException => _onAnalyzerException; 348public void ExecuteSuppressionAction(DiagnosticSuppressor suppressor, ImmutableArray<Diagnostic> reportedDiagnostics) 388using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 432using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 523using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 567using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 611using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 646using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 669Action<Diagnostic> addDiagnostic, 670Func<Diagnostic, bool> isSupportedDiagnostic, 692Action<Diagnostic> addDiagnostic, 693Func<Diagnostic, bool> isSupportedDiagnostic, 857using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 893Action<Diagnostic> addDiagnostic, 894Func<Diagnostic, bool> isSupportedDiagnostic, 982using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 994Action<Diagnostic> addDiagnostic, 995Func<Diagnostic, bool> isSupportedDiagnostic, 1070using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func<Diagnostic, bool> isSupportedDiagnostic); 1081Action<Diagnostic> addDiagnostic, 1082Func<Diagnostic, bool> isSupportedDiagnostic, 1171var diagnostic = CreateAnalyzerExceptionDiagnostic(analyzer, e, info); 1198internal static Diagnostic CreateAnalyzerExceptionDiagnostic(DiagnosticAnalyzer analyzer, Exception e, AnalysisContextInfo? info = null) 1207return Diagnostic.Create(descriptor, Location.None, messageArguments); 1248internal static Diagnostic CreateDriverExceptionDiagnostic(Exception e) 1255return Diagnostic.Create(descriptor, Location.None, messageArguments); 1280internal static bool IsAnalyzerExceptionDiagnostic(Diagnostic diagnostic) 1296internal static bool AreEquivalentAnalyzerExceptionDiagnostics(Diagnostic exceptionDiagnostic, Diagnostic other) 1316private bool IsSupportedDiagnostic(DiagnosticAnalyzer analyzer, Diagnostic diagnostic) 1329private Action<Diagnostic> GetAddDiagnostic(ISymbol contextSymbol, ImmutableArray<SyntaxReference> cachedDeclaringReferences, DiagnosticAnalyzer analyzer, Func<ISymbol, SyntaxReference, Compilation, CancellationToken, SyntaxNode> getTopMostNodeForAnalysis) 1335private static Action<Diagnostic> GetAddDiagnostic( 1340Action<Diagnostic, CancellationToken>? addNonCategorizedDiagnostic, 1341Action<Diagnostic, DiagnosticAnalyzer, bool, CancellationToken>? addCategorizedLocalDiagnostic, 1342Action<Diagnostic, DiagnosticAnalyzer, CancellationToken>? addCategorizedNonLocalDiagnostic, 1344Func<Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> shouldSuppressGeneratedCodeDiagnostic, 1384private Action<Diagnostic> GetAddCompilationDiagnostic(DiagnosticAnalyzer analyzer)
DiagnosticAnalyzer\AnalyzerManager.AnalyzerExecutionContext.cs (2)
306Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> onAnalyzerException = analyzerExecutor.OnAnalyzerException; 311var diagnostic = AnalyzerExecutor.CreateAnalyzerExceptionDiagnostic(analyzer, ex);
DiagnosticAnalyzer\AnalyzerManager.cs (1)
267internal bool IsSupportedDiagnostic(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Func<DiagnosticAnalyzer, bool> isCompilerAnalyzer, AnalyzerExecutor analyzerExecutor)
DiagnosticAnalyzer\CompilationWithAnalyzers.cs (28)
46private readonly ConcurrentSet<Diagnostic> _exceptionDiagnostics = new ConcurrentSet<Diagnostic>(); 238public Task<ImmutableArray<Diagnostic>> GetAnalyzerDiagnosticsAsync() 246public async Task<ImmutableArray<Diagnostic>> GetAnalyzerDiagnosticsAsync(CancellationToken cancellationToken) 256public async Task<ImmutableArray<Diagnostic>> GetAnalyzerDiagnosticsAsync(ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 286public Task<ImmutableArray<Diagnostic>> GetAllDiagnosticsAsync() 294public async Task<ImmutableArray<Diagnostic>> GetAllDiagnosticsAsync(CancellationToken cancellationToken) 304async Task<ImmutableArray<Diagnostic>> getAllDiagnosticsWithoutStateTrackingAsync(ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 341public async Task<ImmutableArray<Diagnostic>> GetAnalyzerCompilationDiagnosticsAsync(CancellationToken cancellationToken) 352public async Task<ImmutableArray<Diagnostic>> GetAnalyzerCompilationDiagnosticsAsync(ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 359private async Task<ImmutableArray<Diagnostic>> GetAnalyzerCompilationDiagnosticsCoreAsync(ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 375private async Task<ImmutableArray<Diagnostic>> GetAnalyzerDiagnosticsCoreAsync(ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 402public async Task<ImmutableArray<Diagnostic>> GetAnalyzerSyntaxDiagnosticsAsync(SyntaxTree tree, CancellationToken cancellationToken) 418public async Task<ImmutableArray<Diagnostic>> GetAnalyzerSyntaxDiagnosticsAsync(SyntaxTree tree, ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 491private async Task<ImmutableArray<Diagnostic>> GetAnalyzerSyntaxDiagnosticsCoreAsync(SyntaxTree tree, ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 505public async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsAsync(SemanticModel model, TextSpan? filterSpan, CancellationToken cancellationToken) 520public async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsAsync(SemanticModel model, TextSpan? filterSpan, ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 565private async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsCoreAsync(SemanticModel model, TextSpan? filterSpan, ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken) 1173public static IEnumerable<Diagnostic> GetEffectiveDiagnostics(IEnumerable<Diagnostic> diagnostics, Compilation compilation) 1183public static IEnumerable<Diagnostic> GetEffectiveDiagnostics(ImmutableArray<Diagnostic> diagnostics, Compilation compilation) 1198private static IEnumerable<Diagnostic> GetEffectiveDiagnosticsImpl(ImmutableArray<Diagnostic> diagnostics, Compilation compilation) 1211foreach (var diagnostic in diagnostics) 1215var effectiveDiagnostic = compilation.Options.FilterDiagnostic(diagnostic, CancellationToken.None); 1236Action<Exception, DiagnosticAnalyzer, Diagnostic>? onAnalyzerException = null) 1247Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken>? wrappedOnAnalyzerException =
DiagnosticAnalyzer\CompilationWithAnalyzersOptions.cs (8)
15private readonly Action<Exception, DiagnosticAnalyzer, Diagnostic>? _onAnalyzerException; 29public Action<Exception, DiagnosticAnalyzer, Diagnostic>? OnAnalyzerException => _onAnalyzerException; 47/// Flag indicating whether analyzer diagnostics with <see cref="Diagnostic.IsSuppressed"/> should be reported. 60Action<Exception, DiagnosticAnalyzer, Diagnostic>? onAnalyzerException, 74/// <param name="reportSuppressedDiagnostics">Flag indicating whether analyzer diagnostics with <see cref="Diagnostic.IsSuppressed"/> should be reported.</param> 77Action<Exception, DiagnosticAnalyzer, Diagnostic>? onAnalyzerException, 93/// <param name="reportSuppressedDiagnostics">Flag indicating whether analyzer diagnostics with <see cref="Diagnostic.IsSuppressed"/> should be reported.</param> 96Action<Exception, DiagnosticAnalyzer, Diagnostic>? onAnalyzerException,
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (10)
60ImmutableArray<Diagnostic> diagnostics, 61Action<Diagnostic> reportDiagnostic, 65foreach (var diagnostic in diagnostics) 70var current = properties == null ? diagnostic : new CompilerDiagnostic(diagnostic, properties); 78private readonly Diagnostic _original; 81public CompilerDiagnostic(Diagnostic original, ImmutableDictionary<string, string?> properties) 112public override bool Equals(Diagnostic? obj) 122internal override Diagnostic WithLocation(Location location) 127internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 132internal override Diagnostic WithIsSuppressed(bool isSuppressed)
DiagnosticAnalyzer\DiagnosticAnalysisContext.cs (137)
49/// but cannot itself report any <see cref="Diagnostic"/>s. 56/// A compilation action reports <see cref="Diagnostic"/>s about the <see cref="Compilation"/>. 64/// reports <see cref="Diagnostic"/>s about the model. 71/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s. 82/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s. 101/// but cannot itself report any <see cref="Diagnostic"/>s. 109/// A code block action reports <see cref="Diagnostic"/>s about code blocks. 116/// A syntax tree action reports <see cref="Diagnostic"/>s about the <see cref="SyntaxTree"/> of a document. 123/// An additional file action reports <see cref="Diagnostic"/>s about the <see cref="AdditionalText"/> of a document. 133/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 146/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 157/// but cannot itself report any <see cref="Diagnostic"/>s. 167/// An operation block action reports <see cref="Diagnostic"/>s about operation blocks. 177/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 189/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 330/// A compilation end action reports <see cref="Diagnostic"/>s about the <see cref="CodeAnalysis.Compilation"/>. 338/// reports <see cref="Diagnostic"/>s about the model. 345/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s. 356/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s. 375/// but cannot itself report any <see cref="Diagnostic"/>s. 383/// A code block action reports <see cref="Diagnostic"/>s about code blocks. 391/// but cannot itself report any <see cref="Diagnostic"/>s. 401/// An operation block action reports <see cref="Diagnostic"/>s about operation blocks. 411/// A syntax tree action reports <see cref="Diagnostic"/>s about the <see cref="SyntaxTree"/> of a document. 418/// An additional file action reports <see cref="Diagnostic"/>s about the <see cref="AdditionalText"/> of a document. 428/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 441/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 451/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 463/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 519/// A compilation action or compilation end action can use a <see cref="CompilationAnalysisContext"/> to report <see cref="Diagnostic"/>s about a <see cref="CodeAnalysis.Compilation"/>. 525private readonly Action<Diagnostic> _reportDiagnostic; 526private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 546public CompilationAnalysisContext(Compilation compilation, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 554Action<Diagnostic> reportDiagnostic, 555Func<Diagnostic, bool> isSupportedDiagnostic, 568/// Report a <see cref="Diagnostic"/> about a <see cref="CodeAnalysis.Compilation"/>. 570/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 571public void ReportDiagnostic(Diagnostic diagnostic) 627/// A semantic model action operates on the <see cref="CodeAnalysis.SemanticModel"/> of a code document, and can use a <see cref="SemanticModelAnalysisContext"/> to report <see cref="Diagnostic"/>s about the model. 633private readonly Action<Diagnostic> _reportDiagnostic; 634private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 663public SemanticModelAnalysisContext(SemanticModel semanticModel, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 671Action<Diagnostic> reportDiagnostic, 672Func<Diagnostic, bool> isSupportedDiagnostic, 687/// Report a <see cref="Diagnostic"/> about a <see cref="CodeAnalysis.SemanticModel"/>. 689/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 690public void ReportDiagnostic(Diagnostic diagnostic) 702/// A symbol action can use a <see cref="SymbolAnalysisContext"/> to report <see cref="Diagnostic"/>s about an <see cref="ISymbol"/>. 709private readonly Action<Diagnostic> _reportDiagnostic; 710private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 733internal Func<Diagnostic, bool> IsSupportedDiagnostic => _isSupportedDiagnostic; 741public SymbolAnalysisContext(ISymbol symbol, Compilation compilation, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 750Action<Diagnostic> reportDiagnostic, 751Func<Diagnostic, bool> isSupportedDiagnostic, 765/// Report a <see cref="Diagnostic"/> about an <see cref="ISymbol"/>. 767/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 768public void ReportDiagnostic(Diagnostic diagnostic) 780/// A symbol start/end action can use a <see cref="SymbolStartAnalysisContext"/> to report <see cref="Diagnostic"/>s about code within a <see cref="ISymbol"/> and its members. 826/// A symbol end action reports <see cref="Diagnostic"/>s about the code within a <see cref="Symbol"/> and its members. 834/// but cannot itself report any <see cref="Diagnostic"/>s. 842/// A code block action reports <see cref="Diagnostic"/>s about code blocks. 849/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 862/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 873/// but cannot itself report any <see cref="Diagnostic"/>s. 880/// An operation block action reports <see cref="Diagnostic"/>s about operation blocks. 887/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 899/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 982/// A code block end action reports <see cref="Diagnostic"/>s about code blocks. 989/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 1001/// A syntax node action can report <see cref="Diagnostic"/>s about <see cref="SyntaxNode"/>s, and can also collect 1011/// A code block action or code block end action can use a <see cref="CodeBlockAnalysisContext"/> to report <see cref="Diagnostic"/>s about a code block. 1019private readonly Action<Diagnostic> _reportDiagnostic; 1020private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 1054public CodeBlockAnalysisContext(SyntaxNode codeBlock, ISymbol owningSymbol, SemanticModel semanticModel, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 1064Action<Diagnostic> reportDiagnostic, 1065Func<Diagnostic, bool> isSupportedDiagnostic, 1080/// Report a <see cref="Diagnostic"/> about a code block. 1082/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 1083public void ReportDiagnostic(Diagnostic diagnostic) 1179/// A code block end action reports <see cref="Diagnostic"/>s about code blocks. 1186/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 1198/// An operation action can report <see cref="Diagnostic"/>s about <see cref="IOperation"/>s, and can also collect 1227/// An operation block action or operation block end action can use an <see cref="OperationAnalysisContext"/> to report <see cref="Diagnostic"/>s about an operation block. 1235private readonly Action<Diagnostic> _reportDiagnostic; 1236private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 1279Action<Diagnostic> reportDiagnostic, 1280Func<Diagnostic, bool> isSupportedDiagnostic, 1291Action<Diagnostic> reportDiagnostic, 1292Func<Diagnostic, bool> isSupportedDiagnostic, 1309/// Report a <see cref="Diagnostic"/> about a code block. 1311/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 1312public void ReportDiagnostic(Diagnostic diagnostic) 1343/// A syntax tree action can use a <see cref="SyntaxTreeAnalysisContext"/> to report <see cref="Diagnostic"/>s about a <see cref="SyntaxTree"/> for a code document. 1350private readonly Action<Diagnostic> _reportDiagnostic; 1351private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 1377public SyntaxTreeAnalysisContext(SyntaxTree tree, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 1385Action<Diagnostic> reportDiagnostic, 1386Func<Diagnostic, bool> isSupportedDiagnostic, 1401/// Report a <see cref="Diagnostic"/> about a <see cref="SyntaxTree"/>. 1403/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 1404public void ReportDiagnostic(Diagnostic diagnostic) 1416/// An additional file action can use an <see cref="AdditionalFileAnalysisContext"/> to report <see cref="Diagnostic"/>s about a non-source <see cref="AdditionalText"/> document. 1420private readonly Action<Diagnostic> _reportDiagnostic; 1421private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 1446Action<Diagnostic> reportDiagnostic, 1447Func<Diagnostic, bool> isSupportedDiagnostic, 1464public void ReportDiagnostic(Diagnostic diagnostic) 1476/// A syntax node action can use a <see cref="SyntaxNodeAnalysisContext"/> to report <see cref="Diagnostic"/>s for a <see cref="SyntaxNode"/>. 1484private readonly Action<Diagnostic> _reportDiagnostic; 1485private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 1524public SyntaxNodeAnalysisContext(SyntaxNode node, ISymbol? containingSymbol, SemanticModel semanticModel, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 1530public SyntaxNodeAnalysisContext(SyntaxNode node, SemanticModel semanticModel, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken) 1540Action<Diagnostic> reportDiagnostic, 1541Func<Diagnostic, bool> isSupportedDiagnostic, 1556/// Report a <see cref="Diagnostic"/> about a <see cref="SyntaxNode"/>. 1558/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 1559public void ReportDiagnostic(Diagnostic diagnostic) 1571/// An operation action can use an <see cref="OperationAnalysisContext"/> to report <see cref="Diagnostic"/>s for an <see cref="IOperation"/>. 1579private readonly Action<Diagnostic> _reportDiagnostic; 1580private readonly Func<Diagnostic, bool> _isSupportedDiagnostic; 1620Action<Diagnostic> reportDiagnostic, 1621Func<Diagnostic, bool> isSupportedDiagnostic, 1632Action<Diagnostic> reportDiagnostic, 1633Func<Diagnostic, bool> isSupportedDiagnostic, 1650/// Report a <see cref="Diagnostic"/> about a <see cref="SyntaxNode"/>. 1652/// <param name="diagnostic"><see cref="Diagnostic"/> to be reported.</param> 1653public void ReportDiagnostic(Diagnostic diagnostic) 1684/// 2. Diagnostic's <see cref="Diagnostic.DefaultSeverity"/> is not <see cref="DiagnosticSeverity.Error"/>. 1687public ImmutableArray<Diagnostic> ReportedDiagnostics { get; } 1707ImmutableArray<Diagnostic> reportedDiagnostics,
DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs (3)
43internal static void VerifyArguments(Diagnostic diagnostic, Compilation? compilation, Func<Diagnostic, bool> isSupportedDiagnostic) 75internal static void VerifyDiagnosticLocationsInCompilation(Diagnostic diagnostic, Compilation compilation)
DiagnosticAnalyzer\DiagnosticQueue.cs (34)
20public abstract bool TryDequeue([NotNullWhen(returnValue: true)] out Diagnostic? d); 21public abstract void Enqueue(Diagnostic diagnostic); 24public abstract void EnqueueLocal(Diagnostic diagnostic, DiagnosticAnalyzer analyzer, bool isSyntaxDiagnostic); 25public abstract void EnqueueNonLocal(Diagnostic diagnostic, DiagnosticAnalyzer analyzer); 26public abstract ImmutableArray<Diagnostic> DequeueLocalSyntaxDiagnostics(DiagnosticAnalyzer analyzer); 27public abstract ImmutableArray<Diagnostic> DequeueLocalSemanticDiagnostics(DiagnosticAnalyzer analyzer); 28public abstract ImmutableArray<Diagnostic> DequeueNonLocalDiagnostics(DiagnosticAnalyzer analyzer); 40private readonly AsyncQueue<Diagnostic> _queue; 44_queue = new AsyncQueue<Diagnostic>(); 47public SimpleDiagnosticQueue(Diagnostic diagnostic) 49_queue = new AsyncQueue<Diagnostic>(); 53public override void Enqueue(Diagnostic diagnostic) 58public override void EnqueueLocal(Diagnostic diagnostic, DiagnosticAnalyzer analyzer, bool isSyntaxDiagnostic) 63public override void EnqueueNonLocal(Diagnostic diagnostic, DiagnosticAnalyzer analyzer) 68public override ImmutableArray<Diagnostic> DequeueLocalSemanticDiagnostics(DiagnosticAnalyzer analyzer) 73public override ImmutableArray<Diagnostic> DequeueLocalSyntaxDiagnostics(DiagnosticAnalyzer analyzer) 78public override ImmutableArray<Diagnostic> DequeueNonLocalDiagnostics(DiagnosticAnalyzer analyzer) 88public override bool TryDequeue([NotNullWhen(returnValue: true)] out Diagnostic? d) 104public override void Enqueue(Diagnostic diagnostic) 109public override void EnqueueLocal(Diagnostic diagnostic, DiagnosticAnalyzer analyzer, bool isSyntaxDiagnostic) 122public override void EnqueueNonLocal(Diagnostic diagnostic, DiagnosticAnalyzer analyzer) 129Diagnostic diagnostic, 139private static void EnqueueCore_NoLock(Dictionary<DiagnosticAnalyzer, SimpleDiagnosticQueue> diagnosticsMap, Diagnostic diagnostic, DiagnosticAnalyzer analyzer) 156public override bool TryDequeue([NotNullWhen(returnValue: true)] out Diagnostic? d) 164private bool TryDequeue_NoLock([NotNullWhen(returnValue: true)] out Diagnostic? d) 171private static bool TryDequeue_NoLock(Dictionary<DiagnosticAnalyzer, SimpleDiagnosticQueue>? lazyDiagnosticsMap, [NotNullWhen(returnValue: true)] out Diagnostic? d) 173Diagnostic? diag = null; 185public override ImmutableArray<Diagnostic> DequeueLocalSyntaxDiagnostics(DiagnosticAnalyzer analyzer) 190public override ImmutableArray<Diagnostic> DequeueLocalSemanticDiagnostics(DiagnosticAnalyzer analyzer) 195public override ImmutableArray<Diagnostic> DequeueNonLocalDiagnostics(DiagnosticAnalyzer analyzer) 200private ImmutableArray<Diagnostic> DequeueDiagnosticsCore(DiagnosticAnalyzer analyzer, Dictionary<DiagnosticAnalyzer, SimpleDiagnosticQueue>? lazyDiagnosticsMap) 204var builder = ImmutableArray.CreateBuilder<Diagnostic>(); 205while (queue.TryDequeue(out var d)) 213return ImmutableArray<Diagnostic>.Empty;
DiagnosticAnalyzer\DiagnosticSuppressor.cs (1)
35/// 2. Diagnostic's <see cref="Diagnostic.DefaultSeverity"/> is not <see cref="DiagnosticSeverity.Error"/>.
DiagnosticAnalyzer\Suppression.cs (8)
13/// Programmatic suppression of a <see cref="Diagnostic"/> by a <see cref="DiagnosticSuppressor"/>. 17private Suppression(SuppressionDescriptor descriptor, Diagnostic suppressedDiagnostic) 32/// Creates a suppression of a <see cref="Diagnostic"/> with the given <see cref="SuppressionDescriptor"/>. 39/// <see cref="Diagnostic"/> to be suppressed, which must be from <see cref="SuppressionAnalysisContext.ReportedDiagnostics"/> 41public static Suppression Create(SuppressionDescriptor descriptor, Diagnostic suppressedDiagnostic) 52public Diagnostic SuppressedDiagnostic { get; } 73&& EqualityComparer<Diagnostic>.Default.Equals(SuppressedDiagnostic, other.SuppressedDiagnostic); 80EqualityComparer<Diagnostic>.Default.GetHashCode(SuppressedDiagnostic));
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (4)
107public Diagnostic ApplySourceSuppressions(Diagnostic diagnostic) 125public bool IsDiagnosticSuppressed(Diagnostic diagnostic, [NotNullWhen(true)] out AttributeData? suppressingAttribute) 138private bool IsDiagnosticSuppressed(Diagnostic diagnostic, out SuppressMessageInfo info)
Emit\EditAndContinue\EmitDifferenceResult.cs (1)
24internal EmitDifferenceResult(bool success, ImmutableArray<Diagnostic> diagnostics, EmitBaseline? baseline, ImmutableArray<MethodDefinitionHandle> updatedMethods, ImmutableArray<TypeDefinitionHandle> changedTypes)
MetadataReader\MetadataHelpers.cs (1)
929internal static void CheckAssemblyOrModuleName(string name, CommonMessageProvider messageProvider, int code, ArrayBuilder<Diagnostic> builder)
MetadataReference\PortableExecutableReference.cs (1)
186internal static Diagnostic ExceptionToDiagnostic(Exception e, CommonMessageProvider messageProvider, Location location, string display, MetadataImageKind kind)
ReferenceManager\CommonReferenceManager.Resolution.cs (3)
488Diagnostic? newDiagnostic = null; 530Debug.Assert(existing is Metadata || existing is Diagnostic); 535diagnostics.Add((Diagnostic)existing);
ReferenceManager\CommonReferenceManager.State.cs (3)
142private ImmutableArray<Diagnostic> _lazyDiagnostics; 205internal ImmutableArray<Diagnostic> Diagnostics 416ImmutableArray<Diagnostic> diagnostics,
RuleSet\RuleSet.cs (5)
289internal static ReportDiagnostic GetDiagnosticOptionsFromRulesetFile(string? rulesetFileFullPath, out Dictionary<string, ReportDiagnostic> diagnosticOptions, IList<Diagnostic>? diagnosticsOpt, CommonMessageProvider? messageProviderOpt) 300private static ReportDiagnostic GetDiagnosticOptionsFromRulesetFile(Dictionary<string, ReportDiagnostic> diagnosticOptions, string resolvedPath, IList<Diagnostic>? diagnosticsOpt, CommonMessageProvider? messageProviderOpt) 318diagnosticsOpt.Add(Diagnostic.Create(messageProviderOpt, messageProviderOpt.ERR_CantReadRulesetFile, resolvedPath, e.Message)); 327diagnosticsOpt.Add(Diagnostic.Create(messageProviderOpt, messageProviderOpt.ERR_CantReadRulesetFile, resolvedPath, new CodeAnalysisResourcesLocalizableErrorArgument(nameof(CodeAnalysisResources.FileNotFound)))); 334diagnosticsOpt.Add(Diagnostic.Create(messageProviderOpt, messageProviderOpt.ERR_CantReadRulesetFile, resolvedPath, e.Message));
SourceGeneration\GeneratorContexts.cs (3)
95/// Adds a <see cref="Diagnostic"/> to the users compilation 101public void ReportDiagnostic(Diagnostic diagnostic) => _diagnostics.Add(diagnostic); 103internal (ImmutableArray<GeneratedSourceText> sources, ImmutableArray<Diagnostic> diagnostics) ToImmutableAndFree()
SourceGeneration\GeneratorDriver.cs (9)
51public GeneratorDriver RunGeneratorsAndUpdateCompilation(Compilation compilation, out Compilation outputCompilation, out ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken = default) 362var diagnostic = Diagnostic.Create(descriptor, Location.None, generator.GetGeneratorType().Name, e.GetType().Name, e.Message); 363var filtered = compilation.Options.FilterDiagnostic(diagnostic, cancellationToken); 373private static ImmutableArray<Diagnostic> FilterDiagnostics(Compilation compilation, ImmutableArray<Diagnostic> generatorDiagnostics, DiagnosticBag? driverDiagnostics, CancellationToken cancellationToken) 381ArrayBuilder<Diagnostic> filteredDiagnostics = ArrayBuilder<Diagnostic>.GetInstance(); 382foreach (var diag in generatorDiagnostics)
SourceGeneration\GeneratorState.cs (6)
21ImmutableArray<Diagnostic>.Empty, 36ImmutableArray<Diagnostic>.Empty, 50ImmutableArray<Diagnostic> diagnostics, 71ImmutableArray<Diagnostic> diagnostics, 89public GeneratorState WithError(Exception exception, Diagnostic error, TimeSpan elapsedTime) 117internal ImmutableArray<Diagnostic> Diagnostics { get; }
SourceGeneration\IncrementalContexts.cs (3)
157/// Adds a <see cref="Diagnostic"/> to the users compilation 163public void ReportDiagnostic(Diagnostic diagnostic) => Diagnostics.Add(diagnostic); 188internal (ImmutableArray<GeneratedSourceText> sources, ImmutableArray<Diagnostic> diagnostics, GeneratorRunStateTable executedSteps, ImmutableArray<(string Key, string Value)> hostOutputs) ToImmutableAndFree()
SourceGeneration\Nodes\SourceOutputNode.cs (2)
12using TOutput = System.ValueTuple<System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.GeneratedSourceText>, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Diagnostic>>; 90public IIncrementalGeneratorNode<(IEnumerable<GeneratedSourceText>, IEnumerable<Diagnostic>)> WithTrackingName(string name) => throw ExceptionUtilities.Unreachable();
SourceGeneration\RunResults.cs (6)
18private ImmutableArray<Diagnostic> _lazyDiagnostics; 39/// The <see cref="Diagnostic"/>s produced by all generators run during this generation pass. 44public ImmutableArray<Diagnostic> Diagnostics 83ImmutableArray<Diagnostic> diagnostics, 113/// A collection of <see cref="Diagnostic"/>s reported by <see cref="Generator"/> 119public ImmutableArray<Diagnostic> Diagnostics { get; }
StrongName\StrongNameKeys.cs (6)
36internal readonly Diagnostic? DiagnosticOpt; 69internal StrongNameKeys(Diagnostic diagnostic) 175var diagnostic = GetError(keyFilePath, keyContainerName, new CodeAnalysisResourcesLocalizableErrorArgument(nameof(CodeAnalysisResources.AssemblySigningNotSupported)), messageProvider); 204internal static Diagnostic GetError(string? keyFilePath, string? keyContainerName, object message, CommonMessageProvider messageProvider) 217internal static Diagnostic GetContainerError(CommonMessageProvider messageProvider, string name, object message) 222internal static Diagnostic GetKeyFileError(CommonMessageProvider messageProvider, string path, object message)
Syntax\SyntaxNode.cs (1)
699public IEnumerable<Diagnostic> GetDiagnostics()
Syntax\SyntaxNodeOrToken.cs (2)
465public IEnumerable<Diagnostic> GetDiagnostics() 477return SpecializedCollections.EmptyEnumerable<Diagnostic>();
Syntax\SyntaxToken.cs (5)
26private static readonly Func<DiagnosticInfo, Diagnostic> s_createDiagnosticWithoutLocation = Diagnostic.Create; 659public IEnumerable<Diagnostic> GetDiagnostics() 663return SpecializedCollections.EmptyEnumerable<Diagnostic>(); 673? SpecializedCollections.EmptyEnumerable<Diagnostic>()
Syntax\SyntaxTree.cs (5)
178public abstract IEnumerable<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = default); 185public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxNode node); 192public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxToken token); 199public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia); 207public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxNodeOrToken nodeOrToken);
Syntax\SyntaxTrivia.cs (1)
420public IEnumerable<Diagnostic> GetDiagnostics()
Microsoft.CodeAnalysis.CodeStyle (88)
AbstractFileHeaderDiagnosticAnalyzer.cs (2)
61context.ReportDiagnostic(Diagnostic.Create(s_missingHeaderDescriptor, fileHeader.GetLocation(tree))); 68context.ReportDiagnostic(Diagnostic.Create(s_invalidHeaderDescriptor, fileHeader.GetLocation(tree)));
AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
120var diagnostic = DiagnosticHelper.Create(
AbstractMatchFolderAndNamespaceDiagnosticAnalyzer.cs (1)
82context.ReportDiagnostic(Diagnostic.Create(
AbstractOrderModifiersDiagnosticAnalyzer.cs (1)
73Diagnostic.Create(Descriptor, context.Tree.GetLocation(
AbstractPopulateSwitchDiagnosticAnalyzer.cs (2)
63var diagnostic = Diagnostic.Create(
AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (1)
80context.ReportDiagnostic(Diagnostic.Create(Descriptor,
AbstractRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (4)
76public void AnalyzeAssemblyOrModuleAttribute(SyntaxNode attributeSyntax, SemanticModel model, Action<Diagnostic> reportDiagnostic, CancellationToken cancellationToken) 85reportDiagnostic(Diagnostic.Create(s_invalidScopeDescriptor, attributeSyntax.GetLocation())); 92reportDiagnostic(Diagnostic.Create(s_invalidOrMissingTargetDescriptor, attributeSyntax.GetLocation())); 115reportDiagnostic(Diagnostic.Create(LegacyFormatTargetDescriptor, targetValueOperation.Syntax.GetLocation(), properties!, targetSymbolString));
AbstractRemoveUnnecessaryCastDiagnosticAnalyzer.cs (3)
42var diagnostic = TryRemoveCastExpression( 53private Diagnostic? TryRemoveCastExpression(SemanticModel model, TCastExpression node, CancellationToken cancellationToken) 68return Diagnostic.Create(
AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (5)
83foreach (var diagnostic in diagnostics) 142private static IEnumerable<Diagnostic> CreateClassificationDiagnostics( 153yield return Diagnostic.Create(descriptor, tree.GetLocation(span)); 160private IEnumerable<Diagnostic> CreateFixableDiagnostics( 166yield return Diagnostic.Create(s_fixableIdDescriptor, tree.GetLocation(span));
AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (20)
87Action<Diagnostic> reportDiagnostic, 387private static async Task<(ImmutableArray<Diagnostic> reportedDiagnostics, ImmutableArray<string> unhandledIds)> GetReportedDiagnosticsForIdsAsync( 448using var _3 = ArrayBuilder<Diagnostic>.GetInstance(out var reportedDiagnostics); 481static void AddAllDiagnostics(ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> diagnostics, ArrayBuilder<Diagnostic> reportedDiagnostics) 489static void AddAllCompilationDiagnosticsForTree(AnalysisResult analysisResult, SyntaxTree tree, ArrayBuilder<Diagnostic> reportedDiagnostics) 493foreach (var diagnostic in perAnalyzerDiagnostics) 505ImmutableArray<Diagnostic> diagnostics, 514foreach (var diagnostic in diagnostics) 541Diagnostic diagnostic, 581Diagnostic diagnostic, 609Action<Diagnostic> reportDiagnostic, 613using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnosticsBuilder); 619foreach (var diagnostic in effectiveDiagnostics) 627ArrayBuilder<Diagnostic> diagnosticsBuilder, 652var diagnostic = Diagnostic.Create(s_removeUnnecessarySuppressionDescriptor, pragma.GetLocation(), severity, additionalLocations, properties: null); 659ArrayBuilder<Diagnostic> diagnosticsBuilder, 667var diagnostic = Diagnostic.Create(s_removeUnnecessarySuppressionDescriptor, attribute.GetLocation(), severity, additionalLocations: null, properties: null);
AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
472var diagnostic = DiagnosticHelper.CreateWithMessage(
AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (3)
290public static bool TryGetUnusedValuePreference(Diagnostic diagnostic, out UnusedValuePreference preference) 311public static bool GetIsUnusedLocalDiagnostic(Diagnostic diagnostic) 317public static bool GetIsRemovableAssignmentDiagnostic(Diagnostic diagnostic)
AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (2)
182var diagnostic = DiagnosticHelper.Create(s_expressionValueIsUnusedRule, 536var diagnostic = DiagnosticHelper.Create(s_valueAssignedIsUnusedRule,
AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (2)
131Action<Diagnostic> reportDiagnostic, 154var diagnostic = DiagnosticHelper.CreateWithMessage(s_unusedParameterRule, location,
AbstractUseAutoPropertyAnalyzer.cs (3)
330var diagnostic1 = DiagnosticHelper.Create( 339var diagnostic2 = Diagnostic.Create(
AbstractUseObjectInitializerDiagnosticAnalyzer.cs (1)
150context.ReportDiagnostic(Diagnostic.Create(
AbstractValidateFormatStringDiagnosticAnalyzer.cs (2)
357var diagnostic = Diagnostic.Create(
DiagnosticHelper.cs (21)
21/// Creates a <see cref="Diagnostic"/> instance. 29/// If null, <see cref="Diagnostic.AdditionalLocations"/> will return an empty list. 33/// can convey more detailed information to the fixer. If null, <see cref="Diagnostic.Properties"/> will return 37/// <returns>The <see cref="Diagnostic"/> instance.</returns> 38public static Diagnostic Create( 74/// <see cref="Diagnostic.AdditionalLocations"/>. 79/// <see cref="Diagnostic.AdditionalLocations"/>. 82/// <returns>The <see cref="Diagnostic"/> instance.</returns> 83public static Diagnostic CreateWithLocationTags( 118/// <see cref="Diagnostic.AdditionalLocations"/>. 123/// <see cref="Diagnostic.AdditionalLocations"/>. 130/// <returns>The <see cref="Diagnostic"/> instance.</returns> 131public static Diagnostic CreateWithLocationTags( 176/// <returns>The <see cref="Diagnostic"/> instance.</returns> 177private static Diagnostic CreateWithLocationTags( 210/// Creates a <see cref="Diagnostic"/> instance. 218/// If null, <see cref="Diagnostic.AdditionalLocations"/> will return an empty list. 222/// can convey more detailed information to the fixer. If null, <see cref="Diagnostic.Properties"/> will return 226/// <returns>The <see cref="Diagnostic"/> instance.</returns> 227public static Diagnostic CreateWithMessage( 240return Diagnostic.Create(
FormattingAnalyzerHelper.cs (1)
66context.ReportDiagnostic(Diagnostic.Create(
IPragmaSuppressionsAnalyzer.cs (1)
27Action<Diagnostic> reportDiagnostic,
J\s\src\Compilers\Core\Portable\Collections\ImmutableArrayExtensions.cs\ImmutableArrayExtensions.cs (1)
649internal static bool HasAnyErrors<T>(this ImmutableArray<T> diagnostics) where T : Diagnostic
NamingStyleDiagnosticAnalyzerBase.cs (3)
65var diagnostic = TryGetDiagnostic( 87var diagnostic = TryGetDiagnostic( 104private Diagnostic? TryGetDiagnostic(
SimplifyTypeNamesDiagnosticAnalyzerBase.cs (7)
110protected abstract ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context); 111protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree); 113public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, CancellationToken cancellationToken) 134internal static Diagnostic CreateDiagnostic(SemanticModel model, TSimplifierOptions options, TextSpan issueSpan, string diagnosticId, bool inDeclaration) 166var diagnostic = DiagnosticHelper.Create(descriptor, tree.GetLocation(issueSpan), severity, additionalLocations: null, builder.ToImmutable()); 246foreach (var diagnostic in diagnostics) 298foreach (var diagnostic in diagnostics)
Microsoft.CodeAnalysis.CodeStyle.Fixes (166)
AbstractAddAccessibilityModifiersCodeFixProvider.cs (3)
28var diagnostic = context.Diagnostics.First(); 44Document document, ImmutableArray<Diagnostic> diagnostics, 49foreach (var diagnostic in diagnostics)
AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (5)
38var diagnostic = context.Diagnostics[0]; 54Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 84Document document, ImmutableArray<Diagnostic> diagnostics, 92foreach (var diagnostic in diagnostics) 101Document document, SemanticModel semanticModel, Diagnostic diagnostic,
AbstractAddExplicitCastCodeFixProvider.cs (2)
60var diagnostic = context.Diagnostics.First(); 195ImmutableArray<Diagnostic> diagnostics,
AbstractAddObsoleteAttributeCodeFixProvider.cs (1)
72Document document, ImmutableArray<Diagnostic> diagnostics,
AbstractAddParameterCodeFixProvider.cs (2)
54var diagnostic = context.Diagnostics.First(); 98SyntaxNode initialNode, SyntaxNode node, Diagnostic diagnostic)
AbstractChangeNamespaceToMatchFolderCodeFixProvider.cs (1)
43private static async Task<Solution> FixAllInDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider options, CancellationToken cancellationToken)
AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (3)
58static async Task<ImmutableArray<Diagnostic>> GetSolutionDiagnosticsAsync(FixAllContext fixAllContext) 60var diagnostics = ImmutableArray.CreateBuilder<Diagnostic>(); 74ImmutableArray<Diagnostic> diagnostics,
AbstractConflictMarkerCodeFixProvider.cs (2)
379Document document, ImmutableArray<Diagnostic> diagnostics, 400foreach (var diagnostic in diagnostics)
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)
AbstractConvertTypeOfToNameOfCodeFixProvider.cs (2)
35Document document, ImmutableArray<Diagnostic> diagnostics, 39foreach (var diagnostic in diagnostics)
AbstractFileHeaderCodeFixProvider.cs (1)
33foreach (var diagnostic in context.Diagnostics)
AbstractForEachCastCodeFixProvider.cs (3)
40protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 44Document document, ImmutableArray<Diagnostic> diagnostics, 49foreach (var diagnostic in diagnostics)
AbstractIteratorCodeFixProvider.cs (2)
24protected abstract Task<CodeAction> GetCodeFixAsync(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostics, CancellationToken cancellationToken); 34var diagnostic = context.Diagnostics.FirstOrDefault();
AbstractMakeFieldReadonlyCodeFixProvider.cs (2)
40ImmutableArray<Diagnostic> diagnostics, 46foreach (var diagnostic in diagnostics)
AbstractMakeMemberStaticCodeFixProvider.cs (1)
32protected sealed override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor,
AbstractMakeMethodAsynchronousCodeFixProvider.cs (4)
20protected abstract bool IsSupportedDiagnostic(Diagnostic diagnostic, CancellationToken cancellationToken); 36var diagnostic = context.Diagnostics.First(); 104Diagnostic diagnostic, 147private SyntaxNode? GetContainingFunction(Diagnostic diagnostic, CancellationToken cancellationToken)
AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
32var diagnostic = context.Diagnostics.First();
AbstractMakeTypeAbstractCodeFixProvider.cs (1)
32protected sealed override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor,
AbstractMakeTypePartialCodeFixProvider.cs (2)
29protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 35foreach (var diagnostic in diagnostics)
AbstractMultipleBlankLinesCodeFixProvider.cs (4)
36var diagnostic = context.Diagnostics.First(); 45private static Task<Document> UpdateDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 49Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 55foreach (var diagnostic in diagnostics)
AbstractOrderModifiersCodeFixProvider.cs (2)
53Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 62foreach (var diagnostic in diagnostics)
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,
AbstractQualifyMemberAccessCodeFixProvider.cs (3)
23protected abstract TSimpleNameSyntax? GetNode(Diagnostic diagnostic, CancellationToken cancellationToken); 36Document document, ImmutableArray<Diagnostic> diagnostics, 41foreach (var diagnostic in diagnostics)
AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
36var diagnostic = context.Diagnostics.First(); 64Document document, ImmutableArray<Diagnostic> diagnostics, 75foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
AbstractRemoveUnnecessaryParenthesesCodeFixProvider.cs (1)
35Document document, ImmutableArray<Diagnostic> diagnostics,
AbstractRemoveUnusedMembersCodeFixProvider.cs (2)
44ImmutableArray<Diagnostic> diagnostics, 54foreach (var diagnostic in diagnostics)
AbstractRemoveUnusedValuesCodeFixProvider.cs (17)
127var diagnostic = context.Diagnostics[0]; 191private static bool IsForEachIterationVariableDiagnostic(Diagnostic diagnostic, Document document, CancellationToken cancellationToken) 202private static string GetEquivalenceKey(Diagnostic diagnostic) 221protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 227private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember( 228ImmutableArray<Diagnostic> diagnostics, 240foreach (var diagnostic in diagnostics) 252private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember( 253ImmutableArray<Diagnostic> diagnostics, 260private static async Task<Document> PreprocessDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 272protected sealed override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 284ImmutableArray<Diagnostic> diagnostics, 335IEnumerable<Diagnostic> diagnostics, 372IOrderedEnumerable<Diagnostic> diagnostics, 388foreach (var diagnostic in diagnostics) 431IOrderedEnumerable<Diagnostic> diagnostics, 664foreach (var diagnostic in diagnostics)
AbstractSimplifyInterpolationCodeFixProvider.cs (2)
50Document document, ImmutableArray<Diagnostic> diagnostics, 58foreach (var diagnostic in diagnostics)
AbstractSimplifyLinqExpressionCodeFixProvider`3.cs (2)
35ImmutableArray<Diagnostic> diagnostics, 55static TInvocationExpressionSyntax GetInvocation(SyntaxNode root, Diagnostic diagnostic)
AbstractUpgradeProjectCodeFixProvider.cs (1)
21public abstract string SuggestedVersion(ImmutableArray<Diagnostic> diagnostics);
AbstractUseCollectionInitializerCodeFixProvider.cs (3)
44protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 54Document document, ImmutableArray<Diagnostic> diagnostics, 69foreach (var diagnostic in diagnostics)
AbstractUseCompoundAssignmentCodeFixProvider.cs (2)
53Document document, ImmutableArray<Diagnostic> diagnostics, 59foreach (var diagnostic in diagnostics)
AbstractUseConditionalExpressionCodeFixProvider.cs (3)
49Document document, Diagnostic diagnostic, 53Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, 63foreach (var diagnostic in diagnostics)
AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
61Document document, Diagnostic diagnostic,
AbstractUseConditionalExpressionForReturnCodeFixProvider.cs (1)
47Document document, Diagnostic diagnostic,
AbstractUseInferredMemberNameCodeFixProvider.cs (2)
32Document document, ImmutableArray<Diagnostic> diagnostics, 37foreach (var diagnostic in diagnostics)
AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (4)
32private static bool IsSupportedDiagnostic(Diagnostic diagnostic) 37var diagnostic = context.Diagnostics.First(); 51Document document, ImmutableArray<Diagnostic> diagnostics, 59foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
AbstractUseNullPropagationCodeFixProvider.cs (5)
59protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 69Document document, ImmutableArray<Diagnostic> diagnostics, 75foreach (var diagnostic in diagnostics) 93Diagnostic diagnostic, 141Diagnostic diagnostic,
AbstractUseObjectInitializerCodeFixProvider.cs (3)
42protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 52Document document, ImmutableArray<Diagnostic> diagnostics, 67foreach (var diagnostic in diagnostics)
AddRequiredParenthesesCodeFixProvider.cs (4)
31protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 37var firstDiagnostic = context.Diagnostics[0]; 48Document document, ImmutableArray<Diagnostic> diagnostics, 53foreach (var diagnostic in diagnostics)
CodeFixContextExtensions.cs (2)
16internal static void RegisterFixes(this CodeFixContext context, IEnumerable<CodeAction> actions, Diagnostic diagnostic) 27internal static void RegisterFixes(this CodeFixContext context, IEnumerable<CodeAction> actions, ImmutableArray<Diagnostic> diagnostics)
ConsecutiveStatementPlacementCodeFixProvider.cs (3)
36var diagnostic = context.Diagnostics.First(); 45private static Task<Document> UpdateDocumentAsync(Document document, Diagnostic diagnostic, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 48public static async Task<Document> FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
DocumentExtensions.cs (2)
156public static async Task<ImmutableArray<Diagnostic>> GetErrorsAsync(this Document document, CancellationToken cancellationToken, IList<string>? ignoreErrorCode = null) 160return ImmutableArray<Diagnostic>.Empty;
FormattingCodeFixHelper.cs (1)
17internal static async Task<SyntaxTree> FixOneAsync(SyntaxTree syntaxTree, FormattingProvider formattingProvider, SyntaxFormattingOptions options, Diagnostic diagnostic, CancellationToken cancellationToken)
FormattingCodeFixProvider.cs (3)
40foreach (var diagnostic in context.Diagnostics) 63private async Task<Document> FixOneAsync(CodeFixContext context, Diagnostic diagnostic, CancellationToken cancellationToken) 72protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
NamingStyleCodeFixProvider.cs (1)
51var diagnostic = context.Diagnostics.First();
ProjectExtensions.cs (2)
43public static string? TryGetAnalyzerConfigPathForDiagnosticConfiguration(this Project project, Diagnostic diagnostic) 49private static string? TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(Project project, Diagnostic? diagnostic)
RemoveRedundantEqualityCodeFixProvider.cs (3)
35foreach (var diagnostic in context.Diagnostics) 43protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 49foreach (var diagnostic in diagnostics)
RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (3)
34foreach (var diagnostic in context.Diagnostics) 44protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 46foreach (var diagnostic in diagnostics)
RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
40foreach (var diagnostic in context.Diagnostics) 51protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 60foreach (var diagnostic in diagnostics)
SimplifyConditionalCodeFixProvider.cs (2)
43ImmutableArray<Diagnostic> diagnostics, 66SyntaxNode SimplifyConditional(SemanticModel semanticModel, Diagnostic diagnostic, SyntaxNode expr)
SyntaxEditorBasedCodeFixProvider.cs (11)
55protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, Diagnostic? diagnostic = null) 58protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, CodeActionPriority priority, Diagnostic? diagnostic = null) 61protected Func<CancellationToken, Task<Document>> GetDocumentUpdater(CodeFixContext context, Diagnostic? diagnostic = null) 68Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider options, CancellationToken cancellationToken) 97Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken); 106/// This overload differs from <see cref="IncludeDiagnosticDuringFixAll(Diagnostic, Document, SemanticModel, string, CancellationToken)"/> 109/// This overload differs from <see cref="IncludeDiagnosticDuringFixAll(Diagnostic)"/> in 116protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, SemanticModel model, string? equivalenceKey, CancellationToken cancellationToken) 119protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 133/// cref="IncludeDiagnosticDuringFixAll(Diagnostic, Document, SemanticModel, string, CancellationToken)"/> 139protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic)
UpdateLegacySuppressionsCodeFixProvider.cs (3)
35foreach (var diagnostic in context.Diagnostics) 45protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 47foreach (var diagnostic in diagnostics)
UseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs (2)
41Document document, ImmutableArray<Diagnostic> diagnostics, 47foreach (var diagnostic in diagnostics)
UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs (3)
32protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 42Document document, ImmutableArray<Diagnostic> diagnostics, 53foreach (var diagnostic in diagnostics)
UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (4)
33protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 43Document document, ImmutableArray<Diagnostic> diagnostics, 51foreach (var diagnostic in diagnostics) 64Diagnostic diagnostic, CancellationToken cancellationToken)
UseExplicitTupleNameCodeFixProvider.cs (2)
39Document document, ImmutableArray<Diagnostic> diagnostics, 44foreach (var diagnostic in diagnostics)
UseSystemHashCodeCodeFixProvider.cs (2)
40Document document, ImmutableArray<Diagnostic> diagnostics, 58foreach (var diagnostic in diagnostics)
Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities (28)
AbstractCodeActionOrUserDiagnosticTest.cs (9)
314protected abstract Task<ImmutableArray<Diagnostic>> GetDiagnosticsWorkerAsync( 476ImmutableArray<Diagnostic> diagnostics, 498static IEnumerable<Location> GetUnnecessaryLocations(Diagnostic diagnostic) 517ImmutableArray<Diagnostic> diagnosticsWithTag) 527foreach (var diagnostic in diagnosticsWithTag) 802var diagnosticsAndEquivalenceKeyToTitleMap = new Dictionary<(Diagnostic diagnostic, string equivalenceKey), string>(); 812ImmutableArray<Diagnostic> diagnostics, 814Dictionary<(Diagnostic diagnostic, string equivalenceKey), string> diagnosticsAndEquivalenceKeyToTitleMap) 827foreach (var diagnostic in diagnostics)
AbstractDiagnosticProviderBasedUserDiagnosticTest.cs (4)
143internal override async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 155internal override async Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( 234/// The internal method <see cref="AnalyzerExecutor.IsAnalyzerExceptionDiagnostic(Diagnostic)"/> does 240private static void AssertNoAnalyzerExceptionDiagnostics(IEnumerable<Diagnostic> diagnostics)
AbstractUserDiagnosticTest.cs (11)
38internal abstract Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( 41internal abstract Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 61var diagnostic = diagnostics.Single(); 81protected override async Task<ImmutableArray<Diagnostic>> GetDiagnosticsWorkerAsync( 117internal async Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( 118IEnumerable<Diagnostic> diagnostics, 128return (ImmutableArray<Diagnostic>.Empty, ImmutableArray<CodeAction>.Empty, null); 140return (ImmutableArray<Diagnostic>.Empty, ImmutableArray<CodeAction>.Empty, null); 149foreach (var diagnostic in intersectingDiagnostics) 192IEnumerable<Diagnostic> diagnostics, 209var diagnostic = diagnostics.First();
AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs (4)
30public override async Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) 38public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) 41public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) 44private async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(
Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities (8)
CSharpCodeFixVerifier`2+Test.cs (4)
80public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; } 137protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray<Diagnostic> fixableDiagnostics)
VisualBasicCodeFixVerifier`2+Test.cs (4)
70public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; } 99protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray<Diagnostic> fixableDiagnostics)
Microsoft.CodeAnalysis.CSharp (160)
Binder\Binder_Crefs.cs (1)
999foreach (Diagnostic diag in unusedDiagnostics.AsEnumerable())
Binder\ForEachLoopBinder.cs (1)
486foreach (var d in createConversionDiagnostics.DiagnosticBag.AsEnumerableWithoutResolution())
BoundTree\UnboundLambda.cs (9)
1275FirstAmongEqualsSet<Diagnostic>? intersection = null; 1297FirstAmongEqualsSet<Diagnostic>? union = null; 1323private static bool PreventsSuccessfulDelegateConversion(FirstAmongEqualsSet<Diagnostic> set) 1325foreach (var diagnostic in set) 1335private static FirstAmongEqualsSet<Diagnostic> CreateFirstAmongEqualsSet(ImmutableArray<Diagnostic> bag) 1341return new FirstAmongEqualsSet<Diagnostic>( 1353private static int CanonicallyCompareDiagnostics(Diagnostic x, Diagnostic y)
CommandLine\CSharpCommandLineParser.cs (27)
54List<Diagnostic> diagnostics = new List<Diagnostic>(); 121int warningLevel = Diagnostic.DefaultWarningLevel; 348IEnumerable<Diagnostic> defineDiagnostics; 1583private static void ParseAndResolveReferencePaths(string? switchName, ReadOnlyMemory<char>? switchValue, string? baseDirectory, List<string> builder, MessageID origin, List<Diagnostic> diagnostics) 1610private static string? GetWin32Setting(string arg, string? value, List<Diagnostic> diagnostics) 1633List<Diagnostic> diagnostics, 1732public static IEnumerable<string> ParseConditionalCompilationSymbols(string value, out IEnumerable<Diagnostic> diagnostics) 1739internal static void ParseConditionalCompilationSymbols(ReadOnlyMemory<char> valueMemory, ArrayBuilder<string> defines, out IEnumerable<Diagnostic> diagnostics) 1745outputDiagnostics.Add(Diagnostic.Create(CSharp.MessageProvider.Instance, (int)ErrorCode.WRN_DefineIdentifierRequired, valueMemory.ToString())); 1777outputDiagnostics.Add(Diagnostic.Create(CSharp.MessageProvider.Instance, (int)ErrorCode.WRN_DefineIdentifierRequired, id)); 1784private static Platform ParsePlatform(string value, IList<Diagnostic> diagnostics) 1808private static OutputKind ParseTarget(string value, IList<Diagnostic> diagnostics) 1836private static IEnumerable<string> ParseUsings(string arg, string? value, IList<Diagnostic> diagnostics) 1850private static void ParseAnalyzers(string arg, ReadOnlyMemory<char>? valueMemory, List<CommandLineAnalyzerReference> analyzerReferences, List<Diagnostic> diagnostics) 1877private static void ParseAssemblyReferences(string arg, ReadOnlyMemory<char>? valueMemory, IList<Diagnostic> diagnostics, bool embedInteropTypes, List<CommandLineReference> commandLineReferences) 1961private static void ValidateWin32Settings(string? win32ResourceFile, string? win32IconResourceFile, string? win32ManifestFile, OutputKind outputKind, IList<Diagnostic> diagnostics) 1982private static IEnumerable<InstrumentationKind> ParseInstrumentationKinds(string value, IList<Diagnostic> diagnostics) 2004IList<Diagnostic> diagnostics, 2012IList<Diagnostic> diagnostics, 2137private static void UnimplementedSwitch(IList<Diagnostic> diagnostics, string switchName) 2142internal override void GenerateErrorForNoFilesFoundInRecurse(string path, IList<Diagnostic> diagnostics) 2147private static void AddDiagnostic(IList<Diagnostic> diagnostics, ErrorCode errorCode) 2149diagnostics.Add(Diagnostic.Create(CSharp.MessageProvider.Instance, (int)errorCode)); 2152private static void AddDiagnostic(IList<Diagnostic> diagnostics, ErrorCode errorCode, params object[] arguments) 2154diagnostics.Add(Diagnostic.Create(CSharp.MessageProvider.Instance, (int)errorCode, arguments)); 2160private static void AddDiagnostic(IList<Diagnostic> diagnostics, Dictionary<string, ReportDiagnostic> warningOptions, ErrorCode errorCode, params object[] arguments)
Compilation\CSharpCompilation.cs (21)
71private ImmutableArray<Diagnostic> _lazyClsComplianceDiagnostics; 1914foreach (var diagnostic in noMainFoundDiagnostics.DiagnosticBag.AsEnumerable()) 2621public override ImmutableArray<Diagnostic> GetParseDiagnostics(CancellationToken cancellationToken = default) 2630public override ImmutableArray<Diagnostic> GetDeclarationDiagnostics(CancellationToken cancellationToken = default) 2638public override ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(CancellationToken cancellationToken = default) 2647public override ImmutableArray<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = default) 2652internal ImmutableArray<Diagnostic> GetDiagnostics(CompilationStage stage, bool includeEarlierStages, CancellationToken cancellationToken) 2709foreach (var error in syntaxTree.Options.Errors) 2758private static void AppendLoadDirectiveDiagnostics(DiagnosticBag builder, SyntaxAndDeclarationManager syntaxAndDeclarations, SyntaxTree syntaxTree, Func<IEnumerable<Diagnostic>, IEnumerable<Diagnostic>>? locationFilterOpt = null) 2766IEnumerable<Diagnostic> diagnostics = directive.Diagnostics; 2820private ImmutableArray<Diagnostic> GetDiagnosticsForMethodBodiesInTree(SyntaxTree tree, TextSpan? span, CancellationToken cancellationToken) 2952private ImmutableBindingDiagnostic<AssemblySymbol> GetSourceDeclarationDiagnostics(SyntaxTree? syntaxTree = null, TextSpan? filterSpanWithinTree = null, Func<IEnumerable<Diagnostic>, SyntaxTree, TextSpan?, IEnumerable<Diagnostic>>? locationFilterOpt = null, CancellationToken cancellationToken = default) 2979var result = _lazyDeclarationDiagnostics?.AsEnumerable() ?? Enumerable.Empty<Diagnostic>(); 3016private static IEnumerable<Diagnostic> FilterDiagnosticsByLocation(IEnumerable<Diagnostic> diagnostics, SyntaxTree tree, TextSpan? filterSpanWithinTree) 3018foreach (var diagnostic in diagnostics) 3027internal ImmutableArray<Diagnostic> GetDiagnosticsForSyntaxTree( 3065IEnumerable<Diagnostic> methodBodyDiagnostics = GetDiagnosticsForMethodBodiesInTree(syntaxTree, filterSpanWithinTree, cancellationToken); 3079return result.ToReadOnlyAndFree<Diagnostic>();
Compilation\CSharpDiagnosticFilter.cs (5)
15/// Applies C#-specific modification and filtering of <see cref="Diagnostic"/>s. 24/// Modifies an input <see cref="Diagnostic"/> per the given options. For example, the 25/// severity may be escalated, or the <see cref="Diagnostic"/> may be filtered out entirely 34internal static Diagnostic? Filter( 35Diagnostic d,
Compilation\MemberSemanticModel.cs (4)
561public sealed override ImmutableArray<Diagnostic> GetSyntaxDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 566public sealed override ImmutableArray<Diagnostic> GetDeclarationDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 571public sealed override ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 576public sealed override ImmutableArray<Diagnostic> GetDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SpeculativeSemanticModelWithMemberModel.cs (4)
231public override ImmutableArray<Diagnostic> GetSyntaxDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 236public override ImmutableArray<Diagnostic> GetDeclarationDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 241public override ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 246public override ImmutableArray<Diagnostic> GetDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SyntaxTreeSemanticModel.cs (4)
110public override ImmutableArray<Diagnostic> GetSyntaxDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 117public override ImmutableArray<Diagnostic> GetDeclarationDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 124public override ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken)) 131public override ImmutableArray<Diagnostic> GetDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
Compiler\DocumentationCommentCompiler.cs (1)
738foreach (Diagnostic diag in node.GetDiagnostics())
Compiler\DocumentationCommentCompiler.IncludeElementExpander.cs (2)
640foreach (Diagnostic diagnostic in CSharpSyntaxTree.Dummy.GetDiagnostics(treelessSyntax)) 656foreach (Diagnostic diagnostic in bindingDiagnostics.DiagnosticBag.AsEnumerable())
Compiler\MethodCompiler.cs (1)
951sourceMethod.SetDiagnostics(ImmutableArray<Diagnostic>.Empty, out diagsWritten);
CSharpCompilationOptions.cs (14)
64int warningLevel = Diagnostic.DefaultWarningLevel, 662internal override void ValidateOptions(ArrayBuilder<Diagnostic> builder) 671builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_NoMainOnDLL)); 676builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MainTypeName), MainTypeName)); 682builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPlatformType, Platform.ToString())); 692builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OutputKind), OutputKind.ToString())); 697builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OptimizationLevel), OptimizationLevel.ToString())); 702builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(ScriptClassName), ScriptClassName ?? "null")); 707builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(WarningLevel), WarningLevel)); 712builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(Usings), Usings.Where(u => !u.IsValidClrNamespaceName()).First() ?? "null")); 717builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPrefer32OnLib)); 722builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MetadataImportOptions), MetadataImportOptions.ToString())); 761internal override Diagnostic? FilterDiagnostic(Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpParseOptions.cs (4)
178internal override void ValidateOptions(ArrayBuilder<Diagnostic> builder) 185builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadLanguageVersion, LanguageVersion.ToString())); 194builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_InvalidPreprocessingSymbol, "null")); 198builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_InvalidPreprocessingSymbol, symbol));
Declarations\DeclarationTreeBuilder.cs (6)
115var diagnostics = ImmutableArray<Diagnostic>.Empty; 153diagnostics: ImmutableArray<Diagnostic>.Empty, 157private static SingleNamespaceOrTypeDeclaration CreateSimpleProgram(GlobalStatementSyntax firstGlobalStatement, bool hasAwaitExpressions, bool isIterator, bool hasReturnWithExpression, ImmutableArray<Diagnostic> diagnostics) 259diagnostics: ImmutableArray<Diagnostic>.Empty, 271diagnostics: ImmutableArray<Diagnostic>.Empty); 432diagnostics: ImmutableArray<Diagnostic>.Empty);
Declarations\RootSingleNamespaceDeclaration.cs (1)
35ImmutableArray<Diagnostic> diagnostics,
Declarations\SingleNamespaceDeclaration.cs (2)
20ImmutableArray<Diagnostic> diagnostics) 70ImmutableArray<Diagnostic> diagnostics)
Declarations\SingleNamespaceDeclarationEx.cs (1)
20ImmutableArray<Diagnostic> diagnostics)
Declarations\SingleNamespaceOrTypeDeclaration.cs (2)
21public readonly ImmutableArray<Diagnostic> Diagnostics; 27ImmutableArray<Diagnostic> diagnostics)
Declarations\SingleTypeDeclaration.cs (1)
73ImmutableArray<Diagnostic> diagnostics,
Errors\CSDiagnostic.cs (3)
26internal override Diagnostic WithLocation(Location location) 41internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 52internal override Diagnostic WithIsSuppressed(bool isSuppressed)
Errors\ErrorFacts.cs (5)
174return Diagnostic.CompilerDiagnosticCategory; 202return Diagnostic.InfoAndHiddenWarningLevel; 2363foreach (Diagnostic diag in diagnostics.AsEnumerable()) // Checking the code would have resolved them anyway. 2374internal static bool PreventsSuccessfulDelegateConversion(ImmutableArray<Diagnostic> diagnostics) 2376foreach (var diag in diagnostics)
Errors\MessageProvider.cs (2)
99public override Diagnostic CreateDiagnostic(int code, Location location, params object[] args) 105public override Diagnostic CreateDiagnostic(DiagnosticInfo info)
FlowAnalysis\DefiniteAssignment.cs (7)
563HashSet<Diagnostic> compatDiagnosticSet = new HashSet<Diagnostic>(compatDiagnostics.AsEnumerable(), SameDiagnosticComparer.Instance); 565foreach (var diagnostic in strictDiagnostics.AsEnumerable()) 648private sealed class SameDiagnosticComparer : EqualityComparer<Diagnostic> 651public override bool Equals(Diagnostic x, Diagnostic y) => x.Equals(y); 652public override int GetHashCode(Diagnostic obj) =>
FlowAnalysis\FlowAnalysisPass.cs (2)
90IEnumerable<Diagnostic> getErrorsOnly(IEnumerable<Diagnostic> diags) => diags.Where(d => d.Severity == DiagnosticSeverity.Error);
Lowering\SyntheticBoundNodeFactory.cs (2)
34public MissingPredefinedMember(Diagnostic error) : base(error.ToString()) 39public Diagnostic Diagnostic { get; }
Symbols\Source\SourceAssemblySymbol.cs (2)
115private ImmutableArray<Diagnostic> _unusedFieldWarnings; 2621internal ImmutableArray<Diagnostic> GetUnusedFieldWarnings(CancellationToken cancellationToken)
Symbols\Source\SourceMemberContainerSymbol_ImplementationChecks.cs (2)
168Diagnostic diag = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_DuplicateExplicitImpl, interfaceMember), this.Locations[0]); 1751foreach (Diagnostic diagnostic in implementingMemberAndDiagnostics.Diagnostics.Diagnostics)
Symbols\Source\SourceMemberMethodSymbol.cs (4)
208private ImmutableArray<Diagnostic> _cachedDiagnostics; 209internal ImmutableArray<Diagnostic> Diagnostics 214internal ImmutableArray<Diagnostic> SetDiagnostics(ImmutableArray<Diagnostic> newSet, out bool diagsWritten)
Symbols\Source\SourceNamespaceSymbol.AliasesAndUsings.cs (4)
1038public static readonly ExternAliasesAndDiagnostics Empty = new ExternAliasesAndDiagnostics() { ExternAliases = ImmutableArray<AliasAndExternAliasDirective>.Empty, Diagnostics = ImmutableArray<Diagnostic>.Empty }; 1041public ImmutableArray<Diagnostic> Diagnostics { get; init; } 1076Diagnostics = ImmutableArray<Diagnostic>.Empty, 1082public ImmutableArray<Diagnostic> Diagnostics { get; init; }
Symbols\Symbol_Attributes.cs (3)
471var toRemove = new HashSet<Diagnostic>(ReferenceEqualityComparer.Instance); 474foreach (Diagnostic d in diagnostics.DiagnosticBag.AsEnumerableWithoutResolution()) 499foreach (Diagnostic d in diagnostics.DiagnosticBag.AsEnumerableWithoutResolution())
Syntax\CSharpSyntaxNode.cs (1)
233public new IEnumerable<Diagnostic> GetDiagnostics()
Syntax\CSharpSyntaxTree.cs (8)
783public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxNode node) 793private IEnumerable<Diagnostic> GetDiagnostics(GreenNode greenNode, int position) 805return SpecializedCollections.EmptyEnumerable<Diagnostic>(); 808private IEnumerable<Diagnostic> EnumerateDiagnostics(GreenNode node, int position) 824public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxToken token) 840public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia) 857public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxNodeOrToken nodeOrToken) 873public override IEnumerable<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = default)
Syntax\SyntaxFactory.cs (2)
2325foreach (var error in compilation.EndOfFileToken.GetDiagnostics()) 2381foreach (var error in token.GetDiagnostics())
Syntax\SyntaxTreeDiagnosticEnumerator.cs (2)
18private Diagnostic? _current; 109public Diagnostic Current
Microsoft.CodeAnalysis.CSharp.CodeStyle (22)
ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs (2)
36var diagnostic = AnalyzeNamespace(context.GetCSharpAnalyzerOptions().NamespaceDeclarations, namespaceDeclaration); 41private Diagnostic? AnalyzeNamespace(CodeStyleOption2<NamespaceDeclarationPreference> option, FileScopedNamespaceDeclarationSyntax declaration)
ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs (2)
40var diagnostic = AnalyzeNamespace(context.GetCSharpAnalyzerOptions().NamespaceDeclarations, root, namespaceDeclaration); 45private Diagnostic? AnalyzeNamespace(CodeStyleOption2<NamespaceDeclarationPreference> option, CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax declaration)
CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (2)
106var diagnostic = Diagnostic.Create(
CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
61context.ReportDiagnostic(Diagnostic.Create(Descriptor, directive.GetLocation()));
CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (1)
94context.ReportDiagnostic(Diagnostic.Create(
CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (5)
90private ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, int positionOfFirstReducingNullableDirective, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? possibleNullableImpactIntervalTree) 104using var diagnostics = TemporaryArray<Diagnostic>.Empty; 130diagnostics.Add(Diagnostic.Create(Descriptor, currentOptionsDirective.GetLocation())); 162diagnostics.Add(Diagnostic.Create(Descriptor, currentOptionsDirective.GetLocation())); 305foreach (var diagnostic in diagnostics)
CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
58foreach (var diagnostic in diagnostics)
CSharpTypeStyleDiagnosticAnalyzerBase.cs (1)
76private static Diagnostic CreateDiagnostic(DiagnosticDescriptor descriptor, SyntaxNode declaration, TextSpan diagnosticSpan, ReportDiagnostic severity)
CSharpUnnecessaryImportsProvider.cs (1)
33foreach (var diagnostic in diagnostics)
CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs (1)
43public static bool IsSafe(Diagnostic diagnostic)
CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
248private Diagnostic CreateDiagnostic(Result result, ReportDiagnostic severity)
UseExpressionBodyDiagnosticAnalyzer.cs (2)
77var diagnostic = AnalyzeSyntax(options, context.Node, helper); 87private static Diagnostic? AnalyzeSyntax(
UseExpressionBodyForLambdaDiagnosticAnalyzer.cs (2)
60var diagnostic = AnalyzeSyntax(context.SemanticModel, option, declaration, context.CancellationToken); 67private static Diagnostic? AnalyzeSyntax(
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (167)
AbstractAssignOutParametersCodeFixProvider.cs (2)
96Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 136Document document, ImmutableArray<Diagnostic> diagnostics,
AddInheritdocCodeFixProvider.cs (3)
57foreach (var diagnostic in context.Diagnostics) 89protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 93foreach (var diagnostic in diagnostics)
ArrowExpressionClausePlacementCodeFixProvider.cs (3)
39var diagnostic = context.Diagnostics.First(); 50Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 56foreach (var diagnostic in diagnostics)
ConditionalExpressionPlacementCodeFixProvider.cs (3)
39var diagnostic = context.Diagnostics.First(); 50Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 56foreach (var diagnostic in diagnostics)
ConsecutiveBracePlacementCodeFixProvider.cs (5)
38var diagnostic = context.Diagnostics.First(); 48private static Task<Document> UpdateDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 51public static async Task<Document> FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 57foreach (var diagnostic in diagnostics) 68Diagnostic diagnostic, CancellationToken cancellationToken)
ConstructorInitializerPlacementCodeFixProvider.cs (3)
37var diagnostic = context.Diagnostics.First(); 48Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 54foreach (var diagnostic in diagnostics)
ConvertNamespaceCodeFixProvider.cs (3)
42var diagnostic = context.Diagnostics.First(); 60Document document, ImmutableArray<Diagnostic> diagnostics, 63var diagnostic = diagnostics.First();
ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
56Document document, ImmutableArray<Diagnostic> diagnostics, 60foreach (var diagnostic in diagnostics)
CSharpAddBracesCodeFixProvider.cs (2)
37Document document, ImmutableArray<Diagnostic> diagnostics, 41foreach (var diagnostic in diagnostics)
CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
40var diagnostic = context.Diagnostics.First();
CSharpAddYieldCodeFixProvider.cs (1)
48protected override async Task<CodeAction?> GetCodeFixAsync(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostics, CancellationToken cancellationToken)
CSharpAsAndMemberAccessCodeFixProvider.cs (3)
44Document document, ImmutableArray<Diagnostic> diagnostics, 47foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 53private static void FixOne(SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpAsAndNullCheckCodeFixProvider.cs (3)
41Document document, ImmutableArray<Diagnostic> diagnostics, 52foreach (var diagnostic in diagnostics) 86Diagnostic diagnostic,
CSharpChangeToIEnumerableCodeFixProvider.cs (1)
42protected override async Task<CodeAction?> GetCodeFixAsync(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostics, CancellationToken cancellationToken)
CSharpConvertToAsyncMethodCodeFixProvider.cs (2)
35Diagnostic diagnostic, 50Diagnostic diagnostic,
CSharpDeclareAsNullableCodeFixProvider.cs (3)
98ImmutableArray<Diagnostic> diagnostics, 108foreach (var diagnostic in diagnostics) 115protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, SemanticModel model, string? equivalenceKey, CancellationToken cancellationToken)
CSharpDisambiguateSameVariableCodeFixProvider.cs (4)
46var diagnostic = context.Diagnostics.First(); 57SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken, 139Document document, ImmutableArray<Diagnostic> diagnostics, 145foreach (var diagnostic in diagnostics)
CSharpFixIncorrectConstraintCodeFixProvider.cs (4)
37Diagnostic diagnostic, 73var diagnostic = context.Diagnostics.First(); 83Document document, ImmutableArray<Diagnostic> diagnostics, 89foreach (var diagnostic in diagnostics)
CSharpFixReturnTypeCodeFixProvider.cs (2)
67Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 132protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
CSharpInlineDeclarationCodeFixProvider.cs (3)
51Document document, ImmutableArray<Diagnostic> diagnostics, 59foreach (var diagnostic in diagnostics) 92Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpIsAndCastCheckCodeFixProvider.cs (3)
45Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics) 59Diagnostic diagnostic,
CSharpMakeMemberRequiredCodeFixProvider.cs (2)
107protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 113foreach (var diagnostic in diagnostics)
CSharpMakeMethodAsynchronousCodeFixProvider.cs (1)
40protected override bool IsSupportedDiagnostic(Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpMakeStatementAsynchronousCodeFixProvider.cs (3)
37var diagnostic = context.Diagnostics.First(); 51Document document, ImmutableArray<Diagnostic> diagnostics, 54foreach (var diagnostic in diagnostics)
CSharpMakeStructFieldsWritableCodeFixProvider.cs (2)
41ImmutableArray<Diagnostic> diagnostics, 45foreach (var diagnostic in diagnostics)
CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (1)
42ImmutableArray<Diagnostic> diagnostics,
CSharpMakeStructReadOnlyCodeFixProvider.cs (1)
40ImmutableArray<Diagnostic> diagnostics,
CSharpQualifyMemberAccessCodeFixProvider.cs (1)
25protected override SimpleNameSyntax? GetNode(Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpRemoveConfusingSuppressionCodeFixProvider.cs (2)
62Document document, ImmutableArray<Diagnostic> diagnostics, 71foreach (var diagnostic in diagnostics)
CSharpRemoveUnnecessaryCastCodeFixProvider.cs (1)
46Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (2)
43Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
CSharpRemoveUnnecessaryLambdaExpressionCodeFixProvider.cs (2)
44Document document, ImmutableArray<Diagnostic> diagnostics, 47foreach (var diagnostic in diagnostics)
CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs (3)
37foreach (var diagnostic in context.Diagnostics) 50ImmutableArray<Diagnostic> diagnostics, 55foreach (var diagnostic in diagnostics)
CSharpRemoveUnreachableCodeCodeFixProvider.cs (5)
35var diagnostic = context.Diagnostics[0]; 50protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 53private static bool IsSubsequentSection(Diagnostic diagnostic) 58ImmutableArray<Diagnostic> diagnostics, 62foreach (var diagnostic in diagnostics)
CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (1)
46protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
CSharpSimplifyPropertyPatternCodeFixProvider.cs (1)
44Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpTransposeRecordKeywordCodeFixProvider.cs (4)
36Diagnostic diagnostic, CancellationToken cancellationToken, [NotNullWhen(true)] out RecordDeclarationSyntax? recordDeclaration) 91var diagnostic = context.Diagnostics.First(); 102Document document, ImmutableArray<Diagnostic> diagnostics, 105foreach (var diagnostic in diagnostics)
CSharpUpgradeProjectCodeFixProvider.cs (3)
68public override string SuggestedVersion(ImmutableArray<Diagnostic> diagnostics) 71private static LanguageVersion RequiredVersion(ImmutableArray<Diagnostic> diagnostics) 74foreach (var diagnostic in diagnostics)
CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (2)
45Document document, ImmutableArray<Diagnostic> diagnostics, 53foreach (var diagnostic in diagnostics)
CSharpUseDeconstructionCodeFixProvider.cs (1)
43Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpUseDefaultLiteralCodeFixProvider.cs (1)
40Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpUseImplicitObjectCreationCodeFixProvider.cs (4)
36protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 46Document document, ImmutableArray<Diagnostic> diagnostics, 50foreach (var diagnostic in diagnostics.OrderBy(d => d.Location.SourceSpan.End)) 56private static void FixOne(SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpUseIndexOperatorCodeFixProvider.cs (2)
44Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (3)
47Document document, ImmutableArray<Diagnostic> diagnostics, 50foreach (var diagnostic in diagnostics) 61Diagnostic diagnostic,
CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (4)
38private static bool IsSupportedDiagnostic(Diagnostic diagnostic) 43var diagnostic = context.Diagnostics.First(); 58Document document, ImmutableArray<Diagnostic> diagnostics, 61foreach (var diagnostic in diagnostics)
CSharpUseLocalFunctionCodeFixProvider.cs (3)
45protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 55Document document, ImmutableArray<Diagnostic> diagnostics, 67foreach (var diagnostic in diagnostics)
CSharpUseNameofInAttributeCodeFixProvider.cs (2)
43ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
CSharpUseNotPatternCodeFixProvider.cs (3)
40Document document, ImmutableArray<Diagnostic> diagnostics, 44foreach (var diagnostic in diagnostics) 54Diagnostic diagnostic,
CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (2)
45Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
CSharpUsePatternCombinatorsCodeFixProvider.cs (4)
58Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 66var diagnostic = context.Diagnostics.First(); 79Document document, ImmutableArray<Diagnostic> diagnostics, 83foreach (var diagnostic in diagnostics)
CSharpUseRangeOperatorCodeFixProvider.cs (2)
50Document document, ImmutableArray<Diagnostic> diagnostics, 84private static InvocationExpressionSyntax GetInvocationExpression(Diagnostic d, CancellationToken cancellationToken)
CSharpUseTupleSwapCodeFixProvider.cs (3)
45Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics) 55SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
EmbeddedStatementPlacementCodeFixProvider.cs (4)
38var diagnostic = context.Diagnostics.First(); 48public static async Task<Document> FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider codeActionOptionsProvider, CancellationToken cancellationToken) 57foreach (var diagnostic in diagnostics) 65Diagnostic diagnostic,
HideBaseCodeFixProvider.cs (1)
37var diagnostic = context.Diagnostics.First();
InvokeDelegateWithConditionalAccessCodeFixProvider.cs (6)
38protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 48Document document, ImmutableArray<Diagnostic> diagnostics, 51foreach (var diagnostic in diagnostics) 61SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken) 76Diagnostic diagnostic, 120SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
MakeLocalFunctionStaticCodeFixProvider.cs (1)
38Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
MisplacedUsingDirectivesCodeFixProvider.cs (1)
74foreach (var diagnostic in context.Diagnostics)
PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (3)
37var diagnostic = context.Diagnostics.First(); 56protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 68ImmutableArray<Diagnostic> diagnostics,
RemoveInKeywordCodeFixProvider.cs (1)
42var diagnostic = context.Diagnostics.First();
RemoveNewModifierCodeFixProvider.cs (1)
40var diagnostic = context.Diagnostics.First();
UseExplicitTypeCodeFixProvider.cs (2)
44Document document, ImmutableArray<Diagnostic> diagnostics, 49foreach (var diagnostic in diagnostics)
UseExpressionBodyCodeFixProvider.cs (5)
37protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 43var diagnostic = context.Diagnostics.First(); 56Document document, ImmutableArray<Diagnostic> diagnostics, 62foreach (var diagnostic in diagnostics) 78SemanticModel semanticModel, SyntaxEditor editor, Diagnostic diagnostic,
UseExpressionBodyForLambdaCodeFixProvider.cs (6)
38var diagnostic = context.Diagnostics[0]; 50protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 53private static async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CancellationToken cancellationToken) 56foreach (var diagnostic in diagnostics) 63private static Task<Document> FixWithSyntaxEditorAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 69Diagnostic diagnostic, CancellationToken cancellationToken)
UseImplicitTypeCodeFixProvider.cs (2)
43Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
UseSimpleUsingStatementCodeFixProvider.cs (1)
50Document document, ImmutableArray<Diagnostic> diagnostics,
UseThrowExpressionCodeFixProvider.cs (3)
36protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 46Document document, ImmutableArray<Diagnostic> diagnostics, 52foreach (var diagnostic in diagnostics)
UseUtf8StringLiteralCodeFixProvider.cs (3)
46Document document, ImmutableArray<Diagnostic> diagnostics, 55foreach (var diagnostic in diagnostics) 94private static IArrayCreationOperation GetArrayCreationOperation(SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests (2)
CSharpIsAndCastCheckDiagnosticAnalyzerTests.cs (1)
660var diag = (await GetDiagnosticsAsync(workspace, testParameters)).Single();
RemoveUnnecessaryExpressionParenthesesTests.cs (1)
2887var diagnostic = diagnostics.Single();
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (8)
CommandLineTests.cs (8)
861var diags = new List<Diagnostic>(); 1860IEnumerable<Diagnostic> diagnostics; 2780var err = parsedArgs.Errors.Single(); 6266var diagnostics = new List<Diagnostic>(); 14615context.ReportDiagnostic(Diagnostic.Create(Hidden01, context.Node.GetLocation())); 14641context.ReportDiagnostic(Diagnostic.Create(Info01, context.Node.GetLocation())); 14669symbolContext.ReportDiagnostic(Diagnostic.Create(Warning01, symbolContext.Symbol.Locations.First())); 14696nodeContext.ReportDiagnostic(Diagnostic.Create(Error01, nodeContext.Node.GetLocation()));
Microsoft.CodeAnalysis.CSharp.EditorFeatures (4)
StringCopyPaste\StringCopyPasteHelpers.cs (4)
46using var _ = PooledHashSet<Diagnostic>.GetInstance(out var errors); 47foreach (var diagnostic in interpolatedString.GetDiagnostics()) 58foreach (var diagnostic in text.GetDiagnostics()) 71foreach (var diagnostic in nodeOrToken.GetDiagnostics())
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (39)
CSharpIsAndCastCheckDiagnosticAnalyzerTests.cs (1)
660var diag = (await GetDiagnosticsAsync(workspace, testParameters)).Single();
Diagnostics\Configuration\ConfigureSeverity\AllAnalyzersSeverityConfigurationTests.cs (1)
39c => c.ReportDiagnostic(Diagnostic.Create(Rule, c.Node.GetLocation())),
Diagnostics\Configuration\ConfigureSeverity\CategoryBasedSeverityConfigurationTests.cs (1)
39c => c.ReportDiagnostic(Diagnostic.Create(Rule, c.Node.GetLocation())),
Diagnostics\Configuration\ConfigureSeverity\DotNetDiagnosticSeverityBasedSeverityConfigurationTests.cs (1)
39c => c.ReportDiagnostic(Diagnostic.Create(Rule, c.Node.GetLocation())),
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (6)
237=> context.ReportDiagnostic(Diagnostic.Create(s_syntaxDiagnosticDescriptor, context.Tree.GetRoot().GetFirstToken().GetLocation())); 327context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Node.GetLocation())); 356=> context.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.Create(context.Tree, TextSpan.FromBounds(1000, 2000)))); 880var diagnostic = Diagnostic.Create(descriptor, context.Symbol.Locations[0]); 933foreach (var diagnostic in context.ReportedDiagnostics)
Diagnostics\FixAllProvider\BatchFixerTests.cs (2)
54var diagnostic = Diagnostic.Create(Descriptor, node.GetLocation());
Diagnostics\Suppression\RemoveSuppressionTests.cs (1)
50context.ReportDiagnostic(Diagnostic.Create(Decsciptor, location));
Diagnostics\Suppression\RemoveUnnecessaryPragmaSuppressionsTests.cs (3)
106context.ReportDiagnostic(Diagnostic.Create(rule, local.Locations[0])); 1310var diagnostic = Diagnostic.Create(Descriptor, context.Symbol.ContainingNamespace.Locations[0]);
Diagnostics\Suppression\SuppressionTest_FixMultipleTests.cs (2)
52context.ReportDiagnostic(Diagnostic.Create(Decsciptor1, location)); 53context.ReportDiagnostic(Diagnostic.Create(Decsciptor2, location));
Diagnostics\Suppression\SuppressionTests.cs (15)
712context.ReportDiagnostic(Diagnostic.Create(Decsciptor, classDecl.Identifier.GetLocation())); 822context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())); 885context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())); 935context.ReportDiagnostic(Diagnostic.Create(Decsciptor, classDecl.GetLocation())); 1079context.ReportDiagnostic(Diagnostic.Create(Descriptor, classDecl.Identifier.GetLocation())); 1084context.ReportDiagnostic(Diagnostic.Create(Descriptor, ns.Name.GetLocation())); 1089context.ReportDiagnostic(Diagnostic.Create(Descriptor, method.Identifier.GetLocation())); 1094context.ReportDiagnostic(Diagnostic.Create(Descriptor, property.Identifier.GetLocation())); 1099context.ReportDiagnostic(Diagnostic.Create(Descriptor, field.Declaration.Variables.First().Identifier.GetLocation())); 1104context.ReportDiagnostic(Diagnostic.Create(Descriptor, e.Identifier.GetLocation())); 1111context.ReportDiagnostic(Diagnostic.Create(Descriptor, trivia.GetLocation())); 2073context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())); 2078context.ReportDiagnostic(Diagnostic.Create(_descriptor, ns.Name.GetLocation())); 2083context.ReportDiagnostic(Diagnostic.Create(_descriptor, method.Identifier.GetLocation())); 2464=> context.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None));
Formatting\CodeCleanupTests.TestFixers.cs (3)
25foreach (var diagnostic in context.Diagnostics) 101foreach (var diagnostic in diagnostics) 157foreach (var diagnostic in diagnostics)
RemoveUnnecessaryExpressionParenthesesTests.cs (1)
2887var diagnostic = diagnostics.Single();
Semantics\SpeculationAnalyzerTests.cs (1)
519static bool isProblem(Diagnostic d) => d.Severity >= DiagnosticSeverity.Warning;
Squiggles\ErrorSquiggleProducerTests.cs (1)
433context.ReportDiagnostic(Diagnostic.Create(Rule, context.Symbol.Locations.First()));
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (4)
CodeGen\CodeGenOperators.cs (1)
5261var diagnostics = ImmutableArray<Diagnostic>.Empty;
Emit\CompilationEmitTests.cs (1)
5209var err = result.Diagnostics.Single();
Emit\DynamicAnalysis\DynamicInstrumentationTests.cs (2)
2450ImmutableArray<Diagnostic> diagnostics = CreateEmptyCompilation(source + InstrumentationHelperSource).GetEmitDiagnostics(EmitOptions.Default.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage))); 2451foreach (Diagnostic diagnostic in diagnostics)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (108)
Attributes\AttributeTests_WellKnownAttributes.cs (15)
8211var diag = diags.Single(); 8244var diag = diags.Single(); 8275var diag = diags.Single(); 8306var diag = diags.Single(); 8377var diag = diags.Single(); 8425var diag = diags.Last(); 8622var diag = diags.Single(); 8665var diag = diags.Single(); 8767var diag = diags.Single(); 8869var diag = diags.Single(); 9052var diag = diags.Single(); 9103var diag = diags.Single(); 9244var diag = diags.Single(); 9382var diag = diags.Single(); 9432var diag = diags.Single();
Attributes\InternalsVisibleToAndStrongNameTests.cs (2)
360var err = other.GetDiagnostics().Single(); 1558var err = other.GetDiagnostics().Single();
Diagnostics\DiagnosticAnalyzerTests.cs (63)
57context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_CA9999_UseOfVariableThatStartsWithX, id.Location, id.Identifier.ValueText)); 253var diag1 = CodeAnalysis.Diagnostic.Create(s_descriptor, context.Node.GetLocation(), "Attribute"); 258var diag2 = CodeAnalysis.Diagnostic.Create(s_descriptor, context.Node.GetLocation(), "ClassDeclaration"); 263var diag3 = CodeAnalysis.Diagnostic.Create(s_descriptor, context.Node.GetLocation(), "UsingDirective"); 271var diag1 = CodeAnalysis.Diagnostic.Create(s_descriptor, context.Symbol.Locations[0], "NamedType"); 307var noneDiag = CodeAnalysis.Diagnostic.Create(noneDiagDescriptor, Location.None); 308var infoDiag = CodeAnalysis.Diagnostic.Create(infoDiagDescriptor, Location.None); 309var warningDiag = CodeAnalysis.Diagnostic.Create(warningDiagDescriptor, Location.None); 310var errorDiag = CodeAnalysis.Diagnostic.Create(errorDiagDescriptor, Location.None); 324foreach (var effectiveDiag in effectiveDiags) 353foreach (var effectiveDiag in effectiveDiags) 391var noneDiag = Microsoft.CodeAnalysis.Diagnostic.Create(noneDiagDescriptor, Location.None); 392var infoDiag = Microsoft.CodeAnalysis.Diagnostic.Create(infoDiagDescriptor, Location.None); 393var warningDiag = Microsoft.CodeAnalysis.Diagnostic.Create(warningDiagDescriptor, Location.None); 394var errorDiag = Microsoft.CodeAnalysis.Diagnostic.Create(errorDiagDescriptor, Location.None); 444var disabledDiag = CodeAnalysis.Diagnostic.Create(disabledDiagDescriptor, Location.None); 445var enabledDiag = CodeAnalysis.Diagnostic.Create(enabledDiagDescriptor, Location.None); 667var diagnostic = CodeAnalysis.Diagnostic.Create(Rule, fieldDeclaration.GetLocation()); 783context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor1, Location.None)); 798registerSyntaxNodeAction(context => { context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor2, Location.None)); }, 801registerSyntaxNodeAction(context => { context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor3, Location.None)); }, 820context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(descriptor, Location.None)); 840ctxt.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor1, method.Locations[0], method.ToDisplayString())); 894compilationContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(UnsupportedDescriptor, Location.None)); 1654nodeContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(ExpressionDescriptor, nodeContext.Node.GetLocation())); 2335var diagnostic = CodeAnalysis.Diagnostic.Create(Summary, Location.None, sortedCallbackEntityNames.Join(",")); 2340private void ReportNodeDiagnostics(SyntaxNode node, Action<Diagnostic> addDiagnostic) 2345private void ReportOperationDiagnostics(IOperation operation, string name, Action<Diagnostic> addDiagnostic) 2350private void ReportDiagnosticsCore(Action<Diagnostic> addDiagnostic, Location location, params object[] messageArguments) 2353var diagnostic = CodeAnalysis.Diagnostic.Create(Warning, location, messageArguments); 3619var diagnostics = diagnosticsMap.TryGetValue(tree1, out var value) ? value : ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>.Empty; 3626var diagnostic = Assert.Single(diagnostics[analyzer]); 3758context => context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Rule, context.Node.GetLocation())), 3764context => context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Rule, context.Node.GetLocation())), 3771context => context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Rule, context.Operation.Syntax.GetLocation())), 3777context => context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Rule, context.Operation.Syntax.GetLocation())), 3808void verifyDiagnostics(ImmutableArray<Diagnostic> diagnostics) 3810var diagnostic = Assert.Single(diagnostics); 3864ImmutableArray<Diagnostic> diagnostics, 3886foreach (var diagnostic in applicableDiagnostics) 3929static ImmutableArray<Diagnostic> getReportedDiagnostics(AnalysisResult analysisResult, DiagnosticAnalyzer analyzer, AdditionalText additionalFile) 3937return ImmutableArray<Diagnostic>.Empty; 3995var diagnostic = CodeAnalysis.Diagnostic.Create(Rule, recordDeclaration.GetLocation()); 4096var diagnostic = Assert.Single(diagnostics); 4099async Task<ImmutableArray<Diagnostic>> getDiagnosticsAsync(CancellationToken cancellationToken)
Diagnostics\GetDiagnosticsTests.cs (16)
117var diag = compilation.GetDiagnostics().Single(); 122var error = diag.WithSeverity(DiagnosticSeverity.Error); 127var warning = error.WithSeverity(DiagnosticSeverity.Warning); 132var hidden = diag.WithSeverity(DiagnosticSeverity.Hidden); 137var info = diag.WithSeverity(DiagnosticSeverity.Info); 506static void verifyDiagnostics(ImmutableArray<Diagnostic> diagnostics) 511var diagnostic = diagnostics.Single(); 559var diagnostic = analyzerDiagnostics.Single(); 696var diagnostic = Assert.Single(diagnostics); 910blockEndContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(DescriptorForBlockEnd, blockEndContext.CodeBlock.GetLocation())); 929blockEndContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(DescriptorForBlockEnd, operationBlock.Syntax.GetLocation())); 950static void analyzeNode(SyntaxNode node, ISymbol containingSymbol, Action<Diagnostic> reportDiagnostic) 979reportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor, location, containingSymbol.Name)); 1048var compilationDiagnostic = compilationDiagnostics.Single(); 1053var analyzerDiagnostic = analyzerDiagnostics.Single(); 1089foreach (var diagnostic in context.ReportedDiagnostics)
FlowAnalysis\FlowDiagnosticTests.cs (4)
155foreach (var e in this.FlowDiagnostics(comp)) 183foreach (var e in this.FlowDiagnostics(comp)) 352foreach (var e in this.FlowDiagnostics(comp)) 384foreach (var e in this.FlowDiagnostics(comp))
FlowAnalysis\FlowTestBase.cs (1)
20internal ImmutableArray<Diagnostic> FlowDiagnostics(CSharpCompilation compilation)
FlowAnalysis\StructTests.cs (7)
270options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 277options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 339CreateCompilation(source2, references: new MetadataReference[] { sourceReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics( 341CreateCompilation(source2, references: new MetadataReference[] { metadataReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics( 384CreateCompilation(source2, references: new MetadataReference[] { sourceReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics( 386CreateCompilation(source2, references: new MetadataReference[] { metadataReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics( 504CreateCompilation(source2, references: new MetadataReference[] { moduleReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics(
Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler (2)
EvaluationContext.cs (2)
449internal override bool HasDuplicateTypesOrAssemblies(Diagnostic diagnostic) 463internal override ImmutableArray<AssemblyIdentity> GetMissingAssemblyIdentities(Diagnostic diagnostic, AssemblyIdentity linqLibrary)
Microsoft.CodeAnalysis.CSharp.Features (213)
AbstractAssignOutParametersCodeFixProvider.cs (2)
96Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 136Document document, ImmutableArray<Diagnostic> diagnostics,
AddInheritdocCodeFixProvider.cs (3)
57foreach (var diagnostic in context.Diagnostics) 89protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 93foreach (var diagnostic in diagnostics)
ArrowExpressionClausePlacementCodeFixProvider.cs (3)
39var diagnostic = context.Diagnostics.First(); 50Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 56foreach (var diagnostic in diagnostics)
CodeFixes\GenerateEnumMember\GenerateEnumMemberCodeFixProvider.cs (1)
42protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
CodeFixes\GenerateMethod\GenerateConversionCodeFixProvider.cs (1)
39protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs (1)
73protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
CodeFixes\GenerateType\GenerateTypeCodeFixProvider.cs (1)
46protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (7)
35protected override SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken) 42Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken) 49SyntaxToken disableOrRestoreKeyword, Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken) 101Diagnostic diagnostic, 128SyntaxNode targetNode, ISymbol targetSymbol, INamedTypeSymbol suppressMessageAttribute, Diagnostic diagnostic) 152Diagnostic diagnostic, 175private static AttributeArgumentListSyntax CreateAttributeArguments(ISymbol targetSymbol, Diagnostic diagnostic, bool isAssemblyAttribute)
ConditionalExpressionPlacementCodeFixProvider.cs (3)
39var diagnostic = context.Diagnostics.First(); 50Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 56foreach (var diagnostic in diagnostics)
ConsecutiveBracePlacementCodeFixProvider.cs (5)
38var diagnostic = context.Diagnostics.First(); 48private static Task<Document> UpdateDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 51public static async Task<Document> FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 57foreach (var diagnostic in diagnostics) 68Diagnostic diagnostic, CancellationToken cancellationToken)
ConstructorInitializerPlacementCodeFixProvider.cs (3)
37var diagnostic = context.Diagnostics.First(); 48Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 54foreach (var diagnostic in diagnostics)
ConvertNamespaceCodeFixProvider.cs (3)
42var diagnostic = context.Diagnostics.First(); 60Document document, ImmutableArray<Diagnostic> diagnostics, 63var diagnostic = diagnostics.First();
ConvertProgram\ConvertToProgramMainCodeFixProvider.cs (1)
48Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
ConvertProgram\ConvertToTopLevelStatementsCodeFixProvider.cs (1)
50Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
56Document document, ImmutableArray<Diagnostic> diagnostics, 60foreach (var diagnostic in diagnostics)
ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs (2)
36var diagnostic = AnalyzeNamespace(context.GetCSharpAnalyzerOptions().NamespaceDeclarations, namespaceDeclaration); 41private Diagnostic? AnalyzeNamespace(CodeStyleOption2<NamespaceDeclarationPreference> option, FileScopedNamespaceDeclarationSyntax declaration)
ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs (2)
40var diagnostic = AnalyzeNamespace(context.GetCSharpAnalyzerOptions().NamespaceDeclarations, root, namespaceDeclaration); 45private Diagnostic? AnalyzeNamespace(CodeStyleOption2<NamespaceDeclarationPreference> option, CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax declaration)
CSharpAddBracesCodeFixProvider.cs (2)
37Document document, ImmutableArray<Diagnostic> diagnostics, 41foreach (var diagnostic in diagnostics)
CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
40var diagnostic = context.Diagnostics.First();
CSharpAddYieldCodeFixProvider.cs (1)
48protected override async Task<CodeAction?> GetCodeFixAsync(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostics, CancellationToken cancellationToken)
CSharpAsAndMemberAccessCodeFixProvider.cs (3)
44Document document, ImmutableArray<Diagnostic> diagnostics, 47foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 53private static void FixOne(SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpAsAndNullCheckCodeFixProvider.cs (3)
41Document document, ImmutableArray<Diagnostic> diagnostics, 52foreach (var diagnostic in diagnostics) 86Diagnostic diagnostic,
CSharpChangeToIEnumerableCodeFixProvider.cs (1)
42protected override async Task<CodeAction?> GetCodeFixAsync(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostics, CancellationToken cancellationToken)
CSharpConvertToAsyncMethodCodeFixProvider.cs (2)
35Diagnostic diagnostic, 50Diagnostic diagnostic,
CSharpDeclareAsNullableCodeFixProvider.cs (3)
98ImmutableArray<Diagnostic> diagnostics, 108foreach (var diagnostic in diagnostics) 115protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, SemanticModel model, string? equivalenceKey, CancellationToken cancellationToken)
CSharpDisambiguateSameVariableCodeFixProvider.cs (4)
46var diagnostic = context.Diagnostics.First(); 57SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken, 139Document document, ImmutableArray<Diagnostic> diagnostics, 145foreach (var diagnostic in diagnostics)
CSharpFixIncorrectConstraintCodeFixProvider.cs (4)
37Diagnostic diagnostic, 73var diagnostic = context.Diagnostics.First(); 83Document document, ImmutableArray<Diagnostic> diagnostics, 89foreach (var diagnostic in diagnostics)
CSharpFixReturnTypeCodeFixProvider.cs (2)
67Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 132protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
CSharpInlineDeclarationCodeFixProvider.cs (3)
51Document document, ImmutableArray<Diagnostic> diagnostics, 59foreach (var diagnostic in diagnostics) 92Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpIsAndCastCheckCodeFixProvider.cs (3)
45Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics) 59Diagnostic diagnostic,
CSharpMakeMemberRequiredCodeFixProvider.cs (2)
107protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 113foreach (var diagnostic in diagnostics)
CSharpMakeMethodAsynchronousCodeFixProvider.cs (1)
40protected override bool IsSupportedDiagnostic(Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpMakeStatementAsynchronousCodeFixProvider.cs (3)
37var diagnostic = context.Diagnostics.First(); 51Document document, ImmutableArray<Diagnostic> diagnostics, 54foreach (var diagnostic in diagnostics)
CSharpMakeStructFieldsWritableCodeFixProvider.cs (2)
41ImmutableArray<Diagnostic> diagnostics, 45foreach (var diagnostic in diagnostics)
CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (2)
106var diagnostic = Diagnostic.Create(
CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (1)
42ImmutableArray<Diagnostic> diagnostics,
CSharpMakeStructReadOnlyCodeFixProvider.cs (1)
40ImmutableArray<Diagnostic> diagnostics,
CSharpQualifyMemberAccessCodeFixProvider.cs (1)
25protected override SimpleNameSyntax? GetNode(Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpRemoveConfusingSuppressionCodeFixProvider.cs (2)
62Document document, ImmutableArray<Diagnostic> diagnostics, 71foreach (var diagnostic in diagnostics)
CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
61context.ReportDiagnostic(Diagnostic.Create(Descriptor, directive.GetLocation()));
CSharpRemoveUnnecessaryCastCodeFixProvider.cs (1)
46Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (2)
43Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (1)
94context.ReportDiagnostic(Diagnostic.Create(
CSharpRemoveUnnecessaryLambdaExpressionCodeFixProvider.cs (2)
44Document document, ImmutableArray<Diagnostic> diagnostics, 47foreach (var diagnostic in diagnostics)
CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs (3)
37foreach (var diagnostic in context.Diagnostics) 50ImmutableArray<Diagnostic> diagnostics, 55foreach (var diagnostic in diagnostics)
CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (5)
90private ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, int positionOfFirstReducingNullableDirective, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? possibleNullableImpactIntervalTree) 104using var diagnostics = TemporaryArray<Diagnostic>.Empty; 130diagnostics.Add(Diagnostic.Create(Descriptor, currentOptionsDirective.GetLocation())); 162diagnostics.Add(Diagnostic.Create(Descriptor, currentOptionsDirective.GetLocation())); 305foreach (var diagnostic in diagnostics)
CSharpRemoveUnreachableCodeCodeFixProvider.cs (5)
35var diagnostic = context.Diagnostics[0]; 50protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 53private static bool IsSubsequentSection(Diagnostic diagnostic) 58ImmutableArray<Diagnostic> diagnostics, 62foreach (var diagnostic in diagnostics)
CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
58foreach (var diagnostic in diagnostics)
CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (1)
46protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
CSharpSimplifyPropertyPatternCodeFixProvider.cs (1)
44Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpTransposeRecordKeywordCodeFixProvider.cs (4)
36Diagnostic diagnostic, CancellationToken cancellationToken, [NotNullWhen(true)] out RecordDeclarationSyntax? recordDeclaration) 91var diagnostic = context.Diagnostics.First(); 102Document document, ImmutableArray<Diagnostic> diagnostics, 105foreach (var diagnostic in diagnostics)
CSharpTypeStyleDiagnosticAnalyzerBase.cs (1)
76private static Diagnostic CreateDiagnostic(DiagnosticDescriptor descriptor, SyntaxNode declaration, TextSpan diagnosticSpan, ReportDiagnostic severity)
CSharpUpgradeProjectCodeFixProvider.cs (3)
68public override string SuggestedVersion(ImmutableArray<Diagnostic> diagnostics) 71private static LanguageVersion RequiredVersion(ImmutableArray<Diagnostic> diagnostics) 74foreach (var diagnostic in diagnostics)
CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (2)
45Document document, ImmutableArray<Diagnostic> diagnostics, 53foreach (var diagnostic in diagnostics)
CSharpUseDeconstructionCodeFixProvider.cs (1)
43Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpUseDefaultLiteralCodeFixProvider.cs (1)
40Document document, ImmutableArray<Diagnostic> diagnostics,
CSharpUseImplicitObjectCreationCodeFixProvider.cs (4)
36protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 46Document document, ImmutableArray<Diagnostic> diagnostics, 50foreach (var diagnostic in diagnostics.OrderBy(d => d.Location.SourceSpan.End)) 56private static void FixOne(SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
CSharpUseIndexOperatorCodeFixProvider.cs (2)
44Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (3)
47Document document, ImmutableArray<Diagnostic> diagnostics, 50foreach (var diagnostic in diagnostics) 61Diagnostic diagnostic,
CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (4)
38private static bool IsSupportedDiagnostic(Diagnostic diagnostic) 43var diagnostic = context.Diagnostics.First(); 58Document document, ImmutableArray<Diagnostic> diagnostics, 61foreach (var diagnostic in diagnostics)
CSharpUseLocalFunctionCodeFixProvider.cs (3)
45protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 55Document document, ImmutableArray<Diagnostic> diagnostics, 67foreach (var diagnostic in diagnostics)
CSharpUseNameofInAttributeCodeFixProvider.cs (2)
43ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
CSharpUseNotPatternCodeFixProvider.cs (3)
40Document document, ImmutableArray<Diagnostic> diagnostics, 44foreach (var diagnostic in diagnostics) 54Diagnostic diagnostic,
CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (2)
45Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
CSharpUsePatternCombinatorsCodeFixProvider.cs (4)
58Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 66var diagnostic = context.Diagnostics.First(); 79Document document, ImmutableArray<Diagnostic> diagnostics, 83foreach (var diagnostic in diagnostics)
CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs (1)
43public static bool IsSafe(Diagnostic diagnostic)
CSharpUseRangeOperatorCodeFixProvider.cs (2)
50Document document, ImmutableArray<Diagnostic> diagnostics, 84private static InvocationExpressionSyntax GetInvocationExpression(Diagnostic d, CancellationToken cancellationToken)
CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
248private Diagnostic CreateDiagnostic(Result result, ReportDiagnostic severity)
CSharpUseTupleSwapCodeFixProvider.cs (3)
45Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics) 55SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
Diagnostics\Analyzers\CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs (2)
50protected override ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context) 61protected override ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree)
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.cs (6)
50private ImmutableArray<Diagnostic>.Builder? _diagnostics; 62public ImmutableArray<Diagnostic> Diagnostics => _diagnostics?.ToImmutable() ?? ImmutableArray<Diagnostic>.Empty; 64public ImmutableArray<Diagnostic>.Builder DiagnosticsBuilder 69Interlocked.CompareExchange(ref _diagnostics, ImmutableArray.CreateBuilder<Diagnostic>(), null); 290if (!_analyzer.TrySimplify(_semanticModel, node, out var diagnostic, _options, _cancellationToken))
EmbeddedStatementPlacementCodeFixProvider.cs (4)
38var diagnostic = context.Diagnostics.First(); 48public static async Task<Document> FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider codeActionOptionsProvider, CancellationToken cancellationToken) 57foreach (var diagnostic in diagnostics) 65Diagnostic diagnostic,
GenerateConstructor\GenerateConstructorCodeFixProvider.cs (1)
55protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
GenerateVariable\CSharpGenerateVariableCodeFixProvider.cs (1)
44protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
HideBaseCodeFixProvider.cs (1)
37var diagnostic = context.Diagnostics.First();
InvokeDelegateWithConditionalAccessCodeFixProvider.cs (6)
38protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 48Document document, ImmutableArray<Diagnostic> diagnostics, 51foreach (var diagnostic in diagnostics) 61SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken) 76Diagnostic diagnostic, 120SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken)
MakeLocalFunctionStaticCodeFixProvider.cs (1)
38Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
MisplacedUsingDirectivesCodeFixProvider.cs (1)
74foreach (var diagnostic in context.Diagnostics)
PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (3)
37var diagnostic = context.Diagnostics.First(); 56protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 68ImmutableArray<Diagnostic> diagnostics,
RemoveInKeywordCodeFixProvider.cs (1)
42var diagnostic = context.Diagnostics.First();
RemoveNewModifierCodeFixProvider.cs (1)
40var diagnostic = context.Diagnostics.First();
StringIndentation\CSharpStringIndentationService.cs (1)
108foreach (var error in errors)
UseExplicitTypeCodeFixProvider.cs (2)
44Document document, ImmutableArray<Diagnostic> diagnostics, 49foreach (var diagnostic in diagnostics)
UseExpressionBodyCodeFixProvider.cs (5)
37protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 43var diagnostic = context.Diagnostics.First(); 56Document document, ImmutableArray<Diagnostic> diagnostics, 62foreach (var diagnostic in diagnostics) 78SemanticModel semanticModel, SyntaxEditor editor, Diagnostic diagnostic,
UseExpressionBodyDiagnosticAnalyzer.cs (2)
77var diagnostic = AnalyzeSyntax(options, context.Node, helper); 87private static Diagnostic? AnalyzeSyntax(
UseExpressionBodyForLambdaCodeFixProvider.cs (6)
38var diagnostic = context.Diagnostics[0]; 50protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 53private static async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CancellationToken cancellationToken) 56foreach (var diagnostic in diagnostics) 63private static Task<Document> FixWithSyntaxEditorAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 69Diagnostic diagnostic, CancellationToken cancellationToken)
UseExpressionBodyForLambdaDiagnosticAnalyzer.cs (2)
60var diagnostic = AnalyzeSyntax(context.SemanticModel, option, declaration, context.CancellationToken); 67private static Diagnostic? AnalyzeSyntax(
UseImplicitTypeCodeFixProvider.cs (2)
43Document document, ImmutableArray<Diagnostic> diagnostics, 48foreach (var diagnostic in diagnostics)
UsePatternMatching\CSharpIsAndCastCheckWithoutNameCodeFixProvider.cs (1)
51Document document, ImmutableArray<Diagnostic> diagnostics,
UseSimpleUsingStatementCodeFixProvider.cs (1)
50Document document, ImmutableArray<Diagnostic> diagnostics,
UseThrowExpressionCodeFixProvider.cs (3)
36protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 46Document document, ImmutableArray<Diagnostic> diagnostics, 52foreach (var diagnostic in diagnostics)
UseUtf8StringLiteralCodeFixProvider.cs (3)
46Document document, ImmutableArray<Diagnostic> diagnostics, 55foreach (var diagnostic in diagnostics) 94private static IArrayCreationOperation GetArrayCreationOperation(SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (41)
Semantics\MethodBodyModelTests.cs (1)
127foreach (var e in comp.GetDiagnostics())
Semantics\NullableReferenceTypesTests.cs (2)
108768foreach (var diagnostic in diagnostics) 153478var reportedDiagnostics = new HashSet<Diagnostic>();
Semantics\PrimaryConstructorTests.cs (1)
7234var diagnosticsToCheck = (IEnumerable<Diagnostic>)comp.GetEmitDiagnostics();
Semantics\QueryTests.cs (1)
1658foreach (var dd in compilation.GetDiagnostics()) Console.WriteLine(dd);
Semantics\UninitializedNonNullableFieldTests.cs (1)
2805var diagnostic = Assert.Single(diagnostics);
Semantics\UseSiteErrorTests.cs (2)
1227foreach (var diag in compilation.GetDiagnostics()) 2435foreach (var diagnostic in diagnostics)
Semantics\WarningVersionTests.cs (12)
48CreateCompilation(source, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics(); 78CreateCompilation(source, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics(); 117CreateCompilation(source, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics(); 157options: TestOptions.DebugDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 235options: TestOptions.DebugDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 321options: TestOptions.DebugDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 392CreateCompilation(source2, references: new MetadataReference[] { moduleReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics( 445options: TestOptions.DebugDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 532options: TestOptions.DebugDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 619options: TestOptions.DebugDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel), 683CreateCompilation(source2, references: new MetadataReference[] { moduleReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics( 713CreateCompilation(source2, references: new MetadataReference[] { moduleReference }, options: TestOptions.ReleaseDll.WithWarningLevel(CodeAnalysis.Diagnostic.DefaultWarningLevel)).VerifyDiagnostics(
SourceGeneration\GeneratorDriverTests.cs (21)
446var diagnostic = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic, Location.None); 658var diagnostic1 = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic1, Location.None); 659var diagnostic2 = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic2, Location.None); 660var diagnostic3 = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic3, Location.None); 705var diagnostic1 = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic1, Location.None); 706var diagnostic2 = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic2, Location.None); 707var diagnostic3 = Microsoft.CodeAnalysis.Diagnostic.Create(generatorDiagnostic3, Location.None); 1215var gen001 = CSDiagnostic.Create("GEN001", "generators", "message", DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 2); 1253void verifyDiagnosticsWithSource(string source, (Diagnostic, TextSpan)[] reportDiagnostics, params DiagnosticDescription[] expected) 1263foreach ((var d, var l) in reportDiagnostics) 1286var gen001 = CSDiagnostic.Create("GEN001", "generators", "message", DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 2); 1333static void verify(string source, IReadOnlyList<(Diagnostic Diagnostic, string Location)> reportDiagnostics, params DiagnosticDescription[] expected) 1354foreach (var d in actualDiagnostics) 3042var diag = Assert.Single(result.Diagnostics);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (7)
Compilation\CSharpCompilationOptionsTests.cs (1)
194Assert.Equal(CodeAnalysis.Diagnostic.DefaultWarningLevel, defaultWarnings.WarningLevel);
Symbols\Retargeting\RetargetExplicitInterfaceImplementation.cs (1)
358foreach (var diag in comp1.GetDiagnostics())
Symbols\Source\FieldTests.cs (1)
103var one = errors.Single();
Symbols\Source\NullablePublicAPITests.cs (2)
1169syntaxContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_descriptor1, syntaxContext.Node.GetLocation(), syntaxContext.Node, info.Nullability.FlowState, info.Nullability.Annotation, specInfo.Nullability.FlowState)); 1177context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_descriptor2, declarator.GetLocation(), declaredSymbol.Name, declaredSymbol.NullableAnnotation));
Symbols\Source\PropertyTests.cs (1)
1933var one = errors.Single();
Symbols\SymbolDistinguisherTests.cs (1)
751foreach (var diagnostic in diagnostics)
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (17)
Diagnostics\LocationsTests.cs (10)
313var diag = diags.First(); 376var diag = diags.First(); 397foreach (var diag in diags) 462foreach (var diag in expressionDiags) 505var diagnostic = CodeAnalysis.Diagnostic.Create("CS0000", "", "msg", DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1, location: location); 523var diagnosticWithoutMapping = CodeAnalysis.Diagnostic.Create("CS0000", "", "msg", DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1, location: locationWithoutMapping); 526var diagnosticWithMapping = CodeAnalysis.Diagnostic.Create("CS0000", "", "msg", DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1, location: locationWithMapping);
LexicalAndXml\PreprocessorTests.cs (2)
3215var error = tree.GetDiagnostics().Single(); 3875var diagnostic = tree.GetDiagnostics().Single();
Parsing\ParserErrorMessageTests.cs (1)
2632var error = parsedTree.GetDiagnostics().Single();
Parsing\ParserRegressionTests.cs (2)
226IEnumerable<Diagnostic> actualErrors = parsedTree.GetDiagnostics(); 244IEnumerable<Diagnostic> actualErrors = parsedTree.GetDiagnostics();
Syntax\SyntaxNodeTests.cs (2)
3346foreach (var e in syntaxTree.GetDiagnostics(t)) 3390foreach (var diag in tree.GetDiagnostics(trivia))
Microsoft.CodeAnalysis.CSharp.Test.Utilities (4)
CSharpTestBase.cs (1)
1308static bool shouldCompare(Diagnostic d)
DiagnosticTestUtilities.cs (2)
96public static void VerifyErrorCodes(IEnumerable<Diagnostic> actualErrors, params ErrorDescription[] expectedErrorDesp) 170public static void VerifyErrorCodesNoLineColumn(IEnumerable<Diagnostic> actualErrors, params ErrorDescription[] expectedErrorDesp)
TestOptions.cs (1)
184=> new CSharpCompilationOptions(outputKind, optimizationLevel: optimizationLevel, warningLevel: Diagnostic.MaxWarningLevel, allowUnsafe: allowUnsafe);
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
CSharpUnnecessaryImportsProvider.cs (1)
33foreach (var diagnostic in diagnostics)
Simplification\CSharpSimplificationService.cs (1)
192foreach (var diagnostic in diagnostics)
Microsoft.CodeAnalysis.EditorFeatures (8)
EditAndContinue\EditAndContinueDiagnosticAnalyzer.cs (8)
40public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 41=> SpecializedTasks.EmptyImmutableArray<Diagnostic>(); 43public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 47return SpecializedTasks.EmptyImmutableArray<Diagnostic>(); 54private static async Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsImplAsync(Document designTimeDocument, CancellationToken cancellationToken) 60return ImmutableArray<Diagnostic>.Empty; 66return ImmutableArray<Diagnostic>.Empty; 75return ImmutableArray<Diagnostic>.Empty;
Microsoft.CodeAnalysis.EditorFeatures.Cocoa (4)
FixAllCodeFixSuggestedAction.cs (2)
22public Diagnostic Diagnostic { get; } 31Diagnostic diagnostic,
FixMultipleOccurrencesService.cs (2)
37ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, 56ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix,
Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities (56)
ChangeSignature\AbstractChangeSignatureTests.cs (1)
152private static string CreateDiagnosticsString(ImmutableArray<Diagnostic> diagnostics, AddedParameterOrExistingIndex[] permutation, Document document, int? totalParameters, string fileContents)
CodeActions\AbstractCodeActionOrUserDiagnosticTest.cs (9)
314protected abstract Task<ImmutableArray<Diagnostic>> GetDiagnosticsWorkerAsync( 476ImmutableArray<Diagnostic> diagnostics, 498static IEnumerable<Location> GetUnnecessaryLocations(Diagnostic diagnostic) 517ImmutableArray<Diagnostic> diagnosticsWithTag) 527foreach (var diagnostic in diagnosticsWithTag) 802var diagnosticsAndEquivalenceKeyToTitleMap = new Dictionary<(Diagnostic diagnostic, string equivalenceKey), string>(); 812ImmutableArray<Diagnostic> diagnostics, 814Dictionary<(Diagnostic diagnostic, string equivalenceKey), string> diagnosticsAndEquivalenceKeyToTitleMap) 827foreach (var diagnostic in diagnostics)
CodeActions\AbstractCodeActionTest.cs (2)
92protected override Task<ImmutableArray<Diagnostic>> GetDiagnosticsWorkerAsync(TestWorkspace workspace, TestParameters parameters) 93=> SpecializedTasks.EmptyImmutableArray<Diagnostic>();
CodeActions\CSharpCodeFixVerifier`2+Test.cs (6)
80public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; } 111protected override CodeFixContext CreateCodeFixContext(Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, CancellationToken cancellationToken) 137protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray<Diagnostic> fixableDiagnostics)
CodeActions\VisualBasicCodeFixVerifier`2+Test.cs (6)
70public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; } 94protected override CodeFixContext CreateCodeFixContext(Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, CancellationToken cancellationToken) 99protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray<Diagnostic> fixableDiagnostics)
Diagnostics\AbstractDiagnosticProviderBasedUserDiagnosticTest.cs (4)
143internal override async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 155internal override async Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( 234/// The internal method <see cref="AnalyzerExecutor.IsAnalyzerExceptionDiagnostic(Diagnostic)"/> does 240private static void AssertNoAnalyzerExceptionDiagnostics(IEnumerable<Diagnostic> diagnostics)
Diagnostics\AbstractSuppressionAllCodeTests.cs (6)
28public abstract class AbstractSuppressionAllCodeTests : IEqualityComparer<Diagnostic> 85foreach (var diagnostic in diagnostics) 136public bool Equals(Diagnostic x, Diagnostic y) 139public int GetHashCode(Diagnostic obj) 171context.ReportDiagnostic(Diagnostic.Create(_descriptor, node.GetLocation()));
Diagnostics\AbstractSuppressionDiagnosticTest.cs (4)
49private ImmutableArray<Diagnostic> FilterDiagnostics(IEnumerable<Diagnostic> diagnostics) 69internal override async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 80internal override async Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync(
Diagnostics\AbstractUnncessarySuppressionDiagnosticTest.cs (2)
38internal override async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 46internal override async Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync(
Diagnostics\AbstractUserDiagnosticTest.cs (11)
38internal abstract Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( 41internal abstract Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 61var diagnostic = diagnostics.Single(); 81protected override async Task<ImmutableArray<Diagnostic>> GetDiagnosticsWorkerAsync( 117internal async Task<(ImmutableArray<Diagnostic>, ImmutableArray<CodeAction>, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( 118IEnumerable<Diagnostic> diagnostics, 128return (ImmutableArray<Diagnostic>.Empty, ImmutableArray<CodeAction>.Empty, null); 140return (ImmutableArray<Diagnostic>.Empty, ImmutableArray<CodeAction>.Empty, null); 149foreach (var diagnostic in intersectingDiagnostics) 192IEnumerable<Diagnostic> diagnostics, 209var diagnostic = diagnostics.First();
Diagnostics\AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs (4)
30public override async Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) 38public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) 41public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) 44private async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(
Diagnostics\AbstractUserDiagnosticTest_GenerateTypeDialog.cs (1)
90var generateTypeDiagFixes = diagnostics.SingleOrDefault(df => GenerateTypeTestState.FixIds.Contains(df.Id));
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (17)
Diagnostics\DiagnosticProviderTestUtilities.cs (3)
15public static async Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync( 25public static async Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync( 35public static async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(
Diagnostics\TestDiagnosticAnalyzerDriver.cs (8)
49private async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync( 56var documentDiagnostics = SpecializedCollections.EmptyEnumerable<Diagnostic>(); 57var projectDiagnostics = SpecializedCollections.EmptyEnumerable<Diagnostic>(); 87public Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Document document, TextSpan? filterSpan) 90public async Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project) 92var diagnostics = new List<Diagnostic>(); 105public Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, TextSpan span) 108public Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project)
EditAndContinue\MockEditAndContinueWorkspaceService.cs (2)
35public Func<Document, ActiveStatementSpanProvider, ImmutableArray<Diagnostic>>? GetDocumentDiagnosticsImpl; 76public ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken)
Workspaces\NoCompilationDocumentDiagnosticAnalyzer.cs (4)
24public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 25=> SpecializedTasks.EmptyImmutableArray<Diagnostic>(); 27public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 30Diagnostic.Create(Descriptor, Location.Create(document.FilePath, default, default))));
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (50)
CodeFixes\CodeFixServiceTests.cs (6)
508c.ReportDiagnostic(Diagnostic.Create(descriptor, c.Tree.GetLocation(TextSpan.FromBounds(0, 0)))); 533public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 536return Task.FromResult(ImmutableArray<Diagnostic>.Empty); 539public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 542return Task.FromResult(ImmutableArray<Diagnostic>.Empty); 860context.ReportDiagnostic(Diagnostic.Create(_descriptor, location));
Diagnostics\DiagnosticAnalyzerServiceTests.cs (25)
401ImmutableArray.Create(DiagnosticData.Create(document.Project.Solution, Diagnostic.Create(NoNameAnalyzer.s_syntaxRule, location, properties), document.Project))), 1253context.RegisterSyntaxTreeAction(c => c.ReportDiagnostic(Diagnostic.Create(s_syntaxRule, c.Tree.GetRoot().GetLocation()))); 1254context.RegisterSemanticModelAction(c => c.ReportDiagnostic(Diagnostic.Create(s_semanticRule, c.SemanticModel.SyntaxTree.GetRoot().GetLocation()))); 1255context.RegisterCompilationAction(c => c.ReportDiagnostic(Diagnostic.Create(s_compilationRule, c.Compilation.SyntaxTrees.First().GetRoot().GetLocation()))); 1269context.RegisterSyntaxTreeAction(c => c.ReportDiagnostic(Diagnostic.Create(s_syntaxRule, c.Tree.GetRoot().GetLocation()))); 1270context.RegisterSemanticModelAction(c => c.ReportDiagnostic(Diagnostic.Create(s_semanticRule, c.SemanticModel.SyntaxTree.GetRoot().GetLocation()))); 1271context.RegisterCompilationAction(c => c.ReportDiagnostic(Diagnostic.Create(s_compilationRule, c.Compilation.SyntaxTrees.First().GetRoot().GetLocation()))); 1282=> context.RegisterSyntaxTreeAction(c => c.ReportDiagnostic(Diagnostic.Create(s_syntaxRule, c.Tree.GetRoot().GetLocation()))); 1299public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 1300=> Task.FromResult(ImmutableArray.Create(Diagnostic.Create(s_syntaxRule, Location.Create(document.FilePath, TextSpan.FromBounds(0, 0), new LinePositionSpan(new LinePosition(0, 0), new LinePosition(0, 0)))))); 1302public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 1303=> SpecializedTasks.Default<ImmutableArray<Diagnostic>>(); 1338public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 1339=> Task.FromResult(ImmutableArray<Diagnostic>.Empty); 1340public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 1341=> Task.FromResult(ImmutableArray<Diagnostic>.Empty); 1351public override Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken) 1352=> Task.FromResult(ImmutableArray<Diagnostic>.Empty); 1361public override async Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 1364return ImmutableArray.Create(Diagnostic.Create(s_syntaxRule, root.GetLocation())); 1367public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 1368=> SpecializedTasks.Default<ImmutableArray<Diagnostic>>(); 1375public override Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken) => SpecializedTasks.Default<ImmutableArray<Diagnostic>>(); 1395c.ReportDiagnostic(Diagnostic.Create(_supportedDiagnostics[0], c.Symbol.Locations[0]));
Diagnostics\DiagnosticDataTests.cs (3)
165var diagnostic = await diagnosticData.ToDiagnosticAsync(document.Project, CancellationToken.None); 211var diagnostic = await diagnosticData.ToDiagnosticAsync(project, CancellationToken.None); 259var diagnostic = await diagnosticData.ToDiagnosticAsync(firstDocument.Project, CancellationToken.None);
Diagnostics\DiagnosticsSquiggleTaggerProviderTests.cs (1)
229c.ReportDiagnostic(Diagnostic.Create(_rule, Location.Create(c.Tree, new TextSpan(0, 1))));
Diagnostics\MockDiagnosticService.cs (1)
63_diagnosticData = DiagnosticData.Create(Diagnostic.Create(DiagnosticId, "MockCategory", "MockMessage", DiagnosticSeverity.Error, DiagnosticSeverity.Error, isEnabledByDefault: true, warningLevel: 0,
EditAndContinue\RemoteEditAndContinueServiceTests.cs (8)
140var diagnostic = Diagnostic.Create(diagnosticDescriptor, Location.Create(syntaxTree, TextSpan.FromBounds(1, 1))); 220var documentDiagnostic = Diagnostic.Create(diagnosticDescriptor1, Location.Create(syntaxTree, TextSpan.FromBounds(1, 2)), new[] { "doc", "some error" }); 221var projectDiagnostic = Diagnostic.Create(diagnosticDescriptor1, Location.None, new[] { "proj", "some error" }); 222var syntaxError = Diagnostic.Create(diagnosticDescriptor1, Location.Create(syntaxTree, TextSpan.FromBounds(1, 2)), new[] { "doc", "syntax error" });
EditAndContinue\RudeEditDiagnosticTests.cs (4)
88var d = re.ToDiagnostic(tree); 94var d = re.ToDiagnostic(tree); 102var d = re.ToDiagnostic(tree); 111var d = re.ToDiagnostic(tree);
EditAndContinue\TraceLogTests.cs (2)
20var diagnostic = Diagnostic.Create(EditAndContinueDiagnosticDescriptors.GetDescriptor(EditAndContinueErrorCode.ErrorReadingFile), Location.None, "file", "error");
Microsoft.CodeAnalysis.EditorFeatures.Wpf (4)
Suggestions\FixAll\FixMultipleOccurrencesService.cs (2)
37ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, 56ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix,
Suggestions\SuggestedActions\FixAllCodeFixSuggestedAction.cs (2)
22public Diagnostic Diagnostic { get; } 31Diagnostic diagnostic,
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (23)
CodeFixes\CodeFixServiceTests.vb (1)
217context.ReportDiagnostic(Diagnostic.Create(DiagDescriptor, context.Symbol.Locations.First(), context.Symbol.Locations.Skip(1)))
Diagnostics\AbstractCrossLanguageUserDiagnosticTest.vb (4)
126Friend Async Function GetDiagnosticAndFixAsync(workspace As TestWorkspace) As Task(Of Tuple(Of Diagnostic, CodeFixCollection)) 152Private Async Function GetDiagnosticAndFixesAsync(workspace As TestWorkspace) As Task(Of IEnumerable(Of Tuple(Of Diagnostic, CodeFixCollection))) 159Dim result = New List(Of Tuple(Of Diagnostic, CodeFixCollection)) 181Private Shared Async Function GetDocumentAndDiagnosticsAsync(workspace As TestWorkspace) As Task(Of Tuple(Of Document, IEnumerable(Of Diagnostic)))
Diagnostics\AdditionalFileDiagnosticsTests.vb (1)
99context.ReportDiagnostic(Diagnostic.Create(Rule, context.Symbol.Locations.First()))
Diagnostics\DiagnosticServiceTests.vb (17)
556Dim expected = Diagnostic.Create("test", "test", "test", DiagnosticSeverity.Error, DiagnosticSeverity.Error, True, 0) 1294context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor1, sourceLoc)) 1413context.ReportDiagnostic(Diagnostic.Create(Descriptor1, fieldDecl.GetLocation, fieldDecl.ToString())) 1494Dim diag = Diagnostic.Create(Descriptor, symbolContext.Symbol.Locations(0), additionalFileText) 1581context.ReportDiagnostic(Diagnostic.Create(DiagDescriptor, context.Symbol.Locations.First(), context.Symbol.Locations.Skip(1))) 1609context.ReportDiagnostic(Diagnostic.Create(DiagDescriptor, location)) 1636sc.ReportDiagnostic(Diagnostic.Create(DiagDescriptor, sc.Symbol.Locations.First())) 1735context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.CodeBlock.GetLocation)) 1757context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.CodeBlock.GetLocation)) 1783context.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None)) 1784context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Compilation.SyntaxTrees(0).GetRoot().GetLocation)) 1822context.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None, _symbolNames.Count)) 1860context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor1, context.CodeBlock.GetLocation())) 1871context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor2, context.Node.GetLocation())) 1875context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor3, context.Node.GetLocation())) 1894context.ReportDiagnostic(Diagnostic.Create(descriptor, context.Node.GetLocation)) 1920ctxt.ReportDiagnostic(Diagnostic.Create(Descriptor, method.Locations(0), method.ToDisplayString))
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (9)
DebuggerDiagnosticFormatter.cs (1)
13public override string Format(Diagnostic diagnostic, IFormatProvider? formatter = null)
EvaluationContextBase.cs (8)
62foreach (var error in errors) 82Diagnostic error, 91internal abstract bool HasDuplicateTypesOrAssemblies(Diagnostic diagnostic); 93internal abstract ImmutableArray<AssemblyIdentity> GetMissingAssemblyIdentities(Diagnostic diagnostic, AssemblyIdentity linqLibrary); 151public override bool Equals(Diagnostic? obj) 166internal override Diagnostic WithLocation(Location location) 171internal override Diagnostic WithSeverity(DiagnosticSeverity severity) 176internal override Diagnostic WithIsSuppressed(bool isSuppressed)
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Utilities (1)
CustomDiagnosticFormatter.cs (1)
16public override string Format(Diagnostic diagnostic, IFormatProvider formatter = null)
Microsoft.CodeAnalysis.ExternalAccess.FSharp (26)
Diagnostics\IFSharpDocumentDiagnosticAnalyzer.cs (2)
15Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken); 17Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken);
Diagnostics\IFSharpSimplifyNameDiagnosticAnalyzer.cs (1)
15Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken);
Diagnostics\IFSharpUnusedDeclarationsDiagnosticAnalyzer.cs (1)
15Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken);
Diagnostics\IFSharpUnusedOpensDiagnosticAnalyzer.cs (1)
15Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken);
Internal\Diagnostics\FSharpDocumentDiagnosticAnalyzer.cs (6)
35public Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 40public Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 73public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 78return Task.FromResult(ImmutableArray<Diagnostic>.Empty); 84public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 89return Task.FromResult(ImmutableArray<Diagnostic>.Empty);
Internal\Diagnostics\FSharpSimplifyNameDiagnosticAnalyzer.cs (5)
35public Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken) 57public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 62return Task.FromResult(ImmutableArray<Diagnostic>.Empty); 68public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 70return Task.FromResult(ImmutableArray<Diagnostic>.Empty);
Internal\Diagnostics\FSharpUnusedDeclarationsAnalyzer.cs (5)
35public Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken) 59public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 64return Task.FromResult(ImmutableArray<Diagnostic>.Empty); 70public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 72return Task.FromResult(ImmutableArray<Diagnostic>.Empty);
Internal\Diagnostics\FSharpUnusedOpensDiagnosticAnalyzer.cs (5)
32public Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken) 52public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 57return Task.FromResult(ImmutableArray<Diagnostic>.Empty); 63public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 65return Task.FromResult(ImmutableArray<Diagnostic>.Empty);
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp (2)
CodeActions\OmniSharpCodeFixContextFactory.cs (2)
21ImmutableArray<Diagnostic> diagnostics, 22Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix,
Microsoft.CodeAnalysis.Features (490)
AbstractAddAccessibilityModifiersCodeFixProvider.cs (3)
28var diagnostic = context.Diagnostics.First(); 44Document document, ImmutableArray<Diagnostic> diagnostics, 49foreach (var diagnostic in diagnostics)
AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (5)
38var diagnostic = context.Diagnostics[0]; 54Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 84Document document, ImmutableArray<Diagnostic> diagnostics, 92foreach (var diagnostic in diagnostics) 101Document document, SemanticModel semanticModel, Diagnostic diagnostic,
AbstractAddExplicitCastCodeFixProvider.cs (2)
60var diagnostic = context.Diagnostics.First(); 195ImmutableArray<Diagnostic> diagnostics,
AbstractAddObsoleteAttributeCodeFixProvider.cs (1)
72Document document, ImmutableArray<Diagnostic> diagnostics,
AbstractAddParameterCodeFixProvider.cs (2)
54var diagnostic = context.Diagnostics.First(); 98SyntaxNode initialNode, SyntaxNode node, Diagnostic diagnostic)
AbstractChangeNamespaceToMatchFolderCodeFixProvider.cs (1)
43private static async Task<Solution> FixAllInDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider options, CancellationToken cancellationToken)
AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (3)
58static async Task<ImmutableArray<Diagnostic>> GetSolutionDiagnosticsAsync(FixAllContext fixAllContext) 60var diagnostics = ImmutableArray.CreateBuilder<Diagnostic>(); 74ImmutableArray<Diagnostic> diagnostics,
AbstractConflictMarkerCodeFixProvider.cs (2)
379Document document, ImmutableArray<Diagnostic> diagnostics, 400foreach (var diagnostic in diagnostics)
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)
AbstractConvertTypeOfToNameOfCodeFixProvider.cs (2)
35Document document, ImmutableArray<Diagnostic> diagnostics, 39foreach (var diagnostic in diagnostics)
AbstractFileHeaderCodeFixProvider.cs (1)
33foreach (var diagnostic in context.Diagnostics)
AbstractFileHeaderDiagnosticAnalyzer.cs (2)
61context.ReportDiagnostic(Diagnostic.Create(s_missingHeaderDescriptor, fileHeader.GetLocation(tree))); 68context.ReportDiagnostic(Diagnostic.Create(s_invalidHeaderDescriptor, fileHeader.GetLocation(tree)));
AbstractForEachCastCodeFixProvider.cs (3)
40protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 44Document document, ImmutableArray<Diagnostic> diagnostics, 49foreach (var diagnostic in diagnostics)
AbstractIteratorCodeFixProvider.cs (2)
24protected abstract Task<CodeAction> GetCodeFixAsync(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostics, CancellationToken cancellationToken); 34var diagnostic = context.Diagnostics.FirstOrDefault();
AbstractMakeFieldReadonlyCodeFixProvider.cs (2)
40ImmutableArray<Diagnostic> diagnostics, 46foreach (var diagnostic in diagnostics)
AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
120var diagnostic = DiagnosticHelper.Create(
AbstractMakeMemberStaticCodeFixProvider.cs (1)
32protected sealed override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor,
AbstractMakeMethodAsynchronousCodeFixProvider.cs (4)
20protected abstract bool IsSupportedDiagnostic(Diagnostic diagnostic, CancellationToken cancellationToken); 36var diagnostic = context.Diagnostics.First(); 104Diagnostic diagnostic, 147private SyntaxNode? GetContainingFunction(Diagnostic diagnostic, CancellationToken cancellationToken)
AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
32var diagnostic = context.Diagnostics.First();
AbstractMakeTypeAbstractCodeFixProvider.cs (1)
32protected sealed override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor,
AbstractMakeTypePartialCodeFixProvider.cs (2)
29protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 35foreach (var diagnostic in diagnostics)
AbstractMatchFolderAndNamespaceDiagnosticAnalyzer.cs (1)
82context.ReportDiagnostic(Diagnostic.Create(
AbstractMultipleBlankLinesCodeFixProvider.cs (4)
36var diagnostic = context.Diagnostics.First(); 45private static Task<Document> UpdateDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) 49Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 55foreach (var diagnostic in diagnostics)
AbstractOrderModifiersCodeFixProvider.cs (2)
53Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 62foreach (var diagnostic in diagnostics)
AbstractOrderModifiersDiagnosticAnalyzer.cs (1)
73Diagnostic.Create(Descriptor, context.Tree.GetLocation(
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,
AbstractPopulateSwitchDiagnosticAnalyzer.cs (2)
63var diagnostic = Diagnostic.Create(
AbstractQualifyMemberAccessCodeFixProvider.cs (3)
23protected abstract TSimpleNameSyntax? GetNode(Diagnostic diagnostic, CancellationToken cancellationToken); 36Document document, ImmutableArray<Diagnostic> diagnostics, 41foreach (var diagnostic in diagnostics)
AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
36var diagnostic = context.Diagnostics.First(); 64Document document, ImmutableArray<Diagnostic> diagnostics, 75foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (1)
80context.ReportDiagnostic(Diagnostic.Create(Descriptor,
AbstractRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (4)
76public void AnalyzeAssemblyOrModuleAttribute(SyntaxNode attributeSyntax, SemanticModel model, Action<Diagnostic> reportDiagnostic, CancellationToken cancellationToken) 85reportDiagnostic(Diagnostic.Create(s_invalidScopeDescriptor, attributeSyntax.GetLocation())); 92reportDiagnostic(Diagnostic.Create(s_invalidOrMissingTargetDescriptor, attributeSyntax.GetLocation())); 115reportDiagnostic(Diagnostic.Create(LegacyFormatTargetDescriptor, targetValueOperation.Syntax.GetLocation(), properties!, targetSymbolString));
AbstractRemoveUnnecessaryCastDiagnosticAnalyzer.cs (3)
42var diagnostic = TryRemoveCastExpression( 53private Diagnostic? TryRemoveCastExpression(SemanticModel model, TCastExpression node, CancellationToken cancellationToken) 68return Diagnostic.Create(
AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (5)
83foreach (var diagnostic in diagnostics) 142private static IEnumerable<Diagnostic> CreateClassificationDiagnostics( 153yield return Diagnostic.Create(descriptor, tree.GetLocation(span)); 160private IEnumerable<Diagnostic> CreateFixableDiagnostics( 166yield return Diagnostic.Create(s_fixableIdDescriptor, tree.GetLocation(span));
AbstractRemoveUnnecessaryParenthesesCodeFixProvider.cs (1)
35Document document, ImmutableArray<Diagnostic> diagnostics,
AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (20)
87Action<Diagnostic> reportDiagnostic, 387private static async Task<(ImmutableArray<Diagnostic> reportedDiagnostics, ImmutableArray<string> unhandledIds)> GetReportedDiagnosticsForIdsAsync( 448using var _3 = ArrayBuilder<Diagnostic>.GetInstance(out var reportedDiagnostics); 481static void AddAllDiagnostics(ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> diagnostics, ArrayBuilder<Diagnostic> reportedDiagnostics) 489static void AddAllCompilationDiagnosticsForTree(AnalysisResult analysisResult, SyntaxTree tree, ArrayBuilder<Diagnostic> reportedDiagnostics) 493foreach (var diagnostic in perAnalyzerDiagnostics) 505ImmutableArray<Diagnostic> diagnostics, 514foreach (var diagnostic in diagnostics) 541Diagnostic diagnostic, 581Diagnostic diagnostic, 609Action<Diagnostic> reportDiagnostic, 613using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnosticsBuilder); 619foreach (var diagnostic in effectiveDiagnostics) 627ArrayBuilder<Diagnostic> diagnosticsBuilder, 652var diagnostic = Diagnostic.Create(s_removeUnnecessarySuppressionDescriptor, pragma.GetLocation(), severity, additionalLocations, properties: null); 659ArrayBuilder<Diagnostic> diagnosticsBuilder, 667var diagnostic = Diagnostic.Create(s_removeUnnecessarySuppressionDescriptor, attribute.GetLocation(), severity, additionalLocations: null, properties: null);
AbstractRemoveUnusedMembersCodeFixProvider.cs (2)
44ImmutableArray<Diagnostic> diagnostics, 54foreach (var diagnostic in diagnostics)
AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
472var diagnostic = DiagnosticHelper.CreateWithMessage(
AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (3)
290public static bool TryGetUnusedValuePreference(Diagnostic diagnostic, out UnusedValuePreference preference) 311public static bool GetIsUnusedLocalDiagnostic(Diagnostic diagnostic) 317public static bool GetIsRemovableAssignmentDiagnostic(Diagnostic diagnostic)
AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (2)
182var diagnostic = DiagnosticHelper.Create(s_expressionValueIsUnusedRule, 536var diagnostic = DiagnosticHelper.Create(s_valueAssignedIsUnusedRule,
AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (2)
131Action<Diagnostic> reportDiagnostic, 154var diagnostic = DiagnosticHelper.CreateWithMessage(s_unusedParameterRule, location,
AbstractRemoveUnusedValuesCodeFixProvider.cs (17)
127var diagnostic = context.Diagnostics[0]; 191private static bool IsForEachIterationVariableDiagnostic(Diagnostic diagnostic, Document document, CancellationToken cancellationToken) 202private static string GetEquivalenceKey(Diagnostic diagnostic) 221protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 227private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember( 228ImmutableArray<Diagnostic> diagnostics, 240foreach (var diagnostic in diagnostics) 252private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember( 253ImmutableArray<Diagnostic> diagnostics, 260private static async Task<Document> PreprocessDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 272protected sealed override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 284ImmutableArray<Diagnostic> diagnostics, 335IEnumerable<Diagnostic> diagnostics, 372IOrderedEnumerable<Diagnostic> diagnostics, 388foreach (var diagnostic in diagnostics) 431IOrderedEnumerable<Diagnostic> diagnostics, 664foreach (var diagnostic in diagnostics)
AbstractSimplifyInterpolationCodeFixProvider.cs (2)
50Document document, ImmutableArray<Diagnostic> diagnostics, 58foreach (var diagnostic in diagnostics)
AbstractSimplifyLinqExpressionCodeFixProvider`3.cs (2)
35ImmutableArray<Diagnostic> diagnostics, 55static TInvocationExpressionSyntax GetInvocation(SyntaxNode root, Diagnostic diagnostic)
AbstractUpgradeProjectCodeFixProvider.cs (1)
21public abstract string SuggestedVersion(ImmutableArray<Diagnostic> diagnostics);
AbstractUseAutoPropertyAnalyzer.cs (3)
330var diagnostic1 = DiagnosticHelper.Create( 339var diagnostic2 = Diagnostic.Create(
AbstractUseCollectionInitializerCodeFixProvider.cs (3)
44protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 54Document document, ImmutableArray<Diagnostic> diagnostics, 69foreach (var diagnostic in diagnostics)
AbstractUseCompoundAssignmentCodeFixProvider.cs (2)
53Document document, ImmutableArray<Diagnostic> diagnostics, 59foreach (var diagnostic in diagnostics)
AbstractUseConditionalExpressionCodeFixProvider.cs (3)
49Document document, Diagnostic diagnostic, 53Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, 63foreach (var diagnostic in diagnostics)
AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
61Document document, Diagnostic diagnostic,
AbstractUseConditionalExpressionForReturnCodeFixProvider.cs (1)
47Document document, Diagnostic diagnostic,
AbstractUseInferredMemberNameCodeFixProvider.cs (2)
32Document document, ImmutableArray<Diagnostic> diagnostics, 37foreach (var diagnostic in diagnostics)
AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (4)
32private static bool IsSupportedDiagnostic(Diagnostic diagnostic) 37var diagnostic = context.Diagnostics.First(); 51Document document, ImmutableArray<Diagnostic> diagnostics, 59foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
AbstractUseNullPropagationCodeFixProvider.cs (5)
59protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 69Document document, ImmutableArray<Diagnostic> diagnostics, 75foreach (var diagnostic in diagnostics) 93Diagnostic diagnostic, 141Diagnostic diagnostic,
AbstractUseObjectInitializerCodeFixProvider.cs (3)
42protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 52Document document, ImmutableArray<Diagnostic> diagnostics, 67foreach (var diagnostic in diagnostics)
AbstractUseObjectInitializerDiagnosticAnalyzer.cs (1)
150context.ReportDiagnostic(Diagnostic.Create(
AbstractValidateFormatStringDiagnosticAnalyzer.cs (2)
357var diagnostic = Diagnostic.Create(
AddImport\AbstractAddImportFeatureService.cs (4)
485public async Task<ImmutableArray<(Diagnostic Diagnostic, ImmutableArray<AddImportFixData> Fixes)>> GetFixesForDiagnosticsAsync( 486Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, int maxResultsPerDiagnostic, 493using var _ = ArrayBuilder<(Diagnostic, ImmutableArray<AddImportFixData>)>.GetInstance(out var result); 495foreach (var diagnostic in diagnostics)
AddImport\IAddImportFeatureService.cs (5)
27/// Gets data for how to fix a particular <see cref="Diagnostic" /> id within the specified Document. 36/// Gets data for how to fix a set of <see cref="Diagnostic" />s within the specified Document. 39Task<ImmutableArray<(Diagnostic Diagnostic, ImmutableArray<AddImportFixData> Fixes)>> GetFixesForDiagnosticsAsync( 40Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, int maxResultsPerDiagnostic, 53/// Gets data for how to fix a particular <see cref="Diagnostic" /> id within the specified Document.
AddMissingReference\AbstractAddMissingReferenceCodeFixProvider.cs (1)
74foreach (var diagnostic in context.Diagnostics)
AddRequiredParenthesesCodeFixProvider.cs (4)
31protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 37var firstDiagnostic = context.Diagnostics[0]; 48Document document, ImmutableArray<Diagnostic> diagnostics, 53foreach (var diagnostic in diagnostics)
CodeFixes\CodeFixCollection.cs (2)
27public Diagnostic FirstDiagnostic { get; } 35Diagnostic firstDiagnostic)
CodeFixes\Configuration\ConfigurationUpdater.cs (8)
68private readonly Diagnostic? _diagnostic; 81Diagnostic? diagnosticToConfigure, 113Diagnostic diagnostic, 132Diagnostic diagnostic, 204Diagnostic diagnostic, 216Diagnostic diagnostic, 351Diagnostic diagnostic, 400internal static ImmutableArray<IOption2> GetCodeStyleOptionsForDiagnostic(Diagnostic diagnostic, Project project)
CodeFixes\Configuration\ConfigureCodeStyle\ConfigureCodeStyleOptionCodeFixProvider.cs (6)
39public bool IsFixableDiagnostic(Diagnostic diagnostic) 57public Task<ImmutableArray<CodeFix>> GetFixesAsync(TextDocument document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 60public Task<ImmutableArray<CodeFix>> GetFixesAsync(Project project, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 63private static ImmutableArray<CodeFix> GetConfigurations(Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken) 66foreach (var diagnostic in diagnostics) 103TopLevelConfigureCodeStyleOptionCodeAction? GetCodeActionForCodeStyleOption(IOption2 option, Diagnostic diagnostic, bool hasMultipleOptions)
CodeFixes\Configuration\ConfigureCodeStyle\ConfigureCodeStyleOptionCodeFixProvider.TopLevelConfigureCodeStyleOptionCodeAction.cs (1)
14public TopLevelConfigureCodeStyleOptionCodeAction(Diagnostic diagnostic, ImmutableArray<CodeAction> nestedActions)
CodeFixes\Configuration\ConfigureSeverity\ConfigureSeverityLevelCodeFixProvider.cs (9)
40public bool IsFixableDiagnostic(Diagnostic diagnostic) 46public Task<ImmutableArray<CodeFix>> GetFixesAsync(TextDocument document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 49public Task<ImmutableArray<CodeFix>> GetFixesAsync(Project project, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 52private static ImmutableArray<CodeFix> GetConfigurations(Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken) 55var analyzerDiagnosticsByCategory = new SortedDictionary<string, ArrayBuilder<Diagnostic>>(); 56using var disposer = ArrayBuilder<Diagnostic>.GetInstance(out var analyzerDiagnostics); 57foreach (var diagnostic in diagnostics) 78var diagnosticsForCategory = analyzerDiagnosticsByCategory.GetOrAdd(diagnostic.Descriptor.Category, _ => ArrayBuilder<Diagnostic>.GetInstance()); 98void AddBulkConfigurationCodeFixes(ImmutableArray<Diagnostic> diagnostics, string? category)
CodeFixes\Configuration\ConfigureSeverity\ConfigureSeverityLevelCodeFixProvider.TopLevelConfigureSeverityCodeAction.cs (1)
16public TopLevelConfigureSeverityCodeAction(Diagnostic diagnostic, ImmutableArray<CodeAction> nestedActions)
CodeFixes\FixAllOccurrences\IFixMultipleOccurrencesService.cs (2)
21ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, 36ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix,
CodeFixes\GenerateMember\AbstractGenerateMemberCodeFixProvider.cs (3)
28protected abstract bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic); 39var diagnostic = context.Diagnostics.First(); 63TextSpan span, Diagnostic diagnostic)
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (19)
47ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap, 76private async Task<ImmutableArray<(Diagnostic diagnostic, CodeAction action)>> GetDiagnosticsAndCodeActionsAsync( 77ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap, 82var fixesBag = new ConcurrentBag<(Diagnostic diagnostic, CodeAction action)>(); 120Document document, ImmutableArray<Diagnostic> diagnostics, 121ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> fixes, 135Document document, ImmutableArray<Diagnostic> diagnostics, 136ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> fixes, 145foreach (var diagnostic in diagnostics) 162ImmutableDictionary<Project, ImmutableArray<Diagnostic>> projectsAndDiagnosticsToFixMap, 172var bag = new ConcurrentBag<(Diagnostic diagnostic, CodeAction action)>(); 201private static Action<CodeAction, ImmutableArray<Diagnostic>> GetRegisterCodeFixAction( 203ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> result) 227Project project, ImmutableArray<Diagnostic> diagnostics, 228ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> fixes, 235ImmutableArray<(Diagnostic diagnostic, CodeAction action)> batchOfFixes, 257ImmutableArray<(Diagnostic diagnostic, CodeAction action)> diagnosticsAndCodeActions, 282ImmutableArray<(Diagnostic diagnostic, CodeAction action)> diagnosticsAndCodeActions, 305ImmutableArray<(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, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 150internal async Task<ImmutableArray<PragmaWarningCodeAction>> GetPragmaSuppressionsAsync(Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 159Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken) 172Project project, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 188Document documentOpt, Project project, IEnumerable<Diagnostic> diagnostics, SuppressionTargetInfo suppressionTargetInfo, CodeActionOptionsProvider fallbackOptions, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken) 207foreach (var diagnostic in diagnostics)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.GlobalSuppressMessageCodeAction.cs (2)
22private readonly Diagnostic _diagnostic; 27Project project, Diagnostic diagnostic,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs (26)
29private readonly IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>> _diagnosticsBySymbol; 35IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>> diagnosticsBySymbol, 45internal static CodeAction Create(string title, AbstractSuppressionCodeFixProvider fixer, Document triggerDocument, ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsByDocument, CodeActionOptionsProvider fallbackOptions) 52internal static CodeAction Create(string title, AbstractSuppressionCodeFixProvider fixer, Project triggerProject, ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject, CodeActionOptionsProvider fallbackOptions) 76ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsByDocument, 106ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject, 146foreach (var diagnostic in diagnostics) 160private static async Task<IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>> CreateDiagnosticsBySymbolAsync(AbstractSuppressionCodeFixProvider fixer, IEnumerable<KeyValuePair<Document, ImmutableArray<Diagnostic>>> diagnosticsByDocument, CancellationToken cancellationToken) 162var diagnosticsMapBuilder = ImmutableDictionary.CreateBuilder<ISymbol, List<Diagnostic>>(); 165foreach (var diagnostic in diagnostics) 181private static async Task<IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>> CreateDiagnosticsBySymbolAsync(Project project, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 183var diagnosticsMapBuilder = ImmutableDictionary.CreateBuilder<ISymbol, List<Diagnostic>>(); 187foreach (var diagnostic in diagnostics) 198private static void AddDiagnosticForSymbolIfNeeded(ISymbol targetSymbol, Diagnostic diagnostic, ImmutableDictionary<ISymbol, List<Diagnostic>>.Builder diagnosticsMapBuilder) 207diagnosticsForSymbol = new List<Diagnostic>(); 214private static IEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>> CreateDiagnosticsBySymbol(ImmutableDictionary<ISymbol, List<Diagnostic>>.Builder diagnosticsMapBuilder) 218return SpecializedCollections.EmptyEnumerable<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>(); 221var builder = new List<KeyValuePair<ISymbol, ImmutableArray<Diagnostic>>>(); 228private static ImmutableArray<Diagnostic> GetUniqueDiagnostics(List<Diagnostic> diagnostics) 231var uniqueDiagnostics = ArrayBuilder<Diagnostic>.GetInstance(); 232foreach (var diagnostic in diagnostics)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.LocalSuppressMessageCodeAction.cs (2)
21private readonly Diagnostic _diagnostic; 29Diagnostic diagnostic)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (9)
30ImmutableArray<Diagnostic> pragmaDiagnostics, 45ImmutableArray<Diagnostic> diagnostics, 51var currentDiagnosticSpans = new Dictionary<Diagnostic, TextSpan>(); 52foreach (var diagnostic in diagnostics) 61var diagnostic = diagnostics[i]; 72diagnostic = Diagnostic.Create( 131private static void UpdateDiagnosticSpans(ImmutableArray<Diagnostic> diagnostics, Dictionary<Diagnostic, TextSpan> currentDiagnosticSpans, IEnumerable<TextChange> textChanges) 137foreach (var diagnostic in diagnostics)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaHelpers.cs (2)
105Diagnostic diagnostic, 157Diagnostic diagnostic,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningBatchFixAllProvider.cs (4)
31Document document, ImmutableArray<Diagnostic> diagnostics, 32ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> fixes, 36var pragmaDiagnosticsBuilder = ArrayBuilder<Diagnostic>.GetInstance(); 38foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && !d.IsSuppressed))
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs (3)
20private readonly Diagnostic _diagnostic; 27Diagnostic diagnostic, 41Diagnostic diagnostic,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs (9)
37Document document, ImmutableArray<Diagnostic> diagnostics, 38ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> fixes, 43var pragmaDiagnosticsBuilder = ArrayBuilder<Diagnostic>.GetInstance(); 45foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && d.IsSuppressed)) 87Project project, ImmutableArray<Diagnostic> diagnostics, 88ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> bag, 91foreach (var diagnostic in diagnostics.Where(d => !d.Location.IsInSource && d.IsSuppressed)) 108ImmutableArray<(Diagnostic diagnostic, CodeAction action)> batchOfFixes, 120var newBatchOfFixes = new List<(Diagnostic diagnostic, CodeAction action)>();
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.cs (3)
21private readonly Diagnostic _diagnostic; 28Diagnostic diagnostic, 51Diagnostic diagnostic,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Attribute.cs (2)
28Diagnostic diagnostic, 37Diagnostic diagnostic,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (6)
35Diagnostic diagnostic, 49Diagnostic diagnostic, 118private static bool CanRemovePragmaTrivia(SyntaxToken token, Diagnostic diagnostic, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, out int indexOfTriviaToRemove) 212var dummyDiagnosticWithLocationToCheck = Diagnostic.Create(_diagnostic.Descriptor, locationToCheck); 213var effectiveDiagnostic = CompilationWithAnalyzers.GetEffectiveDiagnostics(new[] { dummyDiagnosticWithLocationToCheck }, model.Compilation).FirstOrDefault();
CodeFixes\Suppression\SuppressionHelpers.cs (7)
22public static bool CanBeSuppressed(Diagnostic diagnostic) 25public static bool CanBeSuppressedWithAttribute(Diagnostic diagnostic) 37public static bool CanBeUnsuppressed(Diagnostic diagnostic) 40private static bool CanBeSuppressedOrUnsuppressed(Diagnostic diagnostic, bool checkCanBeSuppressed) 72public static bool IsNotConfigurableDiagnostic(Diagnostic diagnostic) 78public static bool IsCompilerDiagnostic(Diagnostic diagnostic) 84public static bool IsSynthesizedExternalSourceDiagnostic(Diagnostic diagnostic)
CodeFixes\Suppression\TopLevelSuppressionCodeAction.cs (1)
14public TopLevelSuppressionCodeAction(Diagnostic diagnostic, ImmutableArray<NestedSuppressionCodeAction> nestedActions)
Completion\Providers\AbstractInternalsVisibleToCompletionProvider.cs (1)
193foreach (var diagnostic in attribute.GetDiagnostics())
ConsecutiveStatementPlacementCodeFixProvider.cs (3)
36var diagnostic = context.Diagnostics.First(); 45private static Task<Document> UpdateDocumentAsync(Document document, Diagnostic diagnostic, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 48public static async Task<Document> FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
DiagnosticHelper.cs (21)
21/// Creates a <see cref="Diagnostic"/> instance. 29/// If null, <see cref="Diagnostic.AdditionalLocations"/> will return an empty list. 33/// can convey more detailed information to the fixer. If null, <see cref="Diagnostic.Properties"/> will return 37/// <returns>The <see cref="Diagnostic"/> instance.</returns> 38public static Diagnostic Create( 74/// <see cref="Diagnostic.AdditionalLocations"/>. 79/// <see cref="Diagnostic.AdditionalLocations"/>. 82/// <returns>The <see cref="Diagnostic"/> instance.</returns> 83public static Diagnostic CreateWithLocationTags( 118/// <see cref="Diagnostic.AdditionalLocations"/>. 123/// <see cref="Diagnostic.AdditionalLocations"/>. 130/// <returns>The <see cref="Diagnostic"/> instance.</returns> 131public static Diagnostic CreateWithLocationTags( 176/// <returns>The <see cref="Diagnostic"/> instance.</returns> 177private static Diagnostic CreateWithLocationTags( 210/// Creates a <see cref="Diagnostic"/> instance. 218/// If null, <see cref="Diagnostic.AdditionalLocations"/> will return an empty list. 222/// can convey more detailed information to the fixer. If null, <see cref="Diagnostic.Properties"/> will return 226/// <returns>The <see cref="Diagnostic"/> instance.</returns> 227public static Diagnostic CreateWithMessage( 240return Diagnostic.Create(
Diagnostics\AbstractHostDiagnosticUpdateSource.cs (1)
37public void ReportAnalyzerDiagnostic(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, ProjectId? projectId)
Diagnostics\Analyzers\UnboundIdentifiersDiagnosticAnalyzerBase.cs (1)
86context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptor, typeName.GetLocation(), typeName.ToString()));
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (1)
559var syntaxError = syntaxDiagnostics.FirstOrDefault(d => d.Severity == DiagnosticSeverity.Error);
EditAndContinue\DebuggingSession.cs (16)
40private readonly Dictionary<ProjectId, (Guid Mvid, Diagnostic Error)> _projectModuleIds = new(); 252internal async Task<(Guid Mvid, Diagnostic? Error)> GetProjectModuleIdAsync(Project project, CancellationToken cancellationToken) 264(Guid Mvid, Diagnostic? Error) ReadMvid() 279return (Mvid: Guid.Empty, Error: Diagnostic.Create(descriptor, Location.None, new[] { outputs.AssemblyDisplayPath, e.Message })); 317out ImmutableArray<Diagnostic> diagnostics, 329diagnostics = ImmutableArray<Diagnostic>.Empty; 370out ImmutableArray<Diagnostic> diagnostics, 423diagnostics = ImmutableArray.Create(Diagnostic.Create(descriptor, Location.None, new[] { fileBeingRead, e.Message })); 450public async ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken) 456return ImmutableArray<Diagnostic>.Empty; 463return ImmutableArray<Diagnostic>.Empty; 469return ImmutableArray<Diagnostic>.Empty; 479return ImmutableArray<Diagnostic>.Empty; 488return ImmutableArray<Diagnostic>.Empty; 506return ImmutableArray<Diagnostic>.Empty; 519return ImmutableArray<Diagnostic>.Empty;
EditAndContinue\DocumentAnalysisResults.cs (3)
41public Diagnostic? SyntaxError { get; } 102Diagnostic? syntaxError, 176public static DocumentAnalysisResults SyntaxErrors(DocumentId documentId, string filePath, ImmutableArray<RudeEditDiagnostic> rudeEdits, Diagnostic? syntaxError, bool hasChanges)
EditAndContinue\EditAndContinueWorkspaceService.cs (1)
191public ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken)
EditAndContinue\EditSession.cs (12)
124private async Task<Diagnostic?> GetUnsupportedChangesDiagnosticAsync(EmitDifferenceResult emitResult, CancellationToken cancellationToken) 146return Diagnostic.Create(descriptor, Location.None); 157public async Task<ImmutableArray<Diagnostic>?> GetModuleDiagnosticsAsync(Guid mvid, Project oldProject, Project newProject, ImmutableArray<DocumentAnalysisResults> documentAnalyses, CancellationToken cancellationToken) 169return ImmutableArray<Diagnostic>.Empty; 175using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnostics); 179diagnostics.Add(Diagnostic.Create(descriptor, location, messageArgs)); 505private async Task<(ImmutableArray<DocumentAnalysisResults> results, ImmutableArray<Diagnostic> diagnostics)> AnalyzeDocumentsAsync( 510using var _1 = ArrayBuilder<Diagnostic>.GetInstance(out var documentDiagnostics); 525documentDiagnostics.Add(Diagnostic.Create(descriptor, Location.Create(newDocument.FilePath!, textSpan: default, lineSpan: default), new[] { newDocument.FilePath })); 806using var _4 = ArrayBuilder<(ProjectId, ImmutableArray<Diagnostic>)>.GetInstance(out var diagnostics); 809Diagnostic? syntaxError = null; 1015var unsupportedChangesDiagnostic = await GetUnsupportedChangesDiagnosticAsync(emitResult, cancellationToken).ConfigureAwait(false);
EditAndContinue\EditSessionTelemetry.cs (1)
129public void LogProjectAnalysisSummary(ProjectAnalysisSummary summary, Guid projectTelemetryId, ImmutableArray<Diagnostic> emitDiagnostics)
EditAndContinue\EmitSolutionUpdateResults.cs (8)
51diagnostics: ImmutableArray<(ProjectId, ImmutableArray<Diagnostic>)>.Empty, 56public readonly ImmutableArray<(ProjectId ProjectId, ImmutableArray<Diagnostic> Diagnostics)> Diagnostics; 58public readonly Diagnostic? SyntaxError; 62ImmutableArray<(ProjectId ProjectId, ImmutableArray<Diagnostic> Diagnostic)> diagnostics, 64Diagnostic? syntaxError) 83foreach (var diagnostic in diagnostics) 105public async Task<ImmutableArray<Diagnostic>> GetAllDiagnosticsAsync(Solution solution, CancellationToken cancellationToken) 107using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnostics);
EditAndContinue\IEditAndContinueWorkspaceService.cs (1)
16ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken);
EditAndContinue\Remote\RemoteDebuggingSessionProxy.cs (2)
151var diagnostic = Diagnostic.Create(
EditAndContinue\Remote\RemoteEditAndContinueServiceProxy.cs (6)
172public async ValueTask<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, Document designTimeDocument, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken) 177return ImmutableArray<Diagnostic>.Empty; 202return ImmutableArray<Diagnostic>.Empty; 207using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var result); 212Diagnostic diagnostic; 232private static Diagnostic RemapLocation(Document designTimeDocument, DiagnosticData data)
EditAndContinue\RudeEditDiagnostic.cs (2)
39internal Diagnostic ToDiagnostic(SyntaxTree tree) 42return Diagnostic.Create(descriptor, tree.GetLocation(Span), Arguments);
EditAndContinue\SolutionUpdate.cs (6)
17public readonly ImmutableArray<(ProjectId ProjectId, ImmutableArray<Diagnostic> Diagnostics)> Diagnostics; 19public readonly Diagnostic? SyntaxError; 25ImmutableArray<(ProjectId ProjectId, ImmutableArray<Diagnostic> Diagnostics)> diagnostics, 27Diagnostic? syntaxError) 38ImmutableArray<(ProjectId, ImmutableArray<Diagnostic>)> diagnostics, 40Diagnostic? syntaxError,
EditAndContinue\TraceLog.cs (1)
91public static implicit operator Arg(Diagnostic value) => new(value);
EmbeddedLanguages\Json\LanguageServices\AbstractJsonDetectionCodeFixProvider.cs (3)
47public void Fix(SyntaxEditor editor, Diagnostic diagnostic, CancellationToken cancellationToken) 60Document document, ImmutableArray<Diagnostic> diagnostics, 63foreach (var diagnostic in diagnostics)
ExternalAccess\UnitTesting\API\UnitTestingHotReloadService.cs (3)
71private static readonly ImmutableArray<Diagnostic> EmptyDiagnostic = ImmutableArray.Create<Diagnostic>(); 111public async Task<(ImmutableArray<Update> updates, ImmutableArray<Diagnostic> diagnostics)> EmitSolutionUpdateAsync(Solution solution, bool commitUpdates, CancellationToken cancellationToken)
ExternalAccess\VSTypeScript\Api\IVSTypeScriptDiagnosticAnalyzerImplementation.cs (3)
13Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken); 14Task<ImmutableArray<Diagnostic>> AnalyzeDocumentSyntaxAsync(Document document, CancellationToken cancellationToken); 15Task<ImmutableArray<Diagnostic>> AnalyzeDocumentSemanticsAsync(Document document, CancellationToken cancellationToken);
ExternalAccess\VSTypeScript\VSTypeScriptDocumentDiagnosticAnalyzer.cs (4)
18public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 23return SpecializedTasks.EmptyImmutableArray<Diagnostic>(); 29public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 34return SpecializedTasks.EmptyImmutableArray<Diagnostic>();
ExternalAccess\VSTypeScript\VSTypeScriptProjectDiagnosticAnalyzer.cs (2)
18public override Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken) 23return SpecializedTasks.EmptyImmutableArray<Diagnostic>();
ExternalAccess\Watch\Api\WatchHotReloadService.cs (1)
97public async Task<(ImmutableArray<Update> updates, ImmutableArray<Diagnostic> diagnostics)> EmitSolutionUpdateAsync(Solution solution, CancellationToken cancellationToken)
ExtractMethod\Extensions.cs (1)
84var set = new HashSet<Diagnostic>(node.GetDiagnostics());
FormattingAnalyzerHelper.cs (1)
66context.ReportDiagnostic(Diagnostic.Create(
FormattingCodeFixHelper.cs (1)
17internal static async Task<SyntaxTree> FixOneAsync(SyntaxTree syntaxTree, FormattingProvider formattingProvider, SyntaxFormattingOptions options, Diagnostic diagnostic, CancellationToken cancellationToken)
FormattingCodeFixProvider.cs (3)
40foreach (var diagnostic in context.Diagnostics) 63private async Task<Document> FixOneAsync(CodeFixContext context, Diagnostic diagnostic, CancellationToken cancellationToken) 72protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
25var diagnostic = context.Diagnostics.FirstOrDefault();
NamingStyleCodeFixProvider.cs (1)
51var diagnostic = context.Diagnostics.First();
NamingStyleDiagnosticAnalyzerBase.cs (3)
65var diagnostic = TryGetDiagnostic( 87var diagnostic = TryGetDiagnostic( 104private Diagnostic? TryGetDiagnostic(
PreferFrameworkType\PreferFrameworkTypeCodeFixProvider.cs (4)
33var diagnostic = context.Diagnostics[0]; 48Document document, ImmutableArray<Diagnostic> diagnostics, 54foreach (var diagnostic in diagnostics) 69protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic)
RemoveRedundantEqualityCodeFixProvider.cs (3)
35foreach (var diagnostic in context.Diagnostics) 43protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 49foreach (var diagnostic in diagnostics)
RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (3)
34foreach (var diagnostic in context.Diagnostics) 44protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 46foreach (var diagnostic in diagnostics)
RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
40foreach (var diagnostic in context.Diagnostics) 51protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 60foreach (var diagnostic in diagnostics)
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (3)
41var diagnostic = context.Diagnostics.First(); 60protected override async Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor syntaxEditor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 71foreach (var diagnostic in diagnostics)
SimplifyConditionalCodeFixProvider.cs (2)
43ImmutableArray<Diagnostic> diagnostics, 66SyntaxNode SimplifyConditional(SemanticModel semanticModel, Diagnostic diagnostic, SyntaxNode expr)
SimplifyThisOrMe\AbstractSimplifyThisOrMeCodeFixProvider.cs (1)
44Document document, ImmutableArray<Diagnostic> diagnostics,
SimplifyTypeNames\AbstractSimplifyTypeNamesCodeFixProvider.cs (2)
102Document document, ImmutableArray<Diagnostic> diagnostics, 109foreach (var diagnostic in diagnostics)
SimplifyTypeNamesDiagnosticAnalyzerBase.cs (7)
110protected abstract ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context); 111protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree); 113public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, CancellationToken cancellationToken) 134internal static Diagnostic CreateDiagnostic(SemanticModel model, TSimplifierOptions options, TextSpan issueSpan, string diagnosticId, bool inDeclaration) 166var diagnostic = DiagnosticHelper.Create(descriptor, tree.GetLocation(issueSpan), severity, additionalLocations: null, builder.ToImmutable()); 246foreach (var diagnostic in diagnostics) 298foreach (var diagnostic in diagnostics)
SyncNamespaces\AbstractSyncNamespacesService.cs (13)
56private static async Task<ImmutableDictionary<Project, ImmutableArray<Diagnostic>>> GetDiagnosticsByProjectAsync( 61var builder = ImmutableDictionary.CreateBuilder<Project, ImmutableArray<Diagnostic>>(); 72private static async Task<ImmutableArray<Diagnostic>> GetDiagnosticsAsync( 94ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject, 100var firstDiagnostic = diagnosticsByProject 153private static readonly Task<IEnumerable<Diagnostic>> EmptyDiagnosticResult = Task.FromResult(Enumerable.Empty<Diagnostic>()); 155private readonly ImmutableDictionary<Project, ImmutableArray<Diagnostic>> _diagnosticsByProject; 157internal DiagnosticProvider(ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsByProject) 162public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) 167public override async Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) 175public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) 178? Task.FromResult<IEnumerable<Diagnostic>>(_diagnosticsByProject[project])
UpdateLegacySuppressionsCodeFixProvider.cs (3)
35foreach (var diagnostic in context.Diagnostics) 45protected override Task FixAllAsync(Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) 47foreach (var diagnostic in diagnostics)
UseAutoProperty\AbstractUseAutoPropertyCodeFixProvider.cs (2)
52foreach (var diagnostic in context.Diagnostics) 69private async Task<Solution> ProcessResultAsync(CodeFixContext context, Diagnostic diagnostic, CancellationToken cancellationToken)
UseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs (2)
41Document document, ImmutableArray<Diagnostic> diagnostics, 47foreach (var diagnostic in diagnostics)
UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs (3)
32protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 42Document document, ImmutableArray<Diagnostic> diagnostics, 53foreach (var diagnostic in diagnostics)
UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (4)
33protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) 43Document document, ImmutableArray<Diagnostic> diagnostics, 51foreach (var diagnostic in diagnostics) 64Diagnostic diagnostic, CancellationToken cancellationToken)
UseExplicitTupleNameCodeFixProvider.cs (2)
39Document document, ImmutableArray<Diagnostic> diagnostics, 44foreach (var diagnostic in diagnostics)
UseSystemHashCodeCodeFixProvider.cs (2)
40Document document, ImmutableArray<Diagnostic> diagnostics, 58foreach (var diagnostic in diagnostics)
Microsoft.CodeAnalysis.InteractiveHost (4)
Interactive\Core\InteractiveHost.Service.cs (4)
538foreach (var error in args.Errors) 781private void DisplayInteractiveErrors(ImmutableArray<Diagnostic> diagnostics, TextWriter output) 783var displayedDiagnostics = new List<Diagnostic>(); 794foreach (var diagnostic in displayedDiagnostics)
Microsoft.CodeAnalysis.LanguageServer.Protocol (55)
Features\CodeFixes\CodeFixService.cs (14)
466var uniqueDiagosticToEquivalenceKeysMap = new Dictionary<Diagnostic, PooledHashSet<string?>>(); 471var diagnosticAndEquivalenceKeyToFixersMap = new Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider>(); 497var primaryDiagnostic = dxs.First(); 569ImmutableArray<Diagnostic> diagnostics, 570Dictionary<Diagnostic, PooledHashSet<string?>> uniqueDiagosticToEquivalenceKeysMap, 571Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider> diagnosticAndEquivalenceKeyToFixersMap, 607static ImmutableArray<Diagnostic> FilterApplicableDiagnostics( 608ImmutableArray<Diagnostic> applicableDiagnostics, 611Dictionary<Diagnostic, PooledHashSet<string?>> uniqueDiagosticToEquivalenceKeysMap, 612Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider> diagnosticAndEquivalenceKeyToFixersMap) 614using var disposer = ArrayBuilder<Diagnostic>.GetInstance(out var newApplicableDiagnostics); 615foreach (var diagnostic in applicableDiagnostics) 692Func<Diagnostic, bool> hasFix, 693Func<ImmutableArray<Diagnostic>, Task<ImmutableArray<CodeFix>>> getFixes,
Features\CodeFixes\CodeFixService.FixAllDiagnosticProvider.cs (4)
45public override async Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) 53public override async Task<IEnumerable<Diagnostic>> GetDocumentSpanDiagnosticsAsync(Document document, TextSpan fixAllSpan, CancellationToken cancellationToken) 61public override async Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) 68public override async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken)
Features\CodeFixes\CodeFixService.FixAllPredefinedDiagnosticProvider.cs (8)
19private readonly ImmutableArray<Diagnostic> _diagnostics; 21public FixAllPredefinedDiagnosticProvider(ImmutableArray<Diagnostic> diagnostics) 24public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) 25=> Task.FromResult<IEnumerable<Diagnostic>>(_diagnostics); 27public override Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) 28=> Task.FromResult<IEnumerable<Diagnostic>>(_diagnostics); 30public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) 31=> SpecializedTasks.EmptyEnumerable<Diagnostic>();
Features\Diagnostics\DefaultDiagnosticAnalyzerService.cs (1)
152var loadDiagnostic = await document.State.GetLoadDiagnosticAsync(cancellationToken).ConfigureAwait(false);
Features\Diagnostics\DocumentAnalysisExecutor.cs (4)
76var loadDiagnostic = await textDocument.State.GetLoadDiagnosticAsync(cancellationToken).ConfigureAwait(false); 347static bool IsUnusedImportDiagnostic(Diagnostic d) 362bool shouldInclude(Diagnostic d) => span.Value.IntersectsWith(d.Location.SourceSpan) && !IsUnusedImportDiagnostic(d); 388var diagnostic = await diagnosticData.ToDiagnosticAsync(textDocument.Project, cancellationToken).ConfigureAwait(false);
Features\Diagnostics\DocumentAnalysisExecutor_Helpers.cs (18)
55internal static Diagnostic CreateAnalyzerExceptionDiagnostic(DiagnosticAnalyzer analyzer, Exception e) 71return Diagnostic.Create(descriptor, Location.None, analyzerName, e.GetType(), e.Message); 227public static async Task<ImmutableArray<Diagnostic>> ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync( 236ImmutableArray<Diagnostic> diagnostics; 268public static async Task<ImmutableArray<Diagnostic>> ComputeProjectDiagnosticAnalyzerDiagnosticsAsync( 276ImmutableArray<Diagnostic> diagnostics; 305private static async Task VerifyDiagnosticLocationsAsync(ImmutableArray<Diagnostic> diagnostics, Project project, CancellationToken cancellationToken) 307foreach (var diagnostic in diagnostics) 389public static IEnumerable<DiagnosticData> ConvertToLocalDiagnostics(IEnumerable<Diagnostic> diagnostics, TextDocument targetTextDocument, TextSpan? span = null) 391foreach (var diagnostic in diagnostics) 406static bool IsReportedInDocument(Diagnostic diagnostic, TextDocument targetTextDocument) 425internal static bool AreEquivalent(Diagnostic[] diagnosticsA, Diagnostic[] diagnosticsB) 427var set = new HashSet<Diagnostic>(diagnosticsA, DiagnosticComparer.Instance); 431private sealed class DiagnosticComparer : IEqualityComparer<Diagnostic?> 435public bool Equals(Diagnostic? x, Diagnostic? y) 445public int GetHashCode(Diagnostic? obj)
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer.Executor.cs (2)
511var loadDiagnostic = await document.State.GetLoadDiagnosticAsync(cancellationToken).ConfigureAwait(false); 535foreach (var generatorDiagnostic in generatorDiagnostics)
Features\UnifiedSuggestions\UnifiedSuggestedActions\IFixAllCodeFixSuggestedAction.cs (1)
16Diagnostic Diagnostic { get; }
Features\UnifiedSuggestions\UnifiedSuggestedActions\UnifiedFixAllCodeFixSuggestedAction.cs (2)
18public Diagnostic Diagnostic { get; } 27Diagnostic diagnostic)
Features\UnifiedSuggestions\UnifiedSuggestedActionsSource.cs (1)
216Diagnostic firstDiagnostic,
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (6)
Diagnostics\AbstractPullDiagnosticTestsBase.cs (4)
346public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 347=> SpecializedTasks.EmptyImmutableArray<Diagnostic>(); 349public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 352Diagnostic.Create(Descriptor, Location.Create(document.FilePath!, default, default))));
Diagnostics\AdditionalFileDiagnosticsTests.cs (1)
151=> context.ReportDiagnostic(Diagnostic.Create(_descriptor,
Diagnostics\WorkspaceProjectDiagnosticsTests.cs (1)
92=> context.ReportDiagnostic(Diagnostic.Create(_descriptor, location: null, "args"));
Microsoft.CodeAnalysis.Rebuild (1)
VisualBasicCompilationFactory.cs (1)
78var diagnostic = diagnostics?.FirstOrDefault(x => x.IsUnsuppressedError);
Microsoft.CodeAnalysis.Remote.ServiceHub (2)
Services\EditAndContinue\RemoteEditAndContinueService.cs (2)
161var diagnostic = Diagnostic.Create(descriptor, Location.None, new[] { e.Message });
Microsoft.CodeAnalysis.Scripting (8)
CompilationErrorException.cs (2)
20public ImmutableArray<Diagnostic> Diagnostics { get; } 22public CompilationErrorException(string message, ImmutableArray<Diagnostic> diagnostics)
Hosting\CommandLine\CommandLineRunner.cs (3)
127var errors = _compiler.Arguments.Errors.Concat(diagnosticsInfos.Select(Diagnostic.Create)); 368private void DisplayDiagnostics(ImmutableArray<Diagnostic> diagnostics) 381foreach (var diagnostic in ordered.Take(MaxDisplayCount))
Script.cs (3)
231public ImmutableArray<Diagnostic> Compile(CancellationToken cancellationToken = default(CancellationToken)) 234internal abstract ImmutableArray<Diagnostic> CommonCompile(CancellationToken cancellationToken); 332internal override ImmutableArray<Diagnostic> CommonCompile(CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Test.Utilities (218)
AssemblyLoadTestFixture.cs (1)
461CSharpCompilationOptions options = new(OutputKind.DynamicallyLinkedLibrary, warningLevel: Diagnostic.MaxWarningLevel);
Compilation\DiagnosticBagErrorLogger.cs (1)
19public override void LogDiagnostic(Diagnostic diagnostic, SuppressionInfo? suppressionInfo)
Compilation\Exceptions.cs (2)
19public IEnumerable<Diagnostic> Diagnostics { get; } 21public EmitException(IEnumerable<Diagnostic> diagnostics, string directory)
Compilation\IRuntimeEnvironment.cs (1)
398ImmutableArray<Diagnostic> GetDiagnostics();
Compilation\NullErrorLogger.cs (1)
14public override void LogDiagnostic(Diagnostic diagnostic, SuppressionInfo? suppressionInfo)
CompilationVerifier.cs (2)
36private ImmutableArray<Diagnostic> _diagnostics; 57internal ImmutableArray<Diagnostic> Diagnostics => _diagnostics;
Diagnostics\BoxingOperationAnalyzer.cs (1)
79context.ReportDiagnostic(Diagnostic.Create(BoxingDescriptor, boxingExpression.GetLocation()));
Diagnostics\CommonDiagnosticAnalyzers.cs (84)
71context.ReportDiagnostic(Diagnostic.Create(Descriptor1, location, s_properties)); 76context.ReportDiagnostic(Diagnostic.Create(Descriptor2, Location.None, s_properties))); 436foreach (var diagnostic in context.ReportedDiagnostics) 478compilationContext.ReportDiagnostic(Diagnostic.Create(EnabledRule, Location.None)); 481compilationContext.ReportDiagnostic(Diagnostic.Create(DisabledRule, Location.None)); 524codeBlockContext.ReportDiagnostic(Diagnostic.Create(CodeBlockTopLevelRule, codeBlockContext.OwningSymbol.Locations[0], codeBlockContext.OwningSymbol.Name)); 533codeBlockContext.ReportDiagnostic(Diagnostic.Create(CodeBlockPerCompilationRule, codeBlockContext.OwningSymbol.Locations[0], codeBlockContext.OwningSymbol.Name)); 572syntaxNodeContext.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptor, syntaxNodeContext.Node.GetLocation())); 602context.ReportDiagnostic(Diagnostic.Create(Rule, context.Node.GetLocation())); 642context.ReportDiagnostic(Diagnostic.Create(Rule, context.Node.GetLocation())); 680context.ReportDiagnostic(Diagnostic.Create(Rule, context.Symbol.Locations[0])); 712context.ReportDiagnostic(Diagnostic.Create(Rule, ns.Locations[0])); 739compilationContext.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None))); 770compilationContext.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None))); 791compilationContext.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None))); 818c.ReportDiagnostic(Diagnostic.Create(Descriptor, SourceLocation.Create(c.Tree, _badSpan))); 862private void ReportDiagnostic(Action<Diagnostic> addDiagnostic, ActionKind actionKindBeingRun) 866var diagnostic = _testInvalidAdditionalLocation ? 867Diagnostic.Create(Descriptor, Location.None, additionalLocations: new[] { _invalidLocation }) : 868Diagnostic.Create(Descriptor, _invalidLocation); 917symbolContext.ReportDiagnostic(Diagnostic.Create(Rule, symbolContext.Symbol.Locations[0])); 957symbolContext.ReportDiagnostic(Diagnostic.Create(Rule, symbolContext.Symbol.Locations[0], symbolContext.Symbol.Name)); 995context.ReportDiagnostic(Diagnostic.Create(Descriptor, tree.GetRoot().GetLocation())); 1067var diagnostic = Diagnostic.Create(Descriptor, symbolContext.Symbol.Locations[0], symbolContext.Symbol.Name); 1109var diagnostic = Diagnostic.Create(Descriptor, symbolContext.Symbol.Locations[0]); 1151private void ReportDiagnostic(Action<Diagnostic> addDiagnostic, Location location) 1153var diagnostic = Diagnostic.Create(Descriptor, location, _actionKind); 1282var diagnostic = Diagnostic.Create(Descriptor, c.OwningSymbol.Locations[0], c.OwningSymbol.Name, operationRoot.Kind); 1333private static void AnalyzerFieldReferenceOperation(IFieldReferenceOperation operation, Action<Diagnostic> reportDiagnostic) 1335var diagnostic = Diagnostic.Create(Descriptor, operation.Syntax.GetLocation(), operation.Field.Name, operation.Field.ConstantValue); 1356var diagnostic = Diagnostic.Create(Descriptor, operationContext.Operation.Syntax.GetLocation(), operationContext.ContainingSymbol.Name); 1543var diagnostic = Diagnostic.Create(rule, Location.None, args); 1548private void ReportSymbolDiagnostics(ISymbol symbol, Action<Diagnostic> addDiagnostic) 1553private void ReportTreeDiagnostics(SyntaxTree tree, Action<Diagnostic> addDiagnostic) 1558private void ReportDiagnosticsCore(Action<Diagnostic> addDiagnostic, Location location, params object[] messageArguments) 1561var diagnostic = Diagnostic.Create(Warning, location, messageArguments); 1565diagnostic = Diagnostic.Create(Error, location, messageArguments); 1596var diagnostic = Diagnostic.Create(Rule, namedType.Locations[0], namedType.Name, namedTypes.Count); 1704var diagnostic = Diagnostic.Create(descriptor, symbolContext.Symbol.Locations[0], symbolContext.Symbol.Name); 1713var diagnostic = Diagnostic.Create(descriptor, Location.None, treeContext.Tree.FilePath); 1717diagnostic = Diagnostic.Create(UniqueTextFileDescriptor, Location.None, treeContext.Tree.FilePath); 1728var diagnostic = Diagnostic.Create(NumberOfUniqueTextFileDescriptor, Location.None, _textCallbackSet.Count); 1754context.ReportDiagnostic(Diagnostic.Create(ParameterDescriptor, context.Symbol.Locations[0])); 1868var diagnostics = new ConcurrentBag<Diagnostic>(); 1924compilationEndContext.ReportDiagnostic(Diagnostic.Create(SymbolStartedEndedDifferRule, Location.None, symbolsStartedStr, symbolsEndedStr, _analyzerId)); 1927foreach (var diagnostic in diagnostics) 1939diagnostics.Add(Diagnostic.Create(DuplicateStartActionRule, Location.None, symbolStartContext.Symbol.Name, _analyzerId)); 1949diagnostics.Add(Diagnostic.Create(DuplicateEndActionRule, Location.None, symbolEndContext.Symbol.Name, _analyzerId)); 1954symbolEndContext.ReportDiagnostic(Diagnostic.Create(rule, Location.None, symbolStartContext.Symbol.Name, _analyzerId)); 1964operationContext.ReportDiagnostic(Diagnostic.Create(OperationRule, Location.None, symbolStartContext.Symbol.Name, operationContext.ContainingSymbol.Name, operationContext.Operation.Syntax.ToString(), _analyzerId)); 2000diagnostics.Add(Diagnostic.Create(SymbolStartedOrderingRule, Location.None, member, symbolStarted, _analyzerId)); 2024diagnostics.Add(Diagnostic.Create(SymbolEndedOrderingRule, Location.None, container, symbolEnded, _analyzerId)); 2039diagnostics.Add(Diagnostic.Create(OperationOrderingRule, Location.None, symbolStartContext.Symbol, operationContext.Operation.Syntax.ToString(), _analyzerId)); 2063foreach (var diagnostic in context.ReportedDiagnostics) 2160foreach (var diagnostic in context.ReportedDiagnostics) 2192foreach (var diagnostic in context.ReportedDiagnostics) 2224var nonReportedDiagnostic = Diagnostic.Create( 2309Diagnostic.Create(_rule, Location.None, GetSortedSymbolCallbacksString()))); 2316private void ReportDiagnostic(ISymbol symbol, Action<Diagnostic> reportDiagnostic) 2317=> reportDiagnostic(Diagnostic.Create(_rule, symbol.Locations[0], symbol.Name)); 2340compilationContext.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None))); 2372context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Symbol.Locations[0])); 2399endContext => endContext.ReportDiagnostic(Diagnostic.Create(s_descriptor, context.OwningSymbol.Locations[0]))); 2432context.ReportDiagnostic(Diagnostic.Create(Descriptor, variable.Identifier.GetLocation())); 2439context => context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Symbol.Locations[0])), 2490context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); 2526context.ReportDiagnostic(Diagnostic.Create(s_descriptor, context.Tree.GetRoot().GetLocation())); 2556context => context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Node.GetLocation())), 2562context => context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Operation.Syntax.GetLocation())), 2625private void HandleCallback(Location analysisLocation, Compilation compilation, Action<Diagnostic> reportDiagnostic, CancellationToken cancellationToken) 2642reportDiagnostic(Diagnostic.Create(s_descriptor, analysisLocation));
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (2)
295context.ReportDiagnostic(Diagnostic.Create(descriptor, local.Locations.FirstOrDefault(), local, moreSpecificType)); 300context.ReportDiagnostic(Diagnostic.Create(descriptor, field.Locations.FirstOrDefault(), field, moreSpecificType));
Diagnostics\DiagnosticDescription.cs (7)
122public DiagnosticDescription(Diagnostic d, bool errorCodeOnly, bool includeDefaultSeverity = false, bool includeEffectiveSeverity = false) 486public static string GetAssertText(DiagnosticDescription[] expected, IEnumerable<Diagnostic> actual, DiagnosticDescription[] unamtchedExpected, IEnumerable<Diagnostic> unmatchedActual) 522Diagnostic d = e.Current; 568Diagnostic d = e.Current; 583private static IEnumerable<Diagnostic> Sort(IEnumerable<Diagnostic> diagnostics)
Diagnostics\DiagnosticExtensions.cs (29)
31public static void VerifyErrorCodes(this IEnumerable<Diagnostic> actual, params DiagnosticDescription[] expected) 36public static void VerifyErrorCodes(this ImmutableArray<Diagnostic> actual, params DiagnosticDescription[] expected) 38VerifyErrorCodes((IEnumerable<Diagnostic>)actual, expected); 46public static void Verify(this IEnumerable<Diagnostic> actual, params DiagnosticDescription[] expected) 51public static void Verify(this IEnumerable<Diagnostic> actual, bool fallbackToErrorCodeOnlyForNonEnglish, params DiagnosticDescription[] expected) 56public static void VerifyWithFallbackToErrorCodeOnlyForNonEnglish(this IEnumerable<Diagnostic> actual, params DiagnosticDescription[] expected) 61public static void Verify(this ImmutableArray<Diagnostic> actual, params DiagnosticDescription[] expected) 63Verify((IEnumerable<Diagnostic>)actual, expected); 66private static void Verify(IEnumerable<Diagnostic> actual, DiagnosticDescription[] expected, bool errorCodeOnly) 116TCompilation c, ImmutableArray<Diagnostic> diagnostics) where TCompilation : Compilation 118foreach (var diagnostic in diagnostics) 146Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null) 156Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, 168Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, 177public static ImmutableArray<Diagnostic> GetAnalyzerDiagnostics<TCompilation>( 181Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, 188public static ImmutableArray<Diagnostic> GetAnalyzerDiagnostics<TCompilation>( 193Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, 205Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, 227Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException, 285Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException = null, 299Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException, 303out ImmutableArray<Diagnostic> diagnostics) 339public static IEnumerable<Diagnostic> GetEffectiveDiagnostics(this Compilation compilation, IEnumerable<Diagnostic> diagnostics) 359public static ImmutableArray<Diagnostic> GetEmitDiagnostics<TCompilation>( 375public static ImmutableArray<Diagnostic> GetEmitDiagnostics<TCompilation>(this TCompilation c) 444public static string Inspect(this Diagnostic e) 448public static string ToString(this Diagnostic d, IFormatProvider formatProvider)
Diagnostics\DiagnosticsHelper.cs (1)
25private static void VerifyDiagnostics(IEnumerable<Diagnostic> actualDiagnostics, params string[] expectedDiagnosticIds)
Diagnostics\EmptyArrayAnalyzer.cs (1)
56context.ReportDiagnostic(Diagnostic.Create(UseArrayEmptyDescriptor, arrayCreationExpression.GetLocation()));
Diagnostics\FieldCouldBeReadOnlyAnalyzer.cs (1)
144context.ReportDiagnostic(Diagnostic.Create(descriptor, field.Locations.FirstOrDefault()));
Diagnostics\LocalCouldBeConstAnalyzer.cs (1)
135context.ReportDiagnostic(Diagnostic.Create(descriptor, local.Locations.FirstOrDefault()));
Diagnostics\OperationTestAnalyzer.cs (64)
59operationContext.ReportDiagnostic(Diagnostic.Create(InvalidStatementDescriptor, operationContext.Operation.Syntax.GetLocation())); 63operationContext.ReportDiagnostic(Diagnostic.Create(InvalidExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 73operationContext.ReportDiagnostic(Diagnostic.Create(IsInvalidDescriptor, operationContext.Operation.Syntax.GetLocation())); 109operationContext.ReportDiagnostic(Diagnostic.Create(ExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 288context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 484context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 549operationContext.ReportDiagnostic(Diagnostic.Create(InvalidArgumentDescriptor, argument.Syntax.GetLocation())); 555operationContext.ReportDiagnostic(Diagnostic.Create(UseDefaultArgumentDescriptor, invocation.Syntax.GetLocation(), argument.Parameter.Name)); 601context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 635operationContext.ReportDiagnostic(Diagnostic.Create(SeventeenDescriptor, literal.Syntax.GetLocation())); 678context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 724context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 765context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 805context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 862context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 923context.ReportDiagnostic(Diagnostic.Create(descriptor, syntax.GetLocation())); 954operationContext.ReportDiagnostic(Diagnostic.Create(instanceReference.IsImplicit ? ImplicitInstanceDescriptor : ExplicitInstanceDescriptor, 1034operationContext.ReportDiagnostic(Diagnostic.Create(EventReferenceDescriptor, operationContext.Operation.Syntax.GetLocation())); 1042operationContext.ReportDiagnostic(Diagnostic.Create(eventAssignment.Adds ? HandlerAddedDescriptor : HandlerRemovedDescriptor, operationContext.Operation.Syntax.GetLocation())); 1046operationContext.ReportDiagnostic(Diagnostic.Create(InvalidEventDescriptor, eventAssignment.Syntax.GetLocation())); 1054operationContext.ReportDiagnostic(Diagnostic.Create(PropertyReferenceDescriptor, operationContext.Operation.Syntax.GetLocation())); 1061operationContext.ReportDiagnostic(Diagnostic.Create(FieldReferenceDescriptor, operationContext.Operation.Syntax.GetLocation())); 1068operationContext.ReportDiagnostic(Diagnostic.Create(MethodBindingDescriptor, operationContext.Operation.Syntax.GetLocation())); 1111operationContext.ReportDiagnostic(Diagnostic.Create(LongParamsDescriptor, argument.Value.Syntax.GetLocation())); 1126operationContext.ReportDiagnostic(Diagnostic.Create(InvalidConstructorDescriptor, creation.Syntax.GetLocation())); 1138operationContext.ReportDiagnostic(Diagnostic.Create(LongParamsDescriptor, argument.Value.Syntax.GetLocation())); 1184operationContext.ReportDiagnostic(Diagnostic.Create(EqualsValueDescriptor, equalsValue.Syntax.GetLocation())); 1195operationContext.ReportDiagnostic(Diagnostic.Create(EqualsValueDescriptor, equalsValue.Syntax.GetLocation())); 1226operationContext.ReportDiagnostic(Diagnostic.Create(NoneOperationDescriptor, operationContext.Operation.Syntax.GetLocation())); 1262operationContext.ReportDiagnostic(Diagnostic.Create(AddressOfDescriptor, addressOfOperation.Syntax.GetLocation())); 1266operationContext.ReportDiagnostic(Diagnostic.Create(InvalidAddressOfReferenceDescriptor, addressOfOperation.Reference.Syntax.GetLocation())); 1314operationContext.ReportDiagnostic(Diagnostic.Create(LambdaExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 1323operationContext.ReportDiagnostic(Diagnostic.Create(TooManyStatementsInLambdaExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 1336operationContext.ReportDiagnostic(Diagnostic.Create(NoneOperationInLambdaExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 1408operationContext.ReportDiagnostic(Diagnostic.Create(StaticMemberDescriptor, operation.Syntax.GetLocation())); 1412operationContext.ReportDiagnostic(Diagnostic.Create(StaticMemberWithInstanceDescriptor, operation.Syntax.GetLocation())); 1452operationContext.ReportDiagnostic(Diagnostic.Create(LabelDescriptor, operationContext.Operation.Syntax.GetLocation())); 1466operationContext.ReportDiagnostic(Diagnostic.Create(GotoDescriptor, branch.Syntax.GetLocation())); 1518operationContext.ReportDiagnostic(Diagnostic.Create(OperatorAddMethodDescriptor, binary.Syntax.GetLocation())); 1523operationContext.ReportDiagnostic(Diagnostic.Create(DoubleMultiplyDescriptor, binary.Syntax.GetLocation())); 1534operationContext.ReportDiagnostic(Diagnostic.Create(OperatorMinusMethodDescriptor, unary.Syntax.GetLocation())); 1539operationContext.ReportDiagnostic(Diagnostic.Create(BooleanNotDescriptor, unary.Syntax.GetLocation())); 1544operationContext.ReportDiagnostic(Diagnostic.Create(BooleanNotDescriptor, unary.Syntax.GetLocation())); 1573Diagnostic.Create(BinaryUserDefinedOperatorDescriptor, 1626Diagnostic.Create(BinaryOperatorDescriptor, 1650Diagnostic.Create(UnaryOperatorDescriptor, 1701Diagnostic.Create(NullOperationSyntaxDescriptor, null)); 1706Diagnostic.Create(ParamsArrayOperationDescriptor, 1791operationContext.ReportDiagnostic(Diagnostic.Create(InvalidBinaryDescriptor, binary.Syntax.GetLocation())); 1799operationContext.ReportDiagnostic(Diagnostic.Create(InvalidUnaryDescriptor, unary.Syntax.GetLocation())); 1807operationContext.ReportDiagnostic(Diagnostic.Create(InvalidIncrementDescriptor, inc.Syntax.GetLocation())); 1848operationContext.ReportDiagnostic(Diagnostic.Create(ConditionalAccessOperationDescriptor, conditionalAccess.Syntax.GetLocation())); 1857operationContext.ReportDiagnostic(Diagnostic.Create(ConditionalAccessInstanceOperationDescriptor, conditionalAccessInstance.Syntax.GetLocation())); 1897operationContext.ReportDiagnostic(Diagnostic.Create(InvalidConversionExpressionDescriptor, conversion.Syntax.GetLocation())); 1935operationContext.ReportDiagnostic(Diagnostic.Create(ForLoopConditionCrashDescriptor, forLoop.LimitValue.Syntax.GetLocation())); 1974operationContext.ReportDiagnostic(Diagnostic.Create(UnaryTrueDescriptor, unary.Syntax.GetLocation())); 1978operationContext.ReportDiagnostic(Diagnostic.Create(UnaryFalseDescriptor, unary.Syntax.GetLocation())); 2015operationContext.ReportDiagnostic(Diagnostic.Create(AssignmentOperationDescriptor, operationContext.Operation.Syntax.GetLocation())); 2023syntaxContext.ReportDiagnostic(Diagnostic.Create(AssignmentSyntaxDescriptor, syntaxContext.Node.GetLocation())); 2052operationContext.ReportDiagnostic(Diagnostic.Create(LiteralDescriptor, literal.Syntax.GetLocation(), literal.Syntax.ToString())); 2080Diagnostic.Create(OperationActionDescriptor, operationContext.Operation.Syntax.GetLocation(), "Operation", "Analysis")); 2111Diagnostic.Create(OperationActionDescriptor, operationContext.Operation.Syntax.GetLocation(), "Operation", "CompilationStart within Analysis")); 2143syntaxContext.ReportDiagnostic(Diagnostic.Create(GetOperationDescriptor, node.GetLocation())); 2155syntaxContext.ReportDiagnostic(Diagnostic.Create(GetOperationDescriptor, node.GetLocation()));
Diagnostics\SuppressMessageAttributeTests.DiagnosticAnalyzers.cs (9)
43context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, Location.None, messageArgs: Id)); 69context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, context.Symbol.Locations.First(), messageArgs: context.Symbol.Name)); 100context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, context.Symbol.Locations.First(), messageArgs: context.Symbol.Name)); 154context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, context.OwningSymbol.Locations.First(), messageArgs: context.OwningSymbol.Name + ":end")); 160context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, context.Node.GetLocation(), messageArgs: context.Node.ToFullString())); 173context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, context.OwningSymbol.Locations.First(), messageArgs: context.OwningSymbol.Name + ":end")); 179context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, context.Node.GetLocation(), messageArgs: context.Node.ToFullString())); 213context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, comment.GetLocation(), messageArgs: comment.ToFullString())); 248context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_rule, nodeOrToken.GetLocation(), messageArgs: nodeOrToken.ToString()));
Diagnostics\ThrowingDiagnosticAnalyzer.cs (3)
61public static void VerifyAnalyzerEngineIsSafeAgainstExceptions(Func<DiagnosticAnalyzer, IEnumerable<Diagnostic>> runAnalysis) 66public static async Task VerifyAnalyzerEngineIsSafeAgainstExceptionsAsync(Func<DiagnosticAnalyzer, IEnumerable<Diagnostic>> runAnalysis) 71public static async Task VerifyAnalyzerEngineIsSafeAgainstExceptionsAsync(Func<DiagnosticAnalyzer, Task<IEnumerable<Diagnostic>>> runAnalysis)
ExceptionHelper.cs (2)
16internal static string GetMessageFromResult(IEnumerable<Diagnostic> diagnostics, string directory) 21foreach (var d in diagnostics)
Mocks\TestMessageProvider.cs (2)
21public override Diagnostic CreateDiagnostic(int code, Location location, params object[] args) 26public override Diagnostic CreateDiagnostic(DiagnosticInfo info)
Platform\CoreClr\CoreCLRRuntimeEnvironment.cs (2)
102public ImmutableArray<Diagnostic> GetDiagnostics() => GetEmitData().Diagnostics; 162internal ImmutableArray<Diagnostic> Diagnostics;
SourceGeneration\TestGenerators.cs (1)
67context.ReportDiagnostic(Diagnostic.Create(Descriptor, _produceLocation(context)));
Microsoft.CodeAnalysis.UnitTests (16)
CorLibTypesTests.cs (1)
69options: new CSharp.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, warningLevel: CodeAnalysis.Diagnostic.MaxWarningLevel),
Diagnostics\CompilationWithAnalyzersTests.cs (6)
19using SimpleDiagnostic = Diagnostic.SimpleDiagnostic; 23private static readonly CSharpCompilationOptions s_dllWithMaxWarningLevel = new(OutputKind.DynamicallyLinkedLibrary, warningLevel: CodeAnalysis.Diagnostic.MaxWarningLevel); 29var ds = new[] { (Diagnostic)null }; 31Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(default(ImmutableArray<Diagnostic>), c)); 43var d1 = SimpleDiagnostic.Create(MessageProvider.Instance, (int)ErrorCode.WRN_AlignmentMagnitude, "1", "2"); 44var d2 = SimpleDiagnostic.Create(MessageProvider.Instance, (int)ErrorCode.WRN_AlwaysNull, "1");
Diagnostics\DiagnosticCreationTests.cs (2)
20var diagnostic = Diagnostic.Create(descriptor, Location.None, effectiveSeverity, additionalLocations: null, properties: null);
Diagnostics\DiagnosticLocalizationTests.cs (4)
87var localizableDiagnostic = Diagnostic.Create(descriptor, Location.None); 302var exceptionDiagnostics = new List<Diagnostic>(); 304Action<Exception, DiagnosticAnalyzer, Diagnostic, CancellationToken> onAnalyzerException = (ex, a, diag, ct) => exceptionDiagnostics.Add(diag);
Diagnostics\SarifErrorLoggerTests.cs (3)
44logger.LogDiagnostic(Diagnostic.Create(descriptor, mainLocation, additionalLocations), null); 82logger.LogDiagnostic(Diagnostic.Create(descriptor, Location.None), null); 115logger.LogDiagnostic(Diagnostic.Create(
Microsoft.CodeAnalysis.VisualBasic (131)
Binding\Binder.vb (2)
894Public Shared Sub ReportDiagnostic(diagBag As DiagnosticBag, diag As Diagnostic) 924Public Shared Sub ReportDiagnostic(diagBag As BindingDiagnosticBag, diag As Diagnostic)
Binding\Binder_Expressions.vb (1)
1085For Each diag As Diagnostic In tree.GetDiagnostics(root)
Binding\MemberSemanticModel.vb (4)
413Public NotOverridable Overrides Function GetSyntaxDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 428Public NotOverridable Overrides Function GetDeclarationDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 443Public NotOverridable Overrides Function GetMethodBodyDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 460Public NotOverridable Overrides Function GetDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic)
CommandLine\CommandLineDiagnosticFormatter.vb (2)
30Public Overrides Function Format(diagnostic As Diagnostic, Optional formatter As IFormatProvider = Nothing) As String 130Private Function GetDiagnosticSpanAndFileText(diagnostic As Diagnostic, <Out> ByRef text As SourceText) As TextSpan?
CommandLine\VisualBasicCommandLineParser.vb (25)
82Dim diagnostics As List(Of Diagnostic) = New List(Of Diagnostic)() 237Dim conditionalCompilationDiagnostics As IEnumerable(Of Diagnostic) = Nothing 1569Private Shared Function GetWin32Setting(arg As String, value As String, diagnostics As List(Of Diagnostic)) As String 1619Private Shared Sub ValidateWin32Settings(noWin32Manifest As Boolean, win32ResSetting As String, win32IconSetting As String, win32ManifestSetting As String, outputKind As OutputKind, diagnostics As List(Of Diagnostic)) 1639Private Shared Function ParseTarget(optionName As String, value As String, diagnostics As IList(Of Diagnostic)) As OutputKind 1662Friend Shared Function ParseAssemblyReferences(name As String, value As String, diagnostics As IList(Of Diagnostic), embedInteropTypes As Boolean) As IEnumerable(Of CommandLineReference) 1673Private Shared Function ParseAnalyzers(name As String, value As String, diagnostics As IList(Of Diagnostic)) As IEnumerable(Of CommandLineAnalyzerReference) 1687Friend Overloads Shared Function ParseResourceDescription(name As String, resourceDescriptor As String, baseDirectory As String, diagnostics As IList(Of Diagnostic), embedded As Boolean) As ResourceDescription 1746Private Shared Sub AddInvalidSwitchValueDiagnostic(diagnostics As IList(Of Diagnostic), ByVal name As String, ByVal nullStringText As String) 1756Private Shared Sub ParseGlobalImports(value As String, globalImports As List(Of GlobalImport), errors As List(Of Diagnostic)) 1760Dim importDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 1773diagnosticBuilder As ArrayBuilder(Of Diagnostic)) As ImmutableDictionary(Of String, InternalSyntax.CConst) 1782diagnosticBuilder.Add(Diagnostic.Create(VisualBasic.MessageProvider.Instance, ERRID.ERR_InvalidPreprocessorConstantType, symbol.Key, symbol.Value.GetType())) 1819<Out> ByRef diagnostics As IEnumerable(Of Diagnostic), 1823Dim diagnosticBuilder = ArrayBuilder(Of Diagnostic).GetInstance() 2080Private Shared Iterator Function ParseInstrumentationKinds(value As String, diagnostics As IList(Of Diagnostic)) As IEnumerable(Of InstrumentationKind) 2127Private Shared Function ParsePlatform(name As String, value As String, errors As List(Of Diagnostic)) As Platform 2161Private Shared Function ParseFileAlignment(name As String, value As String, errors As List(Of Diagnostic)) As Integer 2184Private Shared Function ParseBaseAddress(name As String, value As String, errors As List(Of Diagnostic)) As ULong 2254Private Shared Sub UnimplementedSwitch(diagnostics As IList(Of Diagnostic), switchName As String) 2258Friend Overrides Sub GenerateErrorForNoFilesFoundInRecurse(path As String, errors As IList(Of Diagnostic)) 2262Private Shared Sub AddDiagnostic(diagnostics As IList(Of Diagnostic), errorCode As ERRID, ParamArray arguments As Object()) 2263diagnostics.Add(Diagnostic.Create(VisualBasic.MessageProvider.Instance, CInt(errorCode), arguments)) 2282Private Sub GetCompilationAndModuleNames(diagnostics As List(Of Diagnostic),
Compilation\MethodCompiler.vb (2)
669If CType(method, SourceMethodSymbol).SetDiagnostics(ImmutableArray(Of Diagnostic).Empty) Then 1228If sourceMethod IsNot Nothing AndAlso sourceMethod.SetDiagnostics(ImmutableArray(Of Diagnostic).Empty) Then
Compilation\SpeculativeSemanticModelWithMemberModel.vb (4)
137Public Overrides Function GetSyntaxDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 141Public Overrides Function GetDeclarationDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 145Public Overrides Function GetMethodBodyDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 149Public Overrides Function GetDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic)
Compilation\SpeculativeSyntaxTreeSemanticModel.vb (3)
113Public Overrides Function GetSyntaxDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 117Public Overrides Function GetDeclarationDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 121Public Overrides Function GetDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic)
Compilation\SyntaxTreeSemanticModel.vb (4)
93Public Overrides Function GetDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 105Public Overrides Function GetSyntaxDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 120Public Overrides Function GetDeclarationDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 135Public Overrides Function GetMethodBodyDiagnostics(Optional span As TextSpan? = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic)
Compilation\VisualBasicCompilation.vb (15)
119Private _lazyClsComplianceDiagnostics As ImmutableArray(Of Diagnostic) 1499Return New EntryPoint(Nothing, ImmutableArray(Of Diagnostic).Empty) 1503Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing 1511Private Function FindEntryPoint(cancellationToken As CancellationToken, ByRef sealedDiagnostics As ImmutableArray(Of Diagnostic)) As MethodSymbol 1666Public ReadOnly Diagnostics As ImmutableArray(Of Diagnostic) 1668Public Sub New(methodSymbol As MethodSymbol, diagnostics As ImmutableArray(Of Diagnostic)) 2070Public Overrides Function GetDiagnostics(Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 2079Public Overrides Function GetParseDiagnostics(Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 2089Public Overrides Function GetDeclarationDiagnostics(Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 2099Public Overrides Function GetMethodBodyDiagnostics(Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 2112Friend Overloads Function GetDiagnostics(stage As CompilationStage, Optional includeEarlierStages As Boolean = True, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 2222Private Shared Iterator Function FilterDiagnosticsByLocation(diagnostics As IEnumerable(Of Diagnostic), tree As SyntaxTree, filterSpanWithinTree As TextSpan?) As IEnumerable(Of Diagnostic) 2234Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic) 2275Return result.ToReadOnlyAndFree(Of Diagnostic)()
Compilation\VisualBasicDiagnosticFilter.vb (5)
12''' Applies Visual Basic-specific modification and filtering of <see cref="Diagnostic"/>s. 20''' Modifies an input <see cref="Diagnostic"/> per the given options. For example, the 21''' severity may be escalated, or the <see cref="Diagnostic"/> may be filtered out entirely 29diagnostic As Diagnostic, 33cancellationToken As CancellationToken) As Diagnostic
Errors\ErrorFactories.vb (1)
130Return Diagnostic.CompilerDiagnosticCategory
Errors\MessageProvider.vb (2)
103Public Overrides Function CreateDiagnostic(code As Integer, location As Location, ParamArray args() As Object) As Diagnostic 107Public Overrides Function CreateDiagnostic(info As DiagnosticInfo) As Diagnostic
Errors\VBDiagnostic.vb (3)
21Friend Overrides Function WithLocation(location As Location) As Diagnostic 33Friend Overrides Function WithSeverity(severity As DiagnosticSeverity) As Diagnostic 41Friend Overrides Function WithIsSuppressed(isSuppressed As Boolean) As Diagnostic
GlobalImport.vb (5)
68Public Shared Function Parse(importedNames As String, <Out()> ByRef diagnostics As ImmutableArray(Of Diagnostic)) As GlobalImport 103Public Shared Function Parse(importedNames As IEnumerable(Of String), <Out()> ByRef diagnostics As ImmutableArray(Of Diagnostic)) As IEnumerable(Of GlobalImport) 106diagnostics = errors.ToReadOnlyAndFree(Of Diagnostic)() 111Friend Function MapDiagnostic(unmappedDiag As Diagnostic) As Diagnostic
OptionsValidator.vb (1)
41Dim syntaxErrors As IEnumerable(Of Diagnostic) = clause.GetSyntaxErrors(tree)
Symbols\Source\SourceAssemblySymbol.vb (1)
67Private _lazyAssemblyLevelDeclarationErrors As ImmutableArray(Of Diagnostic)
Symbols\Source\SourceFile.vb (1)
464Friend Function GetDeclarationErrorsInSpan(filterSpan As TextSpan, cancellationToken As CancellationToken) As IEnumerable(Of Diagnostic)
Symbols\Source\SourceMethodSymbol.vb (3)
56Private _cachedDiagnostics As ImmutableArray(Of Diagnostic) 565Friend ReadOnly Property Diagnostics As ImmutableArray(Of Diagnostic) 574Friend Function SetDiagnostics(diags As ImmutableArray(Of Diagnostic)) As Boolean
Symbols\Source\SourceModuleSymbol.vb (8)
79Private _lazyLinkedAssemblyDiagnostics As ImmutableArray(Of Diagnostic) 382For Each d As Diagnostic In diagBagForThisImport.DiagnosticBag.AsEnumerable() 573locationFilter As Func(Of IEnumerable(Of Diagnostic), SyntaxTree, TextSpan?, IEnumerable(Of Diagnostic)), 574cancellationToken As CancellationToken) As ImmutableArray(Of Diagnostic) 575Dim builder = ArrayBuilder(Of Diagnostic).GetInstance() 630For Each d As Diagnostic In declarationDiagnostics 1036For Each d As Diagnostic In diagBag.DiagnosticBag.AsEnumerableWithoutResolution()
Symbols\Source\SynthesizedMyGroupCollectionPropertyAccessorSymbol.vb (1)
80For Each diag As Diagnostic In tree.GetDiagnostics(root)
Syntax\SyntaxTreeDiagnosticEnumerator.vb (2)
31Private _current As Diagnostic 147Public ReadOnly Property Current As Diagnostic
Syntax\VisualBasicSyntaxNode.vb (10)
194Friend Shared EmptyErrorCollection As New ReadOnlyCollection(Of Diagnostic)(Array.Empty(Of Diagnostic)) 200Friend Function GetSyntaxErrors(tree As SyntaxTree) As ReadOnlyCollection(Of Diagnostic) 204Friend Shared Function DoGetSyntaxErrors(tree As SyntaxTree, nodeOrToken As SyntaxNodeOrToken) As ReadOnlyCollection(Of Diagnostic) 211Dim errorList As New List(Of Diagnostic) 238Return New ReadOnlyCollection(Of Diagnostic)(errorList) 257errorList As List(Of Diagnostic), 283Private Shared Function CreateSyntaxError(tree As SyntaxTree, nodeOrToken As SyntaxNodeOrToken, errorInfo As DiagnosticInfo) As Diagnostic 290Private Shared Function CreateSyntaxError(tree As SyntaxTree, nodeOrToken As SyntaxTrivia, errorInfo As DiagnosticInfo) As Diagnostic 477Public Shadows Function GetDiagnostics() As IEnumerable(Of Diagnostic)
Syntax\VisualBasicSyntaxTree.vb (8)
317Public Overrides Function GetDiagnostics(node As SyntaxNode) As IEnumerable(Of Diagnostic) 329Public Overrides Function GetDiagnostics(token As SyntaxToken) As IEnumerable(Of Diagnostic) 339Public Overrides Function GetDiagnostics(trivia As SyntaxTrivia) As IEnumerable(Of Diagnostic) 350Public Overrides Function GetDiagnostics(nodeOrToken As SyntaxNodeOrToken) As IEnumerable(Of Diagnostic) 360Public Overrides Function GetDiagnostics(Optional cancellationToken As CancellationToken = Nothing) As IEnumerable(Of Diagnostic) 364Friend Iterator Function EnumerateDiagnostics(node As InternalSyntax.VisualBasicSyntaxNode, position As Integer, InDocumentationComment As Boolean) As IEnumerable(Of Diagnostic) 372Friend Overloads Function GetDiagnostics(node As InternalSyntax.VisualBasicSyntaxNode, position As Integer, InDocumentationComment As Boolean) As IEnumerable(Of Diagnostic) 380Return SpecializedCollections.EmptyEnumerable(Of Diagnostic)()
VisualBasicCompilationOptions.vb (13)
1023Friend Overrides Sub ValidateOptions(builder As ArrayBuilder(Of Diagnostic)) 1031builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_VBCoreNetModuleConflict)) 1035builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(Platform), Platform.ToString())) 1043builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(OutputKind), OutputKind.ToString())) 1047builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(OptimizationLevel), OptimizationLevel.ToString())) 1051builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(ScriptClassName), If(ScriptClassName, "Nothing"))) 1055builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(MainTypeName), MainTypeName)) 1059builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(RootNamespace), RootNamespace)) 1063builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(OptionStrict), OptionStrict.ToString())) 1068builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_LibAnycpu32bitPreferredConflict, NameOf(Platform), Platform.ToString())) 1072builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidSwitchValue, NameOf(MetadataImportOptions), MetadataImportOptions.ToString())) 1133Friend Overrides Function FilterDiagnostic(diagnostic As Diagnostic, cancellationToken As CancellationToken) As Diagnostic
VisualBasicExtensions.vb (1)
280Friend Function GetSyntaxErrors(token As SyntaxToken, tree As SyntaxTree) As ReadOnlyCollection(Of Diagnostic)
VisualBasicParseOptions.vb (4)
245Friend Overrides Sub ValidateOptions(builder As ArrayBuilder(Of Diagnostic)) 250builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_BadLanguageVersion, LanguageVersion.ToString)) 256builder.Add(Diagnostic.Create(ErrorFactory.ErrorInfo(ERRID.ERR_ConditionalCompilationConstantNotValid, 264builder.Add(Diagnostic.Create(MessageProvider.Instance, ERRID.ERR_InvalidPreprocessorConstantType, symbol.Key, symbol.Value.GetType))
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
VisualBasicRemoveUnnecessaryByValDiagnosticAnalyzer.vb (1)
29syntaxContext.ReportDiagnostic(Diagnostic.Create(Descriptor, modifier.GetLocation(), additionalLocations:={parameterSyntax.GetLocation()}))
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (11)
VisualBasicChangeToYieldCodeFixProvider.vb (1)
36Protected Overrides Function GetCodeFixAsync(root As SyntaxNode, node As SyntaxNode, document As Document, diagnostics As Diagnostic, cancellationToken As CancellationToken) As Task(Of CodeAction)
VisualBasicConvertToAsyncFunctionCodeFixProvider.vb (2)
35Protected Overrides Async Function GetDescriptionAsync(diagnostic As Diagnostic, node As SyntaxNode, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Task(Of String) 40Protected Overrides Async Function GetRootInOtherSyntaxTreeAsync(node As SyntaxNode, semanticModel As SemanticModel, diagnostic As Diagnostic, cancellationToken As CancellationToken) As Task(Of Tuple(Of SyntaxTree, SyntaxNode))
VisualBasicConvertToIteratorCodeFixProvider.vb (1)
38Protected Overrides Async Function GetCodeFixAsync(root As SyntaxNode, node As SyntaxNode, document As Document, diagnostics As Diagnostic, cancellationToken As CancellationToken) As Task(Of CodeAction)
VisualBasicMakeMethodAsynchronousCodeFixProvider.vb (1)
34Protected Overrides Function IsSupportedDiagnostic(diagnostic As Diagnostic, cancellationToken As CancellationToken) As Boolean
VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
27Protected Overrides Function GetNode(diagnostic As Diagnostic, cancellationToken As CancellationToken) As SimpleNameSyntax
VisualBasicRemoveUnnecessaryByValCodeFixProvider.vb (1)
37Protected Overrides Async Function FixAllAsync(document As Document, diagnostics As ImmutableArray(Of Diagnostic), editor As SyntaxEditor, fallbackOptions As CodeActionOptionsProvider, cancellationToken As CancellationToken) As Task
VisualBasicRemoveUnnecessaryCastCodeFixProvider.vb (1)
54diagnostics As ImmutableArray(Of Diagnostic),
VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
35Protected Overrides Async Function FixAllAsync(document As Document, diagnostics As ImmutableArray(Of Diagnostic), editor As SyntaxEditor, fallbackOptions As CodeActionOptionsProvider, cancellationToken As CancellationToken) As Task
VisualBasicUseIsNotExpressionCodeFixProvider.vb (2)
35diagnostics As ImmutableArray(Of Diagnostic), 50diagnostic As Diagnostic,
Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests (13)
CommandLineArgumentsTests.vb (4)
18Dim errors As IEnumerable(Of Diagnostic) = Nothing 132Dim errors As IEnumerable(Of Diagnostic) = Nothing 226Dim errors As IEnumerable(Of Diagnostic) = Nothing 281Dim errors As IEnumerable(Of Diagnostic) = Nothing
CommandLineTests.vb (9)
1161Dim diags = New List(Of Diagnostic)() 7790Private Shared Sub Verify(actual As IEnumerable(Of Diagnostic), ParamArray expected As DiagnosticDescription()) 9098Dim list As New List(Of Diagnostic) 10628context.ReportDiagnostic(Diagnostic.Create(Hidden01, context.Node.GetLocation())) 10653context.ReportDiagnostic(Diagnostic.Create(Info01, context.Node.GetLocation())) 10679context.ReportDiagnostic(Diagnostic.Create(Warning01, context.Symbol.Locations.First())) 10680context.ReportDiagnostic(Diagnostic.Create(Warning03, context.Symbol.Locations.First())) 10704context.ReportDiagnostic(Diagnostic.Create(Error01, context.Node.GetLocation())) 10754Dim diag = Diagnostic.Create(Rule, diagLocation, IO.Path.GetFileNameWithoutExtension(path))
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests (17)
Diagnostics\Configuration\ConfigureSeverity\DotNetDiagnosticSeverityBasedSeverityConfigurationTests.vb (1)
35Sub(c) c.ReportDiagnostic(Diagnostic.Create(Rule, c.Node.GetLocation())),
Diagnostics\Suppression\SuppressionTests.vb (16)
711context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())) 784context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())) 828context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())) 892context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())) 1012context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())) 1017context.ReportDiagnostic(Diagnostic.Create(_descriptor, ns.Name.GetLocation())) 1022context.ReportDiagnostic(Diagnostic.Create(_descriptor, method.Identifier.GetLocation())) 1027context.ReportDiagnostic(Diagnostic.Create(_descriptor, p.Identifier.GetLocation())) 1032context.ReportDiagnostic(Diagnostic.Create(_descriptor, f.Declarators.First().Names.First.GetLocation())) 1037context.ReportDiagnostic(Diagnostic.Create(_descriptor, e.Identifier.GetLocation())) 1728context.ReportDiagnostic(Diagnostic.Create(_descriptor, classDecl.Identifier.GetLocation())) 1733context.ReportDiagnostic(Diagnostic.Create(_descriptor, ns.Name.GetLocation())) 1738context.ReportDiagnostic(Diagnostic.Create(_descriptor, method.Identifier.GetLocation())) 1743context.ReportDiagnostic(Diagnostic.Create(_descriptor, p.Identifier.GetLocation())) 1748context.ReportDiagnostic(Diagnostic.Create(_descriptor, f.Declarators.First().Names.First.GetLocation())) 1753context.ReportDiagnostic(Diagnostic.Create(_descriptor, e.Identifier.GetLocation()))
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (3)
CodeGen\CodeGenTests.vb (1)
13597Dim diagnostics = ImmutableArray(Of Diagnostic).Empty
Emit\DynamicAnalysis\DynamicInstrumentationTests.vb (2)
1915Dim diagnostics As ImmutableArray(Of Diagnostic) = CreateCompilation(source).GetEmitDiagnostics(EmitOptions.Default.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage))) 1916For Each Diagnostic As Diagnostic In diagnostics
Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler (2)
EvaluationContext.vb (2)
542Friend Overrides Function HasDuplicateTypesOrAssemblies(diagnostic As Diagnostic) As Boolean 556Friend Overrides Function GetMissingAssemblyIdentities(diagnostic As Diagnostic, linqLibrary As AssemblyIdentity) As ImmutableArray(Of AssemblyIdentity)
Microsoft.CodeAnalysis.VisualBasic.Features (35)
CodeFixes\GenerateEnumMember\GenerateEnumMemberCodeFixProvider.vb (1)
40Protected Overrides Function IsCandidate(node As SyntaxNode, token As SyntaxToken, diagnostic As Diagnostic) As Boolean
CodeFixes\GenerateParameterizedMember\GenerateConversionCodeFixProvider.vb (1)
40Protected Overrides Function IsCandidate(node As SyntaxNode, token As SyntaxToken, diagnostic As Diagnostic) As Boolean
CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
59Protected Overrides Function IsCandidate(node As SyntaxNode, token As SyntaxToken, diagnostic As Diagnostic) As Boolean
CodeFixes\GenerateType\GenerateTypeCodeFixProvider.vb (1)
48Protected Overrides Function IsCandidate(node As SyntaxNode, token As SyntaxToken, diagnostic As Diagnostic) As Boolean
CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb (8)
28Protected Overrides Function CreatePragmaRestoreDirectiveTrivia(diagnostic As Diagnostic, formatNode As Func(Of SyntaxNode, CancellationToken, SyntaxNode), needsLeadingEndOfLine As Boolean, needsTrailingEndOfLine As Boolean, cancellationToken As CancellationToken) As SyntaxTriviaList 35Protected Overrides Function CreatePragmaDisableDirectiveTrivia(diagnostic As Diagnostic, formatNode As Func(Of SyntaxNode, CancellationToken, SyntaxNode), needsLeadingEndOfLine As Boolean, needsTrailingEndOfLine As Boolean, cancellationToken As CancellationToken) As SyntaxTriviaList 42Private Shared Function GetErrorCodes(diagnostic As Diagnostic, ByRef includeTitle As Boolean) As SeparatedSyntaxList(Of IdentifierNameSyntax) 54diagnostic As Diagnostic, 120diagnostic As Diagnostic, 155diagnostic As Diagnostic) As SyntaxNode 168diagnostic As Diagnostic, 177Private Shared Function CreateAttributeArguments(targetSymbol As ISymbol, diagnostic As Diagnostic, isAssemblyAttribute As Boolean) As ArgumentListSyntax
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.vb (6)
44Private _diagnostics As ImmutableArray(Of Diagnostic).Builder 54Public ReadOnly Property Diagnostics As ImmutableArray(Of Diagnostic) 56Return If(_diagnostics?.ToImmutable(), ImmutableArray(Of Diagnostic).Empty) 60Public ReadOnly Property DiagnosticsBuilder As ImmutableArray(Of Diagnostic).Builder 63Interlocked.CompareExchange(_diagnostics, ImmutableArray.CreateBuilder(Of Diagnostic)(), Nothing) 187Dim diagnostic As Diagnostic = Nothing
Diagnostics\Analyzers\VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb (2)
38Protected Overrides Function AnalyzeCodeBlock(context As CodeBlockAnalysisContext) As ImmutableArray(Of Diagnostic) 49Protected Overrides Function AnalyzeSemanticModel(context As SemanticModelAnalysisContext, codeBlockIntervalTree As SimpleIntervalTree(Of TextSpan, TextSpanIntervalIntrospector)) As ImmutableArray(Of Diagnostic)
GenerateConstructor\GenerateConstructorCodeFixProvider.vb (1)
59Protected Overrides Function IsCandidate(node As SyntaxNode, token As SyntaxToken, diagnostic As Diagnostic) As Boolean
GenerateVariable\VisualBasicGenerateVariableCodeFixProvider.vb (1)
43Protected Overrides Function IsCandidate(node As SyntaxNode, token As SyntaxToken, diagnostic As Diagnostic) As Boolean
RemoveSharedFromModuleMembers\VisualBasicRemoveSharedFromModuleMembersCodeFixProvider.vb (1)
62Protected Overrides Function FixAllAsync(document As Document, diagnostics As ImmutableArray(Of Diagnostic), editor As SyntaxEditor, fallbackOptions As CodeActionOptionsProvider, cancellationToken As CancellationToken) As Task
VisualBasicChangeToYieldCodeFixProvider.vb (1)
36Protected Overrides Function GetCodeFixAsync(root As SyntaxNode, node As SyntaxNode, document As Document, diagnostics As Diagnostic, cancellationToken As CancellationToken) As Task(Of CodeAction)
VisualBasicConvertToAsyncFunctionCodeFixProvider.vb (2)
35Protected Overrides Async Function GetDescriptionAsync(diagnostic As Diagnostic, node As SyntaxNode, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Task(Of String) 40Protected Overrides Async Function GetRootInOtherSyntaxTreeAsync(node As SyntaxNode, semanticModel As SemanticModel, diagnostic As Diagnostic, cancellationToken As CancellationToken) As Task(Of Tuple(Of SyntaxTree, SyntaxNode))
VisualBasicConvertToIteratorCodeFixProvider.vb (1)
38Protected Overrides Async Function GetCodeFixAsync(root As SyntaxNode, node As SyntaxNode, document As Document, diagnostics As Diagnostic, cancellationToken As CancellationToken) As Task(Of CodeAction)
VisualBasicMakeMethodAsynchronousCodeFixProvider.vb (1)
34Protected Overrides Function IsSupportedDiagnostic(diagnostic As Diagnostic, cancellationToken As CancellationToken) As Boolean
VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
27Protected Overrides Function GetNode(diagnostic As Diagnostic, cancellationToken As CancellationToken) As SimpleNameSyntax
VisualBasicRemoveUnnecessaryByValCodeFixProvider.vb (1)
37Protected Overrides Async Function FixAllAsync(document As Document, diagnostics As ImmutableArray(Of Diagnostic), editor As SyntaxEditor, fallbackOptions As CodeActionOptionsProvider, cancellationToken As CancellationToken) As Task
VisualBasicRemoveUnnecessaryByValDiagnosticAnalyzer.vb (1)
29syntaxContext.ReportDiagnostic(Diagnostic.Create(Descriptor, modifier.GetLocation(), additionalLocations:={parameterSyntax.GetLocation()}))
VisualBasicRemoveUnnecessaryCastCodeFixProvider.vb (1)
54diagnostics As ImmutableArray(Of Diagnostic),
VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
35Protected Overrides Async Function FixAllAsync(document As Document, diagnostics As ImmutableArray(Of Diagnostic), editor As SyntaxEditor, fallbackOptions As CodeActionOptionsProvider, cancellationToken As CancellationToken) As Task
VisualBasicUseIsNotExpressionCodeFixProvider.vb (2)
35diagnostics As ImmutableArray(Of Diagnostic), 50diagnostic As Diagnostic,
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (42)
Compilation\VisualBasicCompilationOptionsTests.vb (2)
359Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing 388Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing
Diagnostics\DiagnosticAnalyzerTests.vb (21)
42context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_CA9999_UseOfVariableThatStartsWithX, id.GetLocation, id.Identifier.ValueText)) 54Dim noneDiag = Microsoft.CodeAnalysis.Diagnostic.Create(noneDiagDescriptor, Location.None) 55Dim infoDiag = Microsoft.CodeAnalysis.Diagnostic.Create(infoDiagDescriptor, Location.None) 56Dim warningDiag = Microsoft.CodeAnalysis.Diagnostic.Create(warningDiagDescriptor, Location.None) 57Dim errorDiag = Microsoft.CodeAnalysis.Diagnostic.Create(errorDiagDescriptor, Location.None) 59Dim diags = New Diagnostic() {noneDiag, infoDiag, warningDiag, errorDiag} 135Dim noneDiag = Microsoft.CodeAnalysis.Diagnostic.Create(noneDiagDescriptor, Location.None) 136Dim infoDiag = Microsoft.CodeAnalysis.Diagnostic.Create(infoDiagDescriptor, Location.None) 137Dim warningDiag = Microsoft.CodeAnalysis.Diagnostic.Create(warningDiagDescriptor, Location.None) 138Dim errorDiag = Microsoft.CodeAnalysis.Diagnostic.Create(errorDiagDescriptor, Location.None) 140Dim diags = New Diagnostic() {noneDiag, infoDiag, warningDiag, errorDiag} 188Dim disabledDiag = CodeAnalysis.Diagnostic.Create(disabledDiagDescriptor, Location.None) 189Dim enabledDiag = CodeAnalysis.Diagnostic.Create(enabledDiagDescriptor, Location.None) 279context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(desc1, context.Node.GetLocation)) 317context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(desc1, sourceLoc)) 368context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(desc1, location)) 412context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_descriptor, context.OwningSymbol.DeclaringSyntaxReferences.First.GetLocation)) 511context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(desc1, sourceLoc)) 576context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(desc1, sourceLoc)) 962nodeContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(ExpressionDescriptor, nodeContext.Node.GetLocation())) 1673Private Shared Sub TestAdditionalFileAnalyzer_VerifyDiagnostics(diagnostics As ImmutableArray(Of Diagnostic),
Diagnostics\GetDiagnosticsTests.vb (4)
632context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(DescriptorForBlockEnd, context.CodeBlock.GetLocation())) 646context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(DescriptorForBlockEnd, operationBlock.Syntax.GetLocation())) 655Private Sub AnalyzeNode(node As SyntaxNode, containingSymbol As ISymbol, reportDiagnostic As Action(Of Diagnostic)) 674reportDiagnostic(CodeAnalysis.Diagnostic.Create(Descriptor, location, containingSymbol.Name))
FlowAnalysis\FlowTestBase.vb (1)
23Friend Function FlowDiagnostics(compilation As VisualBasicCompilation) As ImmutableArray(Of Diagnostic)
SourceGeneration\GeneratorDriverTests.vb (14)
30Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 54Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 68Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 96Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 119Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 137Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 155Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 307Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 325Dim outputDiagnostics As ImmutableArray(Of Diagnostic) = Nothing 359Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing 366Shared Sub VerifyDiagnosticsWithSource(source As String, diag As Diagnostic, location As TextSpan, ParamArray expected As DiagnosticDescription()) 386Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing 393Shared Sub VerifyDiagnosticsWithLocation(source As String, reportDiagnostics As IReadOnlyList(Of (Diagnostic As Diagnostic, Location As String)), ParamArray expected As DiagnosticDescription()) 421Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (6)
DocumentationComments\DocCommentTests.vb (1)
12123Dim diagnostics As Diagnostic()
SymbolsTests\SymbolErrorTests.vb (5)
20736Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing 20992Dim err = DirectCast(errs.Single(), Diagnostic) 22487Assert.Equal(1, Enumerable.Count(Of Diagnostic)(errs)) 22488Dim err As Diagnostic = Enumerable.Single(Of Diagnostic)(errs)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (10)
Parser\ParseDirectives.vb (6)
3155Private ReadOnly _reporter As Func(Of SyntaxNode, DiagnosticDescriptor, Diagnostic) 3157Public Sub New(descriptor As DiagnosticDescriptor, kind As SyntaxKind, reporter As Func(Of SyntaxNode, DiagnosticDescriptor, Diagnostic)) 3187Return CodeAnalysis.Diagnostic.Create(d, varDecl.AsClause.GetLocation) 3294Return CodeAnalysis.Diagnostic.Create(d, varDecl.AsClause.GetLocation) 3625Return CodeAnalysis.Diagnostic.Create(d, varDecl.AsClause.GetLocation) 3652Return CodeAnalysis.Diagnostic.Create(d, varDecl.AsClause.GetLocation)
TestSyntaxNodes.vb (4)
931Private Function CompareDiagnostics(err1 As Diagnostic, err2 As Diagnostic) As Integer 943Dim errorList As New List(Of Diagnostic) 965Dim errorList As New List(Of Diagnostic)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (19)
BasicTestBase.vb (1)
912Public Shared Function GetAssertTheseDiagnosticsString(allDiagnostics As ImmutableArray(Of Diagnostic), suppressInfos As Boolean) As String
CompilationTestUtils.vb (11)
727Private Sub AssertNoDiagnostics(diags As ImmutableArray(Of Diagnostic), suppressInfos As Boolean) 749Public Sub AssertNoErrors(errors As ImmutableArray(Of Diagnostic)) 750Dim diags As ImmutableArray(Of Diagnostic) = errors.WhereAsArray(Function(e) e.Severity = DiagnosticSeverity.Error) 854Public Sub AssertTheseDiagnostics(errors As ImmutableArray(Of Diagnostic), errs As XElement, Optional suppressInfos As Boolean = True) 863Public Sub AssertTheseDiagnostics(errors As ImmutableArray(Of Diagnostic), errs As XCData, Optional suppressInfos As Boolean = True) 868Private Sub AssertTheseDiagnostics(errors As ImmutableArray(Of Diagnostic), expectedText As String, suppressInfos As Boolean) 957Public Sub New(diagnostic As Diagnostic, index As Integer) 961Public ReadOnly Diagnostic As Diagnostic 965Private Function DumpAllDiagnostics(allDiagnostics As Diagnostic(), suppressInfos As Boolean) As String 969Friend Function DumpAllDiagnostics(allDiagnostics As ImmutableArray(Of Diagnostic), suppressInfos As Boolean) As String 991Private Function ErrorText(e As Diagnostic) As String
DiagnosticExtensions.vb (1)
23Friend Function GetDiagnosticsForSyntaxTree(c As VisualBasicCompilation, stage As CompilationStage, tree As SyntaxTree, Optional filterSpan As TextSpan? = Nothing) As ImmutableArray(Of Diagnostic)
ParserTestUtilities.vb (6)
462Public Function ToXml(errors As IEnumerable(Of Diagnostic)) As XElement 473Public Function GetSyntaxErrorsNoTree(t As SyntaxToken) As IEnumerable(Of Diagnostic) 478Public Function GetSyntaxErrorsNoTree(n As SyntaxNode) As IEnumerable(Of Diagnostic) 562Friend Sub AppendSyntaxErrors(errors As IEnumerable(Of Diagnostic), output As StringBuilder) 598Private Function AreErrorsEquivalent(syntaxError As Diagnostic, xmlError As XElement) As Boolean 635Dim unmatchedErrorList As New List(Of Diagnostic)(tree.GetDiagnostics(node))
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
CodeCleanup\Providers\ReduceTokensCodeCleanupProvider.vb (2)
330Private Shared Function HasOverflow(diagnostics As IEnumerable(Of Diagnostic)) As Boolean 331Return diagnostics.Any(Function(diagnostic As Diagnostic) diagnostic.Id = "BC30036")
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.vb (1)
43Dim diagnostics As IEnumerable(Of Diagnostic) = Nothing
Microsoft.CodeAnalysis.Workspaces (192)
CodeFixContextExtensions.cs (2)
16internal static void RegisterFixes(this CodeFixContext context, IEnumerable<CodeAction> actions, Diagnostic diagnostic) 27internal static void RegisterFixes(this CodeFixContext context, IEnumerable<CodeAction> actions, ImmutableArray<Diagnostic> diagnostics)
CodeFixes\CodeFix.cs (7)
17/// <see cref="Diagnostic"/>s that this <see cref="CodeAction"/> will fix. 23internal readonly ImmutableArray<Diagnostic> Diagnostics; 37/// cref="CodeFixContext.RegisterCodeFix(CodeAction, IEnumerable{Diagnostic})"/>). This could change 41internal Diagnostic PrimaryDiagnostic => Diagnostics[0]; 43internal CodeFix(Project project, CodeAction action, Diagnostic diagnostic) 50internal CodeFix(Project project, CodeAction action, ImmutableArray<Diagnostic> diagnostics) 60var diagnostic = PrimaryDiagnostic;
CodeFixes\CodeFixContext.cs (21)
26private readonly ImmutableArray<Diagnostic> _diagnostics; 28private readonly Action<CodeAction, ImmutableArray<Diagnostic>> _registerCodeFix; 67public ImmutableArray<Diagnostic> Diagnostics => _diagnostics; 102/// Additionally, the <see cref="Diagnostic.Id"/> of each diagnostic must be in the set of the <see cref="CodeFixProvider.FixableDiagnosticIds"/> of the associated <see cref="CodeFixProvider"/>. 115ImmutableArray<Diagnostic> diagnostics, 116Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, 136/// Additionally, the <see cref="Diagnostic.Id"/> of each diagnostic must be in the set of the <see cref="CodeFixProvider.FixableDiagnosticIds"/> of the associated <see cref="CodeFixProvider"/>. 148ImmutableArray<Diagnostic> diagnostics, 149Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, 167/// The <see cref="Diagnostic.Id"/> of this diagnostic must be in the set of the <see cref="CodeFixProvider.FixableDiagnosticIds"/> of the associated <see cref="CodeFixProvider"/>. 175Diagnostic diagnostic, 176Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, 194/// The <see cref="Diagnostic.Id"/> of this diagnostic must be in the set of the <see cref="CodeFixProvider.FixableDiagnosticIds"/> of the associated <see cref="CodeFixProvider"/>. 201Diagnostic diagnostic, 202Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, 217ImmutableArray<Diagnostic> diagnostics, 218Action<CodeAction, ImmutableArray<Diagnostic>> registerCodeFix, 239public void RegisterCodeFix(CodeAction action, Diagnostic diagnostic) 259public void RegisterCodeFix(CodeAction action, IEnumerable<Diagnostic> diagnostics) 274public void RegisterCodeFix(CodeAction action, ImmutableArray<Diagnostic> diagnostics) 291private static void VerifyDiagnosticsArgument(ImmutableArray<Diagnostic> diagnostics, TextSpan span)
CodeFixes\CodeFixProvider.cs (1)
28/// The context must only contain diagnostics with a <see cref="Diagnostic.Id"/> included in the <see cref="FixableDiagnosticIds"/> for the current provider.
CodeFixes\FixAllOccurrences\BatchFixAllProvider.cs (5)
89private static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> DetermineDiagnosticsAsync(FixAllContext fixAllContext, IProgressTracker progressTracker) 113ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentToDiagnostics) 140FixAllContext fixAllContext, ImmutableArray<Diagnostic> orderedDiagnostics) 148foreach (var diagnostic in orderedDiagnostics) 231private static Action<CodeAction, ImmutableArray<Diagnostic>> GetRegisterCodeFixAction(
CodeFixes\FixAllOccurrences\DocumentBasedFixAllProvider.cs (5)
22/// cref="Diagnostic"/> only affect the <see cref="Document"/> the diagnostic was produced in. 28/// cref="FixAllAsync(FixAllContext, Document, ImmutableArray{Diagnostic})"/> for implementors to process. 65protected abstract Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics); 94private static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> DetermineDiagnosticsAsync(FixAllContext fixAllContext, IProgressTracker progressTracker) 107FixAllContext fixAllContext, IProgressTracker progressTracker, ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnostics)
CodeFixes\FixAllOccurrences\FixAllContext.cs (13)
226public async Task<ImmutableArray<Diagnostic>> GetDocumentDiagnosticsAsync(Document document) 235return ImmutableArray<Diagnostic>.Empty; 242private static async Task<ImmutableArray<Diagnostic>> GetFilteredDiagnosticsAsync( 243Task<IEnumerable<Diagnostic>> getDiagnosticsTask, 257return ImmutableArray<Diagnostic>.Empty; 263internal async Task<ImmutableArray<Diagnostic>> GetDocumentSpanDiagnosticsAsync(Document document, TextSpan filterSpan) 272return ImmutableArray<Diagnostic>.Empty; 284public Task<ImmutableArray<Diagnostic>> GetProjectDiagnosticsAsync(Project project) 298public Task<ImmutableArray<Diagnostic>> GetAllDiagnosticsAsync(Project project) 313private async Task<ImmutableArray<Diagnostic>> GetProjectDiagnosticsAsync(Project project, bool includeAllDocumentDiagnostics) 319return ImmutableArray<Diagnostic>.Empty; 351internal Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixAsync() 354internal Task<ImmutableDictionary<Project, ImmutableArray<Diagnostic>>> GetProjectDiagnosticsToFixAsync()
CodeFixes\FixAllOccurrences\FixAllContext.DiagnosticProvider.cs (8)
29public abstract Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken); 34public abstract Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken); 40public abstract Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken); 42internal static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixAsync(FixAllContext fixAllContext) 49static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixWorkerAsync(FixAllContext fixAllContext) 66internal static async Task<ImmutableDictionary<Project, ImmutableArray<Diagnostic>>> GetProjectDiagnosticsToFixAsync( 85var projectsAndDiagnostics = ImmutableDictionary.CreateBuilder<Project, ImmutableArray<Diagnostic>>(); 108return ImmutableDictionary<Project, ImmutableArray<Diagnostic>>.Empty;
CodeFixes\FixAllOccurrences\FixAllContext.SpanBasedDiagnosticProvider.cs (1)
38public abstract Task<IEnumerable<Diagnostic>> GetDocumentSpanDiagnosticsAsync(Document document, TextSpan fixAllSpan, CancellationToken cancellationToken);
CodeFixes\FixAllOccurrences\FixAllContextHelper.cs (11)
21public static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixAsync( 26var allDiagnostics = ImmutableArray<Diagnostic>.Empty; 40return ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Empty.SetItem(document, documentDiagnostics); 75var diagnostics = new ConcurrentDictionary<ProjectId, ImmutableArray<Diagnostic>>(); 90return ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Empty; 96async Task AddDocumentDiagnosticsAsync(ConcurrentDictionary<ProjectId, ImmutableArray<Diagnostic>> diagnostics, Project projectToFix) 109static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetSpanDiagnosticsAsync( 113var builder = PooledDictionary<Document, ArrayBuilder<Diagnostic>>.GetInstance(); 127private static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixAsync( 129ImmutableArray<Diagnostic> diagnostics, 132var builder = ImmutableDictionary.CreateBuilder<Document, ImmutableArray<Diagnostic>>();
CodeFixes\FixAllOccurrences\FixAllProvider.cs (7)
49/// <see cref="WellKnownFixAllProviders.BatchFixer"/> in the case where fixes for a <see cref="Diagnostic"/> 58public static FixAllProvider Create(Func<FixAllContext, Document, ImmutableArray<Diagnostic>, Task<Document?>> fixAllAsync) 64/// fixes for a <see cref="Diagnostic"/> only affect the <see cref="Document"/> the diagnostic was produced in. 78Func<FixAllContext, Document, ImmutableArray<Diagnostic>, Task<Document?>> fixAllAsync, 100private readonly Func<FixAllContext, Document, ImmutableArray<Diagnostic>, Task<Document?>> _fixAllAsync; 103Func<FixAllContext, Document, ImmutableArray<Diagnostic>, Task<Document?>> fixAllAsync, 110protected override Task<Document?> FixAllAsync(FixAllContext context, Document document, ImmutableArray<Diagnostic> diagnostics)
CodeFixes\FixAllOccurrences\FixAllState.cs (4)
67ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, 91ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix, 112private static ImmutableHashSet<string> GetDiagnosticsIds(IEnumerable<ImmutableArray<Diagnostic>> diagnosticsCollection) 117foreach (var diagnostic in diagnostics)
CodeFixes\FixAllOccurrences\FixAllState.FixMultipleDiagnosticProvider.cs (16)
21public ImmutableDictionary<Document, ImmutableArray<Diagnostic>> DocumentDiagnosticsMap { get; } 22public ImmutableDictionary<Project, ImmutableArray<Diagnostic>> ProjectDiagnosticsMap { get; } 24public FixMultipleDiagnosticProvider(ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsMap) 27ProjectDiagnosticsMap = ImmutableDictionary<Project, ImmutableArray<Diagnostic>>.Empty; 30public FixMultipleDiagnosticProvider(ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsMap) 33DocumentDiagnosticsMap = ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Empty; 36public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) 38var allDiagnosticsBuilder = ArrayBuilder<Diagnostic>.GetInstance(); 39ImmutableArray<Diagnostic> diagnostics; 56return Task.FromResult<IEnumerable<Diagnostic>>(allDiagnosticsBuilder.ToImmutableAndFree()); 59public override Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) 63return Task.FromResult<IEnumerable<Diagnostic>>(diagnostics); 66return SpecializedTasks.EmptyEnumerable<Diagnostic>(); 69public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) 73return Task.FromResult<IEnumerable<Diagnostic>>(diagnostics); 76return SpecializedTasks.EmptyEnumerable<Diagnostic>();
CodeFixes\Supression\IConfigurationFixProvider.cs (3)
23bool IsFixableDiagnostic(Diagnostic diagnostic); 29Task<ImmutableArray<CodeFix>> GetFixesAsync(TextDocument document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken); 35Task<ImmutableArray<CodeFix>> GetFixesAsync(Project project, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken);
CodeFixesAndRefactorings\FixAllLogger.cs (2)
156public static void LogDiagnosticsStats(int correlationId, ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap) 166public static void LogDiagnosticsStats(int correlationId, ImmutableDictionary<Project, ImmutableArray<Diagnostic>> projectsAndDiagnosticsToFixMap)
CodeFixesAndRefactorings\FixAllProviderInfo.cs (5)
113public abstract bool CanBeFixed(Diagnostic diagnostic); 128public override bool CanBeFixed(Diagnostic diagnostic) 134private readonly Func<Diagnostic, bool> _canBeSuppressedOrUnsuppressed; 145public override bool CanBeFixed(Diagnostic diagnostic) 158public override bool CanBeFixed(Diagnostic diagnostic)
Diagnostics\AbstractDiagnosticPropertiesService.cs (2)
14public ImmutableDictionary<string, string> GetAdditionalProperties(Diagnostic diagnostic) 20Diagnostic diagnostic,
Diagnostics\DiagnosticAnalysisResultBuilder.cs (12)
51public void AddExternalSyntaxDiagnostics(DocumentId documentId, IEnumerable<Diagnostic> diagnostics) 56public void AddExternalSemanticDiagnostics(DocumentId documentId, IEnumerable<Diagnostic> diagnostics) 65ref Dictionary<DocumentId, List<DiagnosticData>>? lazyLocals, DocumentId documentId, IEnumerable<Diagnostic> diagnostics) 67foreach (var diagnostic in diagnostics) 110private void AddDocumentDiagnostic(ref Dictionary<DocumentId, List<DiagnosticData>>? map, TextDocument? document, Diagnostic diagnostic) 130public void AddSyntaxDiagnostics(SyntaxTree tree, IEnumerable<Diagnostic> diagnostics) 133public void AddDiagnosticTreatedAsLocalSemantic(Diagnostic diagnostic) 136public void AddSemanticDiagnostics(SyntaxTree tree, IEnumerable<Diagnostic> diagnostics) 139public void AddCompilationDiagnostics(IEnumerable<Diagnostic> diagnostics) 149ref Dictionary<DocumentId, List<DiagnosticData>>? lazyLocals, SyntaxTree? tree, Diagnostic diagnostic) 202ref Dictionary<DocumentId, List<DiagnosticData>>? lazyLocals, SyntaxTree? tree, IEnumerable<Diagnostic> diagnostics) 204foreach (var diagnostic in diagnostics)
Diagnostics\DiagnosticData.cs (10)
174public async Task<Diagnostic> ToDiagnosticAsync(Project project, CancellationToken cancellationToken) 182public Diagnostic ToDiagnostic(Location location, ImmutableArray<Location> additionalLocations) 184return Diagnostic.Create( 214public static DiagnosticData Create(Solution solution, Diagnostic diagnostic, Project? project) 219public static DiagnosticData Create(Diagnostic diagnostic, TextDocument document) 246Diagnostic diagnostic, 273private static ImmutableDictionary<string, string?>? GetAdditionalProperties(TextDocument document, Diagnostic diagnostic) 279private static ImmutableArray<DiagnosticDataLocation> GetAdditionalLocations(TextDocument document, Diagnostic diagnostic) 330var diagnostic = Diagnostic.Create(descriptor, Location.None, effectiveSeverity, additionalLocations: null, properties: null, messageArgs: messageArguments);
Diagnostics\DocumentDiagnosticAnalyzer.cs (2)
20public abstract Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken); 22public abstract Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken);
Diagnostics\Extensions.cs (17)
25public static async Task<ImmutableArray<Diagnostic>> ToDiagnosticsAsync(this IEnumerable<DiagnosticData> diagnostics, Project project, CancellationToken cancellationToken) 27var result = ArrayBuilder<Diagnostic>.GetInstance(); 86ImmutableArray<Diagnostic> additionalPragmaSuppressionDiagnostics, 131ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>? diagnosticsByAnalyzerMap; 212additionalPragmaSuppressionDiagnostics = ImmutableArray<Diagnostic>.Empty; 222ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> diagnosticsByAnalyzer, 240ImmutableArray<Diagnostic> diagnostics, 291public static ImmutableArray<Diagnostic> Filter( 292this ImmutableArray<Diagnostic> diagnostics, 308public static async Task<(AnalysisResult result, ImmutableArray<Diagnostic> additionalDiagnostics)> GetAnalysisResultAsync( 355private static async Task<ImmutableArray<Diagnostic>> GetPragmaSuppressionAnalyzerDiagnosticsAsync( 366return ImmutableArray<Diagnostic>.Empty; 373return ImmutableArray<Diagnostic>.Empty; 376using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnosticsBuilder); 384var bag = new ConcurrentBag<Diagnostic>(); 401using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnosticsBuilder); 416async Task AnalyzeDocumentAsync(IPragmaSuppressionsAnalyzer suppressionAnalyzer, Document document, TextSpan? span, Action<Diagnostic> reportDiagnostic)
Diagnostics\IDiagnosticPropertiesService.cs (1)
14ImmutableDictionary<string, string> GetAdditionalProperties(Diagnostic diagnostic);
Diagnostics\ProjectDiagnosticAnalyzer.cs (1)
20public abstract Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken);
DocumentExtensions.cs (2)
156public static async Task<ImmutableArray<Diagnostic>> GetErrorsAsync(this Document document, CancellationToken cancellationToken, IList<string>? ignoreErrorCode = null) 160return ImmutableArray<Diagnostic>.Empty;
IPragmaSuppressionsAnalyzer.cs (1)
27Action<Diagnostic> reportDiagnostic,
J\s\src\Compilers\Core\Portable\Collections\ImmutableArrayExtensions.cs\ImmutableArrayExtensions.cs (1)
649internal static bool HasAnyErrors<T>(this ImmutableArray<T> diagnostics) where T : Diagnostic
ProjectExtensions.cs (2)
43public static string? TryGetAnalyzerConfigPathForDiagnosticConfiguration(this Project project, Diagnostic diagnostic) 49private static string? TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(Project project, Diagnostic? diagnostic)
Shared\Extensions\TelemetryExtensions.cs (1)
53public static string GetTelemetryDiagnosticID(this Diagnostic diagnostic)
SyntaxEditorBasedCodeFixProvider.cs (11)
55protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, Diagnostic? diagnostic = null) 58protected void RegisterCodeFix(CodeFixContext context, string title, string equivalenceKey, CodeActionPriority priority, Diagnostic? diagnostic = null) 61protected Func<CancellationToken, Task<Document>> GetDocumentUpdater(CodeFixContext context, Diagnostic? diagnostic = null) 68Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider options, CancellationToken cancellationToken) 97Document document, ImmutableArray<Diagnostic> diagnostics, SyntaxEditor editor, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken); 106/// This overload differs from <see cref="IncludeDiagnosticDuringFixAll(Diagnostic, Document, SemanticModel, string, CancellationToken)"/> 109/// This overload differs from <see cref="IncludeDiagnosticDuringFixAll(Diagnostic)"/> in 116protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, SemanticModel model, string? equivalenceKey, CancellationToken cancellationToken) 119protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string? equivalenceKey, CancellationToken cancellationToken) 133/// cref="IncludeDiagnosticDuringFixAll(Diagnostic, Document, SemanticModel, string, CancellationToken)"/> 139protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic)
Workspace\Solution\DocumentState.cs (2)
575internal override Task<Diagnostic?> GetLoadDiagnosticAsync(CancellationToken cancellationToken) 579return SpecializedTasks.Null<Diagnostic>();
Workspace\Solution\Project.cs (1)
348internal ValueTask<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync(CancellationToken cancellationToken)
Workspace\Solution\RecoverableTextAndVersion.cs (1)
146public readonly Diagnostic? LoadDiagnostic;
Workspace\Solution\SolutionState.CompilationTracker.cs (4)
1060public async ValueTask<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync(SolutionState solution, CancellationToken cancellationToken) 1064return ImmutableArray<Diagnostic>.Empty; 1072return ImmutableArray<Diagnostic>.Empty; 1075using var _ = ArrayBuilder<Diagnostic>.GetInstance(capacity: driverRunResult.Diagnostics.Length, out var builder);
Workspace\Solution\SolutionState.cs (2)
1827public ValueTask<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync(ProjectState project, CancellationToken cancellationToken) 1831: new(ImmutableArray<Diagnostic>.Empty);
Workspace\Solution\SolutionState.GeneratedFileReplacingCompilationTracker.cs (1)
191public ValueTask<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync(SolutionState solution, CancellationToken cancellationToken)
Workspace\Solution\SolutionState.ICompilationTracker.cs (1)
47ValueTask<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync(SolutionState solution, CancellationToken cancellationToken);
Workspace\Solution\SolutionState.SkeletonReferenceCache.cs (1)
266foreach (var diagnostic in emitResult.Diagnostics)
Workspace\Solution\TextAndVersion.cs (3)
34internal Diagnostic? LoadDiagnostic { get; } 36private TextAndVersion(SourceText text, VersionStamp version, string? filePath, Diagnostic? loadDiagnostic) 64internal static TextAndVersion Create(SourceText text, VersionStamp version, Diagnostic? loadDiagnostic)
Workspace\Solution\TextDocumentState.cs (1)
225internal virtual async Task<Diagnostic?> GetLoadDiagnosticAsync(CancellationToken cancellationToken)
Workspace\Solution\TextLoader.cs (1)
172Diagnostic.Create(WorkspaceDiagnosticDescriptors.ErrorReadingFileContent, location, new[] { display, message }));
Microsoft.CodeAnalysis.Workspaces.UnitTests (4)
BatchFixAllProviderTests.cs (2)
74context.ReportDiagnostic(Diagnostic.Create(Descriptor, node.Token.GetLocation())); 97foreach (var diagnostic in context.Diagnostics)
SolutionTests\SolutionTests.cs (2)
3279var diagnostic = await doc.State.GetLoadDiagnosticAsync(CancellationToken.None).ConfigureAwait(false); 4096var diagnostic = Assert.Single(diagnostics);
Microsoft.VisualStudio.LanguageServices (19)
TableDataSource\Suppression\VisualStudioDiagnosticListTableCommandHandler.cs (1)
237var diagnostic = await selectedDiagnostic.ToDiagnosticAsync(project, cancellationToken).ConfigureAwait(false);
TableDataSource\Suppression\VisualStudioSuppressionFixService.cs (18)
285? ImmutableDictionary<Project, ImmutableArray<Diagnostic>>.Empty 468private static ImmutableDictionary<Document, ImmutableArray<Diagnostic>> GetDocumentDiagnosticsMappedToNewSolution(ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentDiagnosticsToFixMap, Solution newSolution, string language) 470ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Builder? builder = null; 479builder ??= ImmutableDictionary.CreateBuilder<Document, ImmutableArray<Diagnostic>>(); 484return builder != null ? builder.ToImmutable() : ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Empty; 487private static ImmutableDictionary<Project, ImmutableArray<Diagnostic>> GetProjectDiagnosticsMappedToNewSolution(ImmutableDictionary<Project, ImmutableArray<Diagnostic>> projectDiagnosticsToFixMap, Solution newSolution, string language) 489ImmutableDictionary<Project, ImmutableArray<Diagnostic>>.Builder? projectDiagsBuilder = null; 498projectDiagsBuilder ??= ImmutableDictionary.CreateBuilder<Project, ImmutableArray<Diagnostic>>(); 503return projectDiagsBuilder != null ? projectDiagsBuilder.ToImmutable() : ImmutableDictionary<Project, ImmutableArray<Diagnostic>>.Empty; 506private static CodeFixProvider? GetSuppressionFixer(IEnumerable<Diagnostic> diagnostics, string language, ICodeFixService codeFixService) 512private async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic>>> GetDocumentDiagnosticsToFixAsync(IEnumerable<DiagnosticData> diagnosticsToFix, Func<Project, bool> shouldFixInProject, bool filterStaleDiagnostics, CancellationToken cancellationToken) 530return ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Empty; 533var finalBuilder = ImmutableDictionary.CreateBuilder<Document, ImmutableArray<Diagnostic>>(); 603private async Task<ImmutableDictionary<Project, ImmutableArray<Diagnostic>>> GetProjectDiagnosticsToFixAsync(IEnumerable<DiagnosticData> diagnosticsToFix, Func<Project, bool> shouldFixInProject, bool filterStaleDiagnostics, CancellationToken cancellationToken) 621return ImmutableDictionary<Project, ImmutableArray<Diagnostic>>.Empty; 624var finalBuilder = ImmutableDictionary.CreateBuilder<Project, ImmutableArray<Diagnostic>>();
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
EditorConfigSettings\DataProvider\DataProviderTests.MockAnalyzerReference.cs (1)
111c.ReportDiagnostic(Diagnostic.Create(descriptor, c.Tree.GetLocation(TextSpan.FromBounds(0, 0))));
Microsoft.VisualStudio.LanguageServices.Implementation (2)
SolutionExplorer\DiagnosticItem\DiagnosticItem.cs (2)
89var diagnostic = Diagnostic.Create(Descriptor, Location.None, effectiveSeverity, additionalLocations: null, properties: null);
Microsoft.VisualStudio.LanguageServices.UnitTests (4)
Diagnostics\DefaultDiagnosticUpdateSourceTests.vb (4)
348Public Overrides Function AnalyzeSemanticsAsync(document As Document, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of Diagnostic)) 349Return Task.FromResult(ImmutableArray.Create(Diagnostic.Create(Descriptor, Location.Create(document.FilePath, Nothing, Nothing)))) 352Public Overrides Function AnalyzeSyntaxAsync(document As Document, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of Diagnostic)) 353Return SpecializedTasks.EmptyImmutableArray(Of Diagnostic)()
Microsoft.VisualStudio.LanguageServices.VisualBasic (1)
ProjectSystemShim\VisualBasicProject.OptionsProcessor.vb (1)
231Dim errors As IEnumerable(Of Diagnostic) = Nothing
Microsoft.VisualStudio.LanguageServices.Xaml (6)
Diagnostics\Analyzers\IXamlDocumentAnalyzerService.cs (2)
18Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken); 20Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken);
Diagnostics\Analyzers\XamlDocumentDiagnosticAnalyzer.cs (4)
27public override async Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) 31return ImmutableArray<Diagnostic>.Empty; 37public override async Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) 41return ImmutableArray<Diagnostic>.Empty;
Roslyn.VisualStudio.Next.UnitTests (2)
Services\VisualStudioDiagnosticAnalyzerExecutorTests.cs (2)
295c.ReportDiagnostic(Diagnostic.Create(_supportedDiagnostics[0], c.Tree.GetLocation(TextSpan.FromBounds(0, 1)))); 313c.ReportDiagnostic(Diagnostic.Create(_supportedDiagnostics[0], c.Tree.GetLocation(TextSpan.FromBounds(0, 1))));
VBCSCompiler.UnitTests (1)
AnalyzerConsistencyCheckerTests.cs (1)
63warningLevel: Diagnostic.MaxWarningLevel,