Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GetTagHelpersSynchronously extension method #11205

Merged
Merged
Show file tree
Hide file tree
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 @@ -3,9 +3,6 @@

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.AspNetCore.Razor.Serialization;
Expand Down Expand Up @@ -38,20 +35,6 @@ public static RazorProjectInfo ToRazorProjectInfo(this IProjectSnapshot project)
documents: documents.DrainToImmutable());
}

public static ImmutableArray<TagHelperDescriptor> GetTagHelpersSynchronously(this IProjectSnapshot projectSnapshot)
{
var canResolveTagHelpersSynchronously = projectSnapshot is ProjectSnapshot ||
projectSnapshot.GetType().FullName == "Microsoft.VisualStudio.LegacyEditor.Razor.EphemeralProjectSnapshot";

Debug.Assert(canResolveTagHelpersSynchronously, "The ProjectSnapshot in the VisualStudioDocumentTracker should not be a cohosted project.");
var tagHelperTask = projectSnapshot.GetTagHelpersAsync(CancellationToken.None);
Debug.Assert(tagHelperTask.IsCompleted, "GetTagHelpersAsync should be synchronous for non-cohosted projects.");

#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
return tagHelperTask.Result;
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
}

public static ImmutableArray<IDocumentSnapshot> GetRelatedDocuments(this IProjectSnapshot projectSnapshot, IDocumentSnapshot document)
{
if (projectSnapshot is not ProjectSnapshot project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,9 @@ public VisualStudioDocumentTracker(
public ClientSpaceSettings EditorSettings => _workspaceEditorSettings.Current.ClientSpaceSettings;

public ImmutableArray<TagHelperDescriptor> TagHelpers
{
get
{
if (ProjectSnapshot is null)
{
return ImmutableArray<TagHelperDescriptor>.Empty;
}

return ProjectSnapshot.GetTagHelpersSynchronously();
}
}
=> _projectSnapshot is { ProjectWorkspaceState.TagHelpers: var tagHelpers }
? tagHelpers
: [];

public bool IsSupportedProject => _isSupportedProject;

Expand Down Expand Up @@ -231,7 +223,7 @@ internal void ProjectManager_Changed(object sender, ProjectChangeEventArgs e)
_ = OnContextChangedAsync(ContextChangeKind.ProjectChanged);

if (e.Older is null ||
!e.Older.GetTagHelpersSynchronously().SequenceEqual(e.Newer!.GetTagHelpersSynchronously()))
!e.Older.ProjectWorkspaceState.TagHelpers.SequenceEqual(e.Newer!.ProjectWorkspaceState.TagHelpers))
{
_ = OnContextChangedAsync(ContextChangeKind.TagHelpersChanged);
}
Expand Down