@@ -18,18 +18,17 @@ internal partial class DiagnosticIncrementalAnalyzer
1818 public Task < ImmutableArray < DiagnosticData > > GetCachedDiagnosticsAsync ( Solution solution , ProjectId projectId , DocumentId ? documentId , CancellationToken cancellationToken )
1919 => new IdeCachedDiagnosticGetter ( this , solution , projectId , documentId ) . GetDiagnosticsAsync ( cancellationToken ) ;
2020
21- public Task < ImmutableArray < DiagnosticData > > GetDiagnosticsForIdsAsync ( Solution solution , ProjectId projectId , DocumentId ? documentId , ImmutableHashSet < string > ? diagnosticIds , Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer , Func < Project , DocumentId ? , IReadOnlyList < DocumentId > > ? getDocuments , bool includeLocalDocumentDiagnostics , bool includeNonLocalDocumentDiagnostics , CancellationToken cancellationToken )
22- => new IdeLatestDiagnosticGetter ( this , solution , projectId , documentId , diagnosticIds , shouldIncludeAnalyzer , getDocuments , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics ) . GetDiagnosticsAsync ( cancellationToken ) ;
21+ public Task < ImmutableArray < DiagnosticData > > GetDiagnosticsForIdsAsync ( Solution solution , ProjectId projectId , DocumentId ? documentId , ImmutableHashSet < string > ? diagnosticIds , Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer , bool includeLocalDocumentDiagnostics , bool includeNonLocalDocumentDiagnostics , CancellationToken cancellationToken )
22+ => new IdeLatestDiagnosticGetter ( this , solution , projectId , documentId , diagnosticIds , shouldIncludeAnalyzer , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics ) . GetDiagnosticsAsync ( cancellationToken ) ;
2323
2424 public Task < ImmutableArray < DiagnosticData > > GetProjectDiagnosticsForIdsAsync ( Solution solution , ProjectId projectId , ImmutableHashSet < string > ? diagnosticIds , Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer , bool includeNonLocalDocumentDiagnostics , CancellationToken cancellationToken )
25- => new IdeLatestDiagnosticGetter ( this , solution , projectId , documentId : null , diagnosticIds , shouldIncludeAnalyzer , getDocuments : null , includeLocalDocumentDiagnostics : false , includeNonLocalDocumentDiagnostics ) . GetProjectDiagnosticsAsync ( cancellationToken ) ;
25+ => new IdeLatestDiagnosticGetter ( this , solution , projectId , documentId : null , diagnosticIds , shouldIncludeAnalyzer , includeLocalDocumentDiagnostics : false , includeNonLocalDocumentDiagnostics ) . GetProjectDiagnosticsAsync ( cancellationToken ) ;
2626
2727 private abstract class DiagnosticGetter (
2828 DiagnosticIncrementalAnalyzer owner ,
2929 Solution solution ,
3030 ProjectId projectId ,
3131 DocumentId ? documentId ,
32- Func < Project , DocumentId ? , IReadOnlyList < DocumentId > > ? getDocuments ,
3332 bool includeLocalDocumentDiagnostics ,
3433 bool includeNonLocalDocumentDiagnostics )
3534 {
@@ -41,8 +40,6 @@ private abstract class DiagnosticGetter(
4140 protected readonly bool IncludeLocalDocumentDiagnostics = includeLocalDocumentDiagnostics ;
4241 protected readonly bool IncludeNonLocalDocumentDiagnostics = includeNonLocalDocumentDiagnostics ;
4342
44- private readonly Func < Project , DocumentId ? , IReadOnlyList < DocumentId > > _getDocuments = getDocuments ?? ( static ( project , documentId ) => documentId != null ? [ documentId ] : project . DocumentIds ) ;
45-
4643 protected StateManager StateManager => Owner . _stateManager ;
4744
4845 protected virtual bool ShouldIncludeDiagnostic ( DiagnosticData diagnostic ) => true ;
@@ -59,7 +56,11 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsAsync(Cancellati
5956 // return diagnostics specific to one project or document
6057 var includeProjectNonLocalResult = DocumentId == null ;
6158 return await ProduceProjectDiagnosticsAsync (
62- project , _getDocuments ( project , DocumentId ) , includeProjectNonLocalResult , cancellationToken ) . ConfigureAwait ( false ) ;
59+ project ,
60+ // Ensure we compute and return diagnostics for both the normal docs and the additional docs in this
61+ // project if no specific document id was requested.
62+ this . DocumentId != null ? [ this . DocumentId ] : [ .. project . DocumentIds , .. project . AdditionalDocumentIds ] ,
63+ includeProjectNonLocalResult , cancellationToken ) . ConfigureAwait ( false ) ;
6364 }
6465
6566 protected async Task < ImmutableArray < DiagnosticData > > ProduceProjectDiagnosticsAsync (
@@ -88,7 +89,7 @@ private sealed class IdeCachedDiagnosticGetter(
8889 ProjectId projectId ,
8990 DocumentId ? documentId )
9091 : DiagnosticGetter (
91- owner , solution , projectId , documentId , getDocuments : null ,
92+ owner , solution , projectId , documentId ,
9293 includeLocalDocumentDiagnostics : documentId != null ,
9394 includeNonLocalDocumentDiagnostics : documentId != null )
9495 {
@@ -187,11 +188,10 @@ private sealed class IdeLatestDiagnosticGetter(
187188 DocumentId ? documentId ,
188189 ImmutableHashSet < string > ? diagnosticIds ,
189190 Func < DiagnosticAnalyzer , bool > ? shouldIncludeAnalyzer ,
190- Func < Project , DocumentId ? , IReadOnlyList < DocumentId > > ? getDocuments ,
191191 bool includeLocalDocumentDiagnostics ,
192192 bool includeNonLocalDocumentDiagnostics )
193193 : DiagnosticGetter (
194- owner , solution , projectId , documentId , getDocuments , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics )
194+ owner , solution , projectId , documentId , includeLocalDocumentDiagnostics , includeNonLocalDocumentDiagnostics )
195195 {
196196 private readonly ImmutableHashSet < string > ? _diagnosticIds = diagnosticIds ;
197197 private readonly Func < DiagnosticAnalyzer , bool > ? _shouldIncludeAnalyzer = shouldIncludeAnalyzer ;
0 commit comments