refactor more TryApplyChanges
This commit is contained in:
@@ -996,16 +996,22 @@ public class RoslynAnalysis(ILogger<RoslynAnalysis> logger, BuildService buildSe
|
|||||||
|
|
||||||
public async Task MoveDocument(SharpIdeFile sharpIdeFile, string oldFilePath)
|
public async Task MoveDocument(SharpIdeFile sharpIdeFile, string oldFilePath)
|
||||||
{
|
{
|
||||||
var document = _workspace!.CurrentSolution.GetDocumentIdsWithFilePath(oldFilePath).Single();
|
var documentId = _workspace!.CurrentSolution.GetDocumentIdsWithFilePath(oldFilePath).Single();
|
||||||
var updatedSolution = _workspace.CurrentSolution.WithDocumentFilePath(document, sharpIdeFile.Path);
|
_workspace.SetCurrentSolution(oldSolution =>
|
||||||
_workspace.TryApplyChanges(updatedSolution);
|
{
|
||||||
|
var newSolution = oldSolution.WithDocumentFilePath(documentId, sharpIdeFile.Path);
|
||||||
|
return newSolution;
|
||||||
|
}, WorkspaceChangeKind.DocumentInfoChanged, documentId: documentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RenameDocument(SharpIdeFile sharpIdeFile, string oldFilePath)
|
public async Task RenameDocument(SharpIdeFile sharpIdeFile, string oldFilePath)
|
||||||
{
|
{
|
||||||
var documentId = _workspace!.CurrentSolution.GetDocumentIdsWithFilePath(oldFilePath).Single();
|
var documentId = _workspace!.CurrentSolution.GetDocumentIdsWithFilePath(oldFilePath).Single();
|
||||||
var updatedSolution = _workspace.CurrentSolution.WithDocumentName(documentId, sharpIdeFile.Name);
|
_workspace.SetCurrentSolution(oldSolution =>
|
||||||
_workspace.TryApplyChanges(updatedSolution);
|
{
|
||||||
|
var newSolution = oldSolution.WithDocumentName(documentId, sharpIdeFile.Name);
|
||||||
|
return newSolution;
|
||||||
|
}, WorkspaceChangeKind.DocumentInfoChanged, documentId: documentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetOutputDllPathForProject(SharpIdeProjectModel projectModel)
|
public async Task<string> GetOutputDllPathForProject(SharpIdeProjectModel projectModel)
|
||||||
|
|||||||
Reference in New Issue
Block a user