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 @@ -575,23 +575,27 @@ private async Task<TextDocument> UpdateDocumentInfoAsync(TextDocument document,

// there is no api to change these once document is created
Contract.ThrowIfFalse(document.State.Attributes.Id == newDocumentInfo.Id);
Contract.ThrowIfFalse(document.State.Attributes.Name == newDocumentInfo.Name);
Contract.ThrowIfFalse(document.State.Attributes.FilePath == newDocumentInfo.FilePath);
Contract.ThrowIfFalse(document.State.Attributes.IsGenerated == newDocumentInfo.IsGenerated);
Contract.ThrowIfFalse(document.State.Attributes.DesignTimeOnly == newDocumentInfo.DesignTimeOnly);

if (document.State.Attributes.Name != newDocumentInfo.Name)
document = document.Project.Solution.WithDocumentName(document.Id, newDocumentInfo.Name).GetRequiredDocument(document.Id);

if (document.State.Attributes.FilePath != newDocumentInfo.FilePath)
document = document.Project.Solution.WithDocumentFilePath(document.Id, newDocumentInfo.FilePath).GetRequiredDocument(document.Id);

if (document.State.Attributes.Folders != newDocumentInfo.Folders)
{
// additional document can't change folder once created
Contract.ThrowIfFalse(document is Document);
document = document.Project.Solution.WithDocumentFolders(document.Id, newDocumentInfo.Folders).GetDocument(document.Id)!;
document = document.Project.Solution.WithDocumentFolders(document.Id, newDocumentInfo.Folders).GetRequiredDocument(document.Id);
}

if (document.State.Attributes.SourceCodeKind != newDocumentInfo.SourceCodeKind)
{
// additional document can't change sourcecode kind once created
Contract.ThrowIfFalse(document is Document);
document = document.Project.Solution.WithDocumentSourceCodeKind(document.Id, newDocumentInfo.SourceCodeKind).GetDocument(document.Id)!;
document = document.Project.Solution.WithDocumentSourceCodeKind(document.Id, newDocumentInfo.SourceCodeKind).GetRequiredDocument(document.Id);
}

return document;
Expand Down
Loading