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 @@ -114,11 +114,18 @@ private async Task AddFallbackProjectAsync(ProjectId projectId, string filePath,
// the project will be updated, and it will no longer be a fallback project.
var hostProject = new FallbackHostProject(project.FilePath, intermediateOutputPath, FallbackRazorConfiguration.Latest, rootNamespace, project.Name);

await _dispatcher
.RunOnDispatcherThreadAsync(
() => _projectManagerAccessor.Instance.ProjectAdded(hostProject),
cancellationToken)
.ConfigureAwait(false);
if (_dispatcher.IsDispatcherThread)
Comment on lines -121 to +117
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this logic just be moved into RunOnDispatcherThread ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%! But I'm just making a small change for the 17.10p2 QB. I'll have a proper PR that updates dispatcher on main up shortly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me

{
_projectManagerAccessor.Instance.ProjectAdded(hostProject);
}
else
{
await _dispatcher
.RunOnDispatcherThreadAsync(
() => _projectManagerAccessor.Instance.ProjectAdded(hostProject),
cancellationToken)
.ConfigureAwait(false);
}

await AddFallbackDocumentAsync(hostProject.Key, filePath, project.FilePath, cancellationToken).ConfigureAwait(false);

Expand All @@ -137,11 +144,18 @@ private async Task AddFallbackDocumentAsync(ProjectKey projectKey, string filePa

var textLoader = new FileTextLoader(filePath, defaultEncoding: null);

await _dispatcher
.RunOnDispatcherThreadAsync(
() => _projectManagerAccessor.Instance.DocumentAdded(projectKey, hostDocument, textLoader),
cancellationToken)
.ConfigureAwait(false);
if (_dispatcher.IsDispatcherThread)
{
_projectManagerAccessor.Instance.DocumentAdded(projectKey, hostDocument, textLoader);
}
else
{
await _dispatcher
.RunOnDispatcherThreadAsync(
() => _projectManagerAccessor.Instance.DocumentAdded(projectKey, hostDocument, textLoader),
cancellationToken)
.ConfigureAwait(false);
}
}

private static HostDocument? CreateHostDocument(string filePath, string projectFilePath)
Expand Down Expand Up @@ -180,11 +194,18 @@ private async Task RemoveFallbackDocumentAsync(ProjectId projectId, string fileP
return;
}

await _dispatcher
.RunOnDispatcherThreadAsync(
() => _projectManagerAccessor.Instance.DocumentRemoved(razorProjectKey, hostDocument),
cancellationToken)
.ConfigureAwait(false);
if (_dispatcher.IsDispatcherThread)
{
_projectManagerAccessor.Instance.DocumentRemoved(razorProjectKey, hostDocument);
}
else
{
await _dispatcher
.RunOnDispatcherThreadAsync(
() => _projectManagerAccessor.Instance.DocumentRemoved(razorProjectKey, hostDocument),
cancellationToken)
.ConfigureAwait(false);
}
}

private Project? TryFindProjectForProjectId(ProjectId projectId)
Expand Down