Skip to content

Commit 8b6e05b

Browse files
Make ISnapshotResolver.TryResolveAllProjects synchronous
This extension method no longer has awaits and can be made synchronous. In addition, the cancellation token can be removed.
1 parent 56356ef commit 8b6e05b

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/ISnapshotResolverExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
1212

1313
internal static class ISnapshotResolverExtensions
1414
{
15-
public static async Task<ImmutableArray<IProjectSnapshot>> TryResolveAllProjectsAsync(
15+
public static ImmutableArray<IProjectSnapshot> TryResolveAllProjects(
1616
this ISnapshotResolver snapshotResolver,
17-
string documentFilePath,
18-
CancellationToken cancellationToken)
17+
string documentFilePath)
1918
{
2019
var potentialProjects = snapshotResolver.FindPotentialProjects(documentFilePath);
2120

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private async Task ActOnDocumentInMultipleProjectsAsync(
258258
CancellationToken cancellationToken)
259259
{
260260
var textDocumentPath = FilePathNormalizer.Normalize(filePath);
261-
var projects = await _snapshotResolver.TryResolveAllProjectsAsync(textDocumentPath, cancellationToken).ConfigureAwait(false);
261+
var projects = _snapshotResolver.TryResolveAllProjects(textDocumentPath);
262262
if (projects.IsEmpty)
263263
{
264264
var miscFilesProject = _snapshotResolver.GetMiscellaneousProject();

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Tooltip/TagHelperTooltipFactoryBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected TagHelperTooltipFactoryBase(ISnapshotResolver snapshotResolver)
3131

3232
internal async Task<string?> GetProjectAvailabilityAsync(string documentFilePath, string tagHelperTypeName, CancellationToken cancellationToken)
3333
{
34-
var projectSnapshots = await _snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, cancellationToken).ConfigureAwait(false);
34+
var projectSnapshots = _snapshotResolver.TryResolveAllProjects(documentFilePath);
3535
if (projectSnapshots.IsEmpty)
3636
{
3737
return null;

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SnapshotResolverTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public async Task TryResolveAllProjects_NoProjects_ReturnsFalse()
8585
await snapshotResolver.InitializeAsync(DisposalToken);
8686

8787
// Act
88-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
88+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
8989

9090
// Assert
9191
Assert.Empty(projects);
@@ -101,7 +101,7 @@ public async Task TryResolveAllProjects_OnlyMiscellaneousProjectDoesNotContainDo
101101
await snapshotResolver.InitializeAsync(DisposalToken);
102102

103103
// Act
104-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
104+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
105105

106106
// Assert
107107
Assert.Empty(projects);
@@ -116,7 +116,7 @@ public async Task TryResolveAllProjects_OnlyMiscellaneousProjectContainsDocument
116116
await snapshotResolver.InitializeAsync(DisposalToken);
117117

118118
// Act
119-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
119+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
120120

121121
// Assert
122122
var miscFilesProject = snapshotResolver.GetMiscellaneousProject();
@@ -138,7 +138,7 @@ await projectManager.UpdateAsync(updater =>
138138
});
139139

140140
// Act
141-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
141+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
142142

143143
// Assert
144144
Assert.Empty(projects);
@@ -164,7 +164,7 @@ public async Task TryResolveAllProjects_OwnerProjectWithOthers_ReturnsTrue()
164164
});
165165

166166
// Act
167-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
167+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
168168

169169
// Assert
170170
var project = Assert.Single(projects);
@@ -192,7 +192,7 @@ public async Task TryResolveAllProjects_MiscellaneousOwnerProjectWithOthers_Retu
192192
});
193193

194194
// Act
195-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
195+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
196196

197197
// Assert
198198
var project = Assert.Single(projects);
@@ -217,7 +217,7 @@ public async Task TryResolveAllProjects_OwnerProjectDifferentCasing_ReturnsTrue(
217217
});
218218

219219
// Act
220-
var projects = await snapshotResolver.TryResolveAllProjectsAsync(documentFilePath, DisposalToken);
220+
var projects = snapshotResolver.TryResolveAllProjects(documentFilePath);
221221

222222
// Assert
223223
var project = Assert.Single(projects);

0 commit comments

Comments
 (0)