Skip to content
Merged
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 @@ -9,6 +9,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Host;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics;
Expand Down Expand Up @@ -38,6 +39,14 @@ public override async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsAsync(
{
if (Document is SourceGeneratedDocument sourceGeneratedDocument)
{
if (sourceGeneratedDocument.IsRazorSourceGeneratedDocument())
{
// Razor has not ever participated in diagnostics for closed files, so we filter then out when doing FSA. They will handle
// their own open file diagnostics. Additionally, if we reported them here, they would should up as coming from a `.g.cs` file
// which is not what the user wants anyway.
return [];
}

// Unfortunately GetDiagnosticsForIdsAsync returns nothing for source generated documents.
var service = this.Solution.Services.GetRequiredService<IDiagnosticAnalyzerService>();
var documentDiagnostics = await service.GetDiagnosticsForSpanAsync(
Expand Down
Loading