From 0289148f770721e29d5f3c6617e115e2abb19644 Mon Sep 17 00:00:00 2001 From: tmat Date: Tue, 16 Dec 2025 15:26:43 -0800 Subject: [PATCH] Hot Reload: Temporarily disable project-level analysis --- .../EditAndContinue/AbstractEditAndContinueAnalyzer.cs | 7 ++++++- src/Features/Core/Portable/EditAndContinue/EditSession.cs | 4 ++-- .../ExternalAccess/HotReload/Api/HotReloadService.cs | 1 + .../EditAndContinue/EditAndContinueWorkspaceTestBase.cs | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs b/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs index 6a398fe7223ae..e12c7b362e900 100644 --- a/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs +++ b/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs @@ -29,6 +29,11 @@ namespace Microsoft.CodeAnalysis.EditAndContinue; internal abstract partial class AbstractEditAndContinueAnalyzer : IEditAndContinueAnalyzer { + // TODO: https://github.com/dotnet/roslyn/issues/81728 + // Temporarily disabled until https://devdiv.visualstudio.com/DevDiv/_queries/edit/1835505 is implemented. + // Only enabled in dotnet-watch and tests. + internal static bool EnableProjectLevelAnalysis = false; + internal const int DefaultStatementPart = 0; private const string CreateNewOnMetadataUpdateAttributeName = "CreateNewOnMetadataUpdateAttribute"; private const string RestartRequiredOnMetadataUpdateAttributeName = "RestartRequiredOnMetadataUpdateAttribute"; @@ -578,7 +583,7 @@ public async Task AnalyzeDocumentAsync( // since the option changed would have different semantics than the parts that have changed. // // Skip further analysis of the document if we detect any such change (classified as rude edits) in parse options. - if (GetParseOptionsRudeEdits(oldTree.Options, newTree.Options).Any()) + if (EnableProjectLevelAnalysis && GetParseOptionsRudeEdits(oldTree.Options, newTree.Options).Any()) { log.Write($"Parse options differ for '{filePath}'"); diff --git a/src/Features/Core/Portable/EditAndContinue/EditSession.cs b/src/Features/Core/Portable/EditAndContinue/EditSession.cs index df9394c7f4a4b..2c82dc9021af5 100644 --- a/src/Features/Core/Portable/EditAndContinue/EditSession.cs +++ b/src/Features/Core/Portable/EditAndContinue/EditSession.cs @@ -343,7 +343,7 @@ internal static async ValueTask HasDifferencesAsync(Project oldProject, Pr return false; } - if (HasProjectLevelDifferences(oldProject, newProject, differences) && differences == null) + if (AbstractEditAndContinueAnalyzer.EnableProjectLevelAnalysis && HasProjectLevelDifferences(oldProject, newProject, differences) && differences == null) { return true; } @@ -1213,7 +1213,7 @@ void UpdateChangedDocumentsStaleness(bool isStale) var projectSummary = GetProjectAnalysisSummary(changedDocumentAnalyses); - if (HasProjectSettingsBlockingRudeEdits(oldProject, newProject, projectDiagnostics)) + if (AbstractEditAndContinueAnalyzer.EnableProjectLevelAnalysis && HasProjectSettingsBlockingRudeEdits(oldProject, newProject, projectDiagnostics)) { // If the project settings have changed and the change is a rude edit, // block applying the changes even if there no other changes to the project documents. diff --git a/src/Features/ExternalAccess/HotReload/Api/HotReloadService.cs b/src/Features/ExternalAccess/HotReload/Api/HotReloadService.cs index da8d623383977..2fd1703b00389 100644 --- a/src/Features/ExternalAccess/HotReload/Api/HotReloadService.cs +++ b/src/Features/ExternalAccess/HotReload/Api/HotReloadService.cs @@ -138,6 +138,7 @@ public readonly struct Updates public HotReloadService(HostWorkspaceServices services, ImmutableArray capabilities) : this(services.SolutionServices, () => ValueTask.FromResult(AddImplicitDotNetCapabilities(capabilities))) { + AbstractEditAndContinueAnalyzer.EnableProjectLevelAnalysis = true; } private DebuggingSessionId GetDebuggingSession() diff --git a/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs b/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs index 12904badeb6c6..9918dd23f4773 100644 --- a/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs +++ b/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs @@ -33,6 +33,12 @@ namespace Microsoft.CodeAnalysis.EditAndContinue.UnitTests; public abstract class EditAndContinueWorkspaceTestBase : TestBase, IDisposable { + static EditAndContinueWorkspaceTestBase() + { + // TODO: remove https://github.com/dotnet/roslyn/issues/81728 + AbstractEditAndContinueAnalyzer.EnableProjectLevelAnalysis = true; + } + private protected static readonly Guid s_solutionTelemetryId = Guid.Parse("00000000-AAAA-AAAA-AAAA-000000000000"); private protected static readonly Guid s_defaultProjectTelemetryId = Guid.Parse("00000000-AAAA-AAAA-AAAA-111111111111"); private protected static readonly Regex s_timePropertiesRegex = new("[|](EmitDifferenceMilliseconds|TotalAnalysisMilliseconds)=[0-9]+");