Skip to content

Commit 4e381be

Browse files
Merge pull request #53768 from jasonmalinowski/allow-async-batch-application
Allow us to dispose batches asynchronously
2 parents 241ed70 + db70b30 commit 4e381be

8 files changed

Lines changed: 323 additions & 249 deletions

File tree

src/VisualStudio/CSharp/Test/ProjectSystemShim/CPS/SourceFileHandlingTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public async Task ReorderSourceFilesBatch_CPS()
144144

145145
project.ReorderSourceFiles(new[] { sourceFileFullPath5, sourceFileFullPath3, sourceFileFullPath1 });
146146

147-
project.EndBatch();
147+
await project.EndBatchAsync();
148148

149149
var documents = GetCurrentDocuments().ToArray();
150150

@@ -196,7 +196,7 @@ public async Task ReorderSourceFilesBatchWithReAdding_CPS()
196196

197197
project.ReorderSourceFiles(new[] { sourceFileFullPath5, sourceFileFullPath4, sourceFileFullPath3, sourceFileFullPath2, sourceFileFullPath1 });
198198

199-
project.EndBatch();
199+
await project.EndBatchAsync();
200200

201201
var documents = GetCurrentDocuments().ToArray();
202202

@@ -234,7 +234,7 @@ public async Task ReorderSourceFilesBatchAddAfterReorder_CPS()
234234
project.AddSourceFile(sourceFileFullPath4);
235235
project.AddSourceFile(sourceFileFullPath5);
236236

237-
project.EndBatch();
237+
await project.EndBatchAsync();
238238

239239
project.ReorderSourceFiles(new[] { sourceFileFullPath5, sourceFileFullPath4, sourceFileFullPath3, sourceFileFullPath2, sourceFileFullPath1 });
240240

@@ -277,7 +277,7 @@ public async Task ReorderSourceFilesBatchRemoveAfterReorder_CPS()
277277
project.RemoveSourceFile(sourceFileFullPath4);
278278
project.RemoveSourceFile(sourceFileFullPath5);
279279

280-
project.EndBatch();
280+
await project.EndBatchAsync();
281281

282282
project.ReorderSourceFiles(new[] { sourceFileFullPath2, sourceFileFullPath1 });
283283

@@ -371,7 +371,7 @@ public async Task ReorderSourceFilesBatchExceptions_CPS()
371371
Assert.Throws<ArgumentOutOfRangeException>(() => project.ReorderSourceFiles(new List<string>()));
372372
Assert.Throws<ArgumentOutOfRangeException>(() => project.ReorderSourceFiles(null));
373373

374-
project.EndBatch();
374+
await project.EndBatchAsync();
375375
}
376376

377377
[WpfFact]
@@ -395,7 +395,7 @@ public async Task ReorderSourceFilesBatchExceptionRemoveFile_CPS()
395395
project.RemoveSourceFile(sourceFileFullPath2);
396396
Assert.Throws<InvalidOperationException>(() => project.ReorderSourceFiles(new[] { sourceFileFullPath2 }));
397397

398-
project.EndBatch();
398+
await project.EndBatchAsync();
399399

400400
var documents = GetCurrentDocuments().ToArray();
401401

src/VisualStudio/Core/Def/Implementation/ProjectSystem/CPS/IWorkspaceProjectContext.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System;
88
using System.Collections.Generic;
99
using System.Collections.Immutable;
10+
using System.Threading.Tasks;
1011
using Microsoft.CodeAnalysis;
1112

1213
namespace Microsoft.VisualStudio.LanguageServices.ProjectSystem
@@ -75,7 +76,9 @@ internal interface IWorkspaceProjectContext : IDisposable
7576
void SetRuleSetFile(string filePath);
7677

7778
void StartBatch();
79+
[Obsolete($"Use {nameof(EndBatchAsync)}.")]
7880
void EndBatch();
81+
ValueTask EndBatchAsync();
7982

8083
void ReorderSourceFiles(IEnumerable<string> filePaths);
8184
}

0 commit comments

Comments
 (0)