diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs index ecd4d9e256..d4ef146525 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs @@ -49,6 +49,19 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor return Task.FromResult(TagHelperResolutionResult.Empty); } + // In 15.6-7 this API is called by WTE to resolve tag helpers, and can be called on build - ie: without any ProjectSnapshot + // changes. That means that projectSnapshot.WorkspaceProject is out of date with respect to the actual workspace. + // + // To work around this issue, always grab the latest WorkspaceProject with the same ID, which will trigger tag helper + // discovery on the current state of the workspace. + // + // This workaround won't be needed in 15.8 since we do tag helper discovery through the project snapshot manager. + var latest = _workspace.CurrentSolution.GetProject(projectSnapshot.WorkspaceProject.Id) ?? projectSnapshot.WorkspaceProject; + if (projectSnapshot.WorkspaceProject != latest) + { + projectSnapshot = ((DefaultProjectSnapshot)projectSnapshot).WithWorkspaceProject(latest); + } + var resolver = _workspace.Services.GetLanguageServices(RazorLanguage.Name).GetRequiredService(); return resolver.GetTagHelpersAsync(projectSnapshot); } diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs index 85912aed47..7a9ca712f1 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs @@ -177,7 +177,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules { Microsoft.Build.Framework.XamlTypes.Rule t = ((Microsoft.Build.Framework.XamlTypes.Rule)(ruleEnumerator.Current)); if (System.StringComparer.OrdinalIgnoreCase.Equals(t.Name, SchemaName)) { unboundRule = t; - unboundRule.Name = "843bc0bc-5265-4864-9b06-f5d5503b0484"; + unboundRule.Name = "6ffb2641-19cd-4943-bc6d-446919acb77e"; RazorConfiguration.deserializedFallbackRule = unboundRule; } }