Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Exception
  • Loading branch information
CyrusNajmabadi committed Aug 27, 2025
commit f660a27389119f808f453751c394b94577a27585
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,18 @@ public static TextDocument GetRequiredAnalyzerConfigDocument(this Solution solut
=> solution.GetAnalyzerConfigDocument(documentId) ?? throw CreateDocumentNotFoundException();

public static TextDocument GetRequiredTextDocument(this Solution solution, DocumentId documentId)
=> solution.GetTextDocument(documentId) ?? throw CreateDocumentNotFoundException();
{
var document = solution.GetTextDocument(documentId);
if (document != null)
return document;

#if WORKSPACE
if (documentId.IsSourceGenerated)
throw new InvalidOperationException($"Use {nameof(GetRequiredTextDocumentAsync)} to get the {nameof(TextDocument)} for a `.{nameof(DocumentId.IsSourceGenerated)}=true` {nameof(DocumentId)}");
#endif

throw CreateDocumentNotFoundException();
}

private static Exception CreateDocumentNotFoundException()
=> new InvalidOperationException(WorkspaceExtensionsResources.The_solution_does_not_contain_the_specified_document);
Expand Down
Loading