From 6702e25e5330e8b4271e40a4a1c15bb23af59ea6 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 25 Oct 2024 14:53:08 +1100 Subject: [PATCH] Invalidate project engine when UseRoslynTokenizer changes --- .../ProjectSystem/ProjectState.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs index 1e1e738399..bbb5418aaf 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs @@ -151,14 +151,15 @@ internal class ProjectState else { ProjectWorkspaceStateVersion = Version; - } - if ((difference & ClearProjectWorkspaceStateVersionMask) != 0 && - CSharpLanguageVersion != older.CSharpLanguageVersion) - { - // C# language version changed. This impacts the ProjectEngine, reset it. - _projectEngine = null; - ConfigurationVersion = Version; + // CSharpLanguageVersion and UseRoslynTokenizer are part of the ProjectWorkspaceState, but they affect the project engine + // so we check for those specifically changing, and clear that. + if (CSharpLanguageVersion != older.CSharpLanguageVersion || + ProjectWorkspaceState.UseRoslynTokenizer != older.ProjectWorkspaceState.UseRoslynTokenizer) + { + _projectEngine = null; + ConfigurationVersion = Version; + } } }