public MSBuildDiagnosticDescriptor(string id, string title, string message, MSBuildDiagnosticSeverity severity) { Title = title; Id = id; Message = message; Severity = severity; }
public MSBuildDiagnosticDescriptor(string id, string title, string message, MSBuildDiagnosticSeverity severity) { Title = title ?? throw new ArgumentNullException(nameof(title)); Id = id ?? throw new ArgumentNullException(nameof(id)); Message = message; Severity = severity; }
public MSBuildDiagnostic(MSBuildDiagnosticDescriptor descriptor, Span location, MSBuildDiagnosticSeverity severity, ImmutableDictionary <string, object> properties, object [] messageArgs) { Descriptor = descriptor; Location = location; Properties = properties; Severity = severity; this.messageArgs = messageArgs; }
public MSBuildDiagnostic(MSBuildDiagnosticDescriptor descriptor, int offset, int length, MSBuildDiagnosticSeverity severity, ImmutableDictionary <string, object> properties, object [] messageArgs) { Descriptor = descriptor; Offset = offset; Length = length; Properties = properties; Severity = severity; this.messageArgs = messageArgs; }
static string GetErrorTypeName(MSBuildDiagnosticSeverity severity) { switch (severity) { case MSBuildDiagnosticSeverity.Error: return(PredefinedErrorTypeNames.SyntaxError); case MSBuildDiagnosticSeverity.Warning: return(PredefinedErrorTypeNames.Warning); case MSBuildDiagnosticSeverity.Suggestion: return(PredefinedErrorTypeNames.Suggestion); } throw new ArgumentException($"Unknown DiagnosticSeverity value {severity}", nameof(severity)); }
private MSBuildDiagnostic( MSBuildDiagnosticSeverity severity, string message, string file, string projectFile, string subcategory, string code, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber) { Severity = severity; Message = message; File = file; ProjectFile = projectFile; Subcategory = subcategory; Code = code; LineNumber = lineNumber; ColumnNumber = columnNumber; EndLineNumber = endLineNumber; EndColumnNumber = endColumnNumber; }
public async Task <MSBuildDiagnosticSeverity> GetFixSeverity( ITextBuffer buffer, MSBuildParseResult result, SnapshotSpan range, MSBuildDiagnosticSeverity severities, CancellationToken cancellationToken) { var filteredDiags = result.Diagnostics.Where(d => range.IntersectsWith(new SnapshotSpan(range.Snapshot, d.Span.Start, d.Span.Length))); var severity = MSBuildDiagnosticSeverity.None; void ReportFix(MSBuildAction a, ImmutableArray <MSBuildDiagnostic> diags) { foreach (var d in diags) { severity |= d.Descriptor.Severity; } }; //TODO invoke the provider once for all the diagnostics it supports foreach (var diagnostic in filteredDiags) { if (cancellationToken.IsCancellationRequested) { return(severity); } if (range.IntersectsWith(new SnapshotSpan(range.Snapshot, diagnostic.Span.Start, diagnostic.Span.Length))) { if (diagnosticIdToFixProviderMap.TryGetValue(diagnostic.Descriptor.Id, out var fixProvider)) { var ctx = new MSBuildFixContext( buffer, result.MSBuildDocument, result.MSBuildDocument.XDocument, new Xml.Dom.TextSpan(range.Start, range.Length), ImmutableArray.Create(diagnostic), ReportFix, cancellationToken); await fixProvider.RegisterCodeFixesAsync(ctx); //callers only really care about the highest severity, so if we got error, we can early out if ((severity | MSBuildDiagnosticSeverity.Error) != 0) { return(severity); } } } } return(severity); }
/// <remarks> /// FIXME: The buffer parameter is workaround for the spellchecker. It can be removed when /// there is a better concept of a durable context/scope to which information can be bound. /// </remarks> public async Task <List <MSBuildCodeFix> > GetFixes( ITextBuffer buffer, MSBuildParseResult result, SnapshotSpan range, MSBuildDiagnosticSeverity requestedSeverities, CancellationToken cancellationToken) { var filteredDiags = ImmutableArray.CreateRange( result.Diagnostics.Where(d => range.IntersectsWith(new SnapshotSpan(range.Snapshot, d.Span.Start, d.Span.Length)))); var fixes = new List <MSBuildCodeFix> (); void ReportFix(MSBuildAction a, ImmutableArray <MSBuildDiagnostic> d) { lock (fixes) { fixes.Add(new MSBuildCodeFix(a, d)); } } //TODO invoke the provider once for all the diagnostics it supports foreach (var diagnostic in filteredDiags) { if ((diagnostic.Descriptor.Severity | requestedSeverities) == 0) { continue; } if (cancellationToken.IsCancellationRequested) { return(null); } if (range.IntersectsWith(new SnapshotSpan(range.Snapshot, diagnostic.Span.Start, diagnostic.Span.Length))) { if (diagnosticIdToFixProviderMap.TryGetValue(diagnostic.Descriptor.Id, out var fixProvider)) { var ctx = new MSBuildFixContext( buffer, result.MSBuildDocument, result.MSBuildDocument.XDocument, new Xml.Dom.TextSpan(range.Start, range.Length), ImmutableArray.Create(diagnostic), ReportFix, cancellationToken); await fixProvider.RegisterCodeFixesAsync(ctx); } } } return(fixes); }
public MSBuildDiagnosticDescriptor(string id, string title, MSBuildDiagnosticSeverity severity) : this(id, title, null, severity) { }
private static IEnumerable <MSBuildDiagnosticsMessage> SelectMessages(ImmutableArray <MSBuildDiagnostic> diagnostics, MSBuildDiagnosticSeverity severity) => diagnostics .Where(d => d.Severity == severity) .Select(MSBuildDiagnosticsMessage.FromDiagnostic);