Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Microsoft.AspNetCore.Razor.PooledObjects;

Expand Down Expand Up @@ -98,9 +97,16 @@ public ImmutableArray<RazorDiagnostic> GetDiagnostics()

// Filter out diagnostics whose warning level exceeds the configured level.
// Diagnostics with level 0 are always reported regardless of the configured level.
return _diagnostics
.Where(d => d.WarningLevel <= warningLevel)
.OrderByAsArray(static d => d.Span.AbsoluteIndex);
using var filtered = new PooledArrayBuilder<RazorDiagnostic>(capacity: _diagnostics.Count);
foreach (var diagnostic in _diagnostics)
{
if (diagnostic.WarningLevel <= warningLevel)
{
filtered.Add(diagnostic);
}
}

return filtered.ToImmutableOrderedBy(static d => d.Span.AbsoluteIndex);
}

public void AddSourceMappingFor(IntermediateNode node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public RazorDiagnosticDescriptor(string id, string messageFormat, RazorDiagnosti
WarningLevel = warningLevel;
}

private string DebuggerToString()
=> $"""Error "{Id}" (level {WarningLevel}): "{MessageFormat}""";
}
private string DebuggerToString() => $"""
Error "{Id}" (level {WarningLevel}): "{MessageFormat}"
""";
}