Fix source generator updates using additional files

This commit is contained in:
Matt Parker
2025-11-28 18:08:18 +10:00
parent 5bebf7e677
commit f4b1e9c1c0
2 changed files with 5 additions and 10 deletions

View File

@@ -107,10 +107,9 @@ public class FileChangedService
}
var afterSaveTask = (file, changeType) switch
{
({ IsRoslynWorkspaceFile: true }, _) => HandleWorkspaceFileChanged(file, newContents),
({ IsCsprojFile: true }, FileChangeType.IdeSaveToDisk or FileChangeType.ExternalChange) => HandleCsprojChanged(file),
({ IsCsprojFile: true }, _) => Task.CompletedTask,
_ => throw new InvalidOperationException("Unknown file change type.")
(_, _) => HandlePotentialWorkspaceFile_Changed(file, newContents)
};
await afterSaveTask;
}
@@ -130,7 +129,8 @@ public class FileChangedService
_updateSolutionDiagnosticsQueue.AddWork();
}
private async Task HandleWorkspaceFileChanged(SharpIdeFile file, string newContents)
/// AdditionalFiles such as txt files may have changed, so we need to attempt to update the workspace regardless of extension
private async Task HandlePotentialWorkspaceFile_Changed(SharpIdeFile file, string newContents)
{
var fileUpdatedInWorkspace = await _roslynAnalysis.UpdateDocument(file, newContents);
if (fileUpdatedInWorkspace is false) return;