Skip to content

Commit a5e081e

Browse files
authored
Revert "Do not set IsDebuggedProcess for legacy WASM debugger (#9804) (#9806)"
This reverts commit 74c1d58.
1 parent 74c1d58 commit a5e081e

File tree

10 files changed

+11
-156
lines changed

10 files changed

+11
-156
lines changed

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/FeatureFlagNames.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,4 @@ internal static class FeatureFlagNames
2727
/// or out via the <c>AccelerateBuildsInVisualStudio</c> MSBuild property.
2828
/// </summary>
2929
public const string EnableBuildAccelerationByDefault = "ManagedProjectSystem.EnableBuildAccelerationByDefault";
30-
31-
/// <summary>
32-
/// Enables new WASM debugger.
33-
/// </summary>
34-
public const string EnableCorDebugWebAssemblyDebugger = "Debugger.NewMonoDebugEngine";
3530
}

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/ProjectSystemOptions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ public ValueTask<bool> IsBuildAccelerationEnabledByDefaultAsync(CancellationToke
8989
return IsFlagEnabledAsync(FeatureFlagNames.EnableBuildAccelerationByDefault, defaultValue: false, cancellationToken);
9090
}
9191

92-
public ValueTask<bool> IsCorDebugWebAssemblyDebuggerEnabledAsync(CancellationToken cancellationToken)
93-
=> IsFlagEnabledAsync(FeatureFlagNames.EnableCorDebugWebAssemblyDebugger, defaultValue: false, cancellationToken);
94-
9592
private async ValueTask<bool> IsFlagEnabledAsync(string featureName, bool defaultValue, CancellationToken cancellationToken)
9693
{
9794
IVsFeatureFlags featureFlags = await _featureFlagsService.GetValueAsync(cancellationToken);

src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/HotReload/ProjectHotReloadAgent.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace Microsoft.VisualStudio.ProjectSystem.HotReload;
1111
internal sealed class ProjectHotReloadAgent(
1212
Lazy<IHotReloadAgentManagerClient> hotReloadAgentManagerClient,
1313
Lazy<IHotReloadDiagnosticOutputService> hotReloadDiagnosticOutputService,
14-
IProjectSystemOptions projectSystemOptions,
1514
[Import(AllowDefault = true)] IHotReloadDebugStateProvider? debugStateProvider) // allow default until VS Code is updated: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2571211
1615
: IProjectHotReloadAgent
1716
{
@@ -34,7 +33,6 @@ public IProjectHotReloadSession CreateHotReloadSession(
3433
configuredProject: configuredProject,
3534
launchProfile: launchProfile,
3635
debugLaunchOptions: debugLaunchOptions,
37-
projectSystemOptions,
3836
debugStateProvider ?? DefaultDebugStateProvider.Instance);
3937
}
4038

src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/HotReload/ProjectHotReloadSession.cs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ internal sealed class ProjectHotReloadSession : IProjectHotReloadSessionInternal
2323
private readonly IProjectHotReloadBuildManager _buildManager;
2424
private readonly ILaunchProfile _launchProfile;
2525
private readonly DebugLaunchOptions _debugLaunchOptions;
26-
private readonly IProjectSystemOptions _projectSystemOptions;
2726
private readonly IHotReloadDebugStateProvider _debugStateProvider;
2827
private readonly IProjectHotReloadLaunchProvider _launchProvider;
2928

@@ -41,7 +40,6 @@ public ProjectHotReloadSession(
4140
ConfiguredProject configuredProject,
4241
ILaunchProfile launchProfile,
4342
DebugLaunchOptions debugLaunchOptions,
44-
IProjectSystemOptions projectSystemOptions,
4543
IHotReloadDebugStateProvider debugStateProvider)
4644
{
4745
Name = name;
@@ -55,7 +53,6 @@ public ProjectHotReloadSession(
5553
_buildManager = buildManager;
5654
_launchProvider = launchProvider;
5755
_debugLaunchOptions = debugLaunchOptions;
58-
_projectSystemOptions = projectSystemOptions;
5956
_debugStateProvider = debugStateProvider;
6057
}
6158

@@ -159,6 +156,8 @@ public async Task StartSessionAsync(CancellationToken cancellationToken)
159156
throw new InvalidOperationException("Attempting to start a Hot Reload session that is already running.");
160157
}
161158

159+
HotReloadAgentFlags flags = _debugLaunchOptions.HasFlag(DebugLaunchOptions.NoDebug) ? HotReloadAgentFlags.None : HotReloadAgentFlags.IsDebuggedProcess;
160+
162161
string targetFramework = await _configuredProject.GetProjectPropertyValueAsync(ConfigurationGeneral.TargetFrameworkProperty);
163162
bool hotReloadAutoRestart = await _configuredProject.GetProjectPropertyBoolAsync(ConfigurationGeneral.HotReloadAutoRestartProperty);
164163

@@ -175,14 +174,6 @@ public async Task StartSessionAsync(CancellationToken cancellationToken)
175174
DebugTrace($"Start session for project '{_configuredProject.UnconfiguredProject.FullPath}' with TFM '{targetFramework}' and HotReloadRestart {runningProjectInfo.RestartAutomatically}");
176175

177176
var processInfo = new ManagedEditAndContinueProcessInfo();
178-
179-
// If the debugger uses ICorDebug, the debugger is responsible for applying deltas to the process and the Hot Reload client receives empty deltas.
180-
// Otherwise, the Hot Reload client is responsible for applying deltas and needs to receive them from the debugger.
181-
// This is controlled by IsDebuggedProcess flag.
182-
var flags = _debugLaunchOptions.HasFlag(DebugLaunchOptions.NoDebug) || await UsingLegacyWebAssemblyDebugEngineAsync(cancellationToken)
183-
? HotReloadAgentFlags.None
184-
: HotReloadAgentFlags.IsDebuggedProcess;
185-
186177
await _hotReloadAgentManagerClient.Value.AgentStartedAsync(this, flags, processInfo, runningProjectInfo, cancellationToken);
187178

188179
WriteToOutputWindow(Resources.HotReloadStartSession, default);
@@ -195,31 +186,6 @@ public async Task StartSessionAsync(CancellationToken cancellationToken)
195186
_sessionActive = true;
196187
}
197188

198-
private async ValueTask<bool> UsingLegacyWebAssemblyDebugEngineAsync(CancellationToken cancellationToken)
199-
{
200-
if (_callback is not IProjectHotReloadSessionWebAssemblyCallback)
201-
{
202-
// not a WASM app:
203-
return false;
204-
}
205-
206-
if (await _projectSystemOptions.IsCorDebugWebAssemblyDebuggerEnabledAsync(cancellationToken) &&
207-
await IsCorDebugWebAssemblyDebuggerSupportedByProjectAsync())
208-
{
209-
// using new debugger:
210-
return false;
211-
}
212-
213-
// using old debugger:
214-
return true;
215-
216-
async ValueTask<bool> IsCorDebugWebAssemblyDebuggerSupportedByProjectAsync()
217-
{
218-
var targetFrameworkMoniker = await _configuredProject.GetProjectPropertyValueAsync(ConfigurationGeneral.TargetFrameworkMonikerProperty);
219-
return new FrameworkName(targetFrameworkMoniker).Version.Major >= 9;
220-
}
221-
}
222-
223189
public async Task StopSessionAsync(CancellationToken cancellationToken)
224190
{
225191
if (_sessionActive && _lazyDeltaApplier is not null)

src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/IProjectSystemOptions.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,4 @@ internal interface IProjectSystemOptions
6565
/// or out via the <c>AccelerateBuildsInVisualStudio</c> MSBuild property.
6666
/// </summary>
6767
ValueTask<bool> IsBuildAccelerationEnabledByDefaultAsync(CancellationToken cancellationToken);
68-
69-
/// <summary>
70-
/// True if the WASM debugger engine uses ICorDebug.
71-
/// </summary>
72-
ValueTask<bool> IsCorDebugWebAssemblyDebuggerEnabledAsync(CancellationToken cancellationToken);
7368
}

tests/Common/Test/App.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<add key="xunit.methodDisplay" value="method" />
55
<add key="xunit.shadowCopy" value="false"/>
66
</appSettings>
7-
<!-- TODO: https://github.com/dotnet/project-system/issues/9805
87
<system.diagnostics>
98
<trace>
109
<listeners>
@@ -13,5 +12,4 @@
1312
</listeners>
1413
</trace>
1514
</system.diagnostics>
16-
-->
1715
</configuration>

tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IProjectHotReloadSessionWebAssemblyCallbackFactory.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IProjectSystemOptionsFactory.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,4 @@ public static IProjectSystemOptions ImplementGetPreferSingleTargetBuildsForStart
4444

4545
return mock.Object;
4646
}
47-
48-
public static IProjectSystemOptions ImplementIsCorDebugWebAssemblyDebuggerEnabledAsync(bool value)
49-
{
50-
var mock = new Mock<IProjectSystemOptions>();
51-
mock.Setup(o => o.IsCorDebugWebAssemblyDebuggerEnabledAsync(It.IsAny<CancellationToken>()))
52-
.ReturnsAsync(value);
53-
54-
return mock.Object;
55-
}
5647
}

tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/TestBrowserRefreshServerAccessor.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/HotReload/ProjectHotReloadSessionTests.cs

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ public async Task StartSessionAsync_VerifiesCorrectProcessInfoAndProjectInfo()
140140
const string expectedProjectPath = "C:\\Test\\Project.csproj";
141141
const string expectedTf = "net6.0";
142142

143-
var configuredProject = CreateConfiguredProjectWithCommonProperties(
144-
projectPath: expectedProjectPath,
145-
targetFrameworkIdentifier: ".NETCoreApp",
146-
targetFrameworkVersion: "6.0");
143+
var configuredProject = CreateConfiguredProjectWithCommonProperties(expectedTf, expectedProjectPath);
147144

148145
var session = CreateInstance(
149146
hotReloadAgentManagerClient: new Lazy<IHotReloadAgentManagerClient>(() => hotReloadAgentManagerClient.Object),
@@ -196,11 +193,7 @@ public async Task StartSessionAsync_CallsAgentStartedWithCorrectParameters()
196193
{
197194
// Arrange
198195
var hotReloadAgentManagerClient = new Mock<IHotReloadAgentManagerClient>();
199-
var configuredProject = CreateConfiguredProjectWithCommonProperties(
200-
"C:\\Test\\Project.csproj",
201-
targetFrameworkIdentifier: ".NETCoreApp",
202-
targetFrameworkVersion: "6.0");
203-
196+
var configuredProject = CreateConfiguredProjectWithCommonProperties("net6.0", "C:\\Test\\Project.csproj");
204197
var cancellationToken = CancellationToken.None;
205198

206199
RunningProjectInfo capturedProjectInfo = default;
@@ -252,36 +245,18 @@ public async Task StartSessionAsync_CallsAgentStartedWithCorrectParameters()
252245
Times.Once);
253246
}
254247

255-
[Theory]
256-
// not debugging:
257-
[InlineData(false, true, false, "6.0", HotReloadAgentFlags.None)]
258-
[InlineData(false, true, true, "6.0", HotReloadAgentFlags.None)]
259-
// debugging non-wasm project:
260-
[InlineData(true, false, false, "6.0", HotReloadAgentFlags.IsDebuggedProcess)]
261-
// debugging wasm project using legacy debugger:
262-
[InlineData(true, true, false, "6.0", HotReloadAgentFlags.None)]
263-
[InlineData(true, true, true, "6.0", HotReloadAgentFlags.None)]
264-
[InlineData(true, true, true, "7.0", HotReloadAgentFlags.None)]
265-
[InlineData(true, true, true, "8.0", HotReloadAgentFlags.None)]
266-
// debugging wasm project using new debugger:
267-
[InlineData(true, true, true, "9.0", HotReloadAgentFlags.IsDebuggedProcess)]
268-
[InlineData(true, true, true, "10.0", HotReloadAgentFlags.IsDebuggedProcess)]
269-
public async Task StartSessionAsync_WithDebugger_SetsCorrectFlags(bool isDebugging, bool isWasmProject, bool isWasmCorDebugEnabled, string targetFrameworkVersion, HotReloadAgentFlags expectedFlags)
248+
[Fact]
249+
public async Task StartSessionAsync_WithDebugger_SetsCorrectFlags()
270250
{
271251
// Arrange
272252
var hotReloadAgentManagerClient = new Mock<IHotReloadAgentManagerClient>();
273-
var configuredProject = CreateConfiguredProjectWithCommonProperties(
274-
targetFrameworkIdentifier: ".NETCoreApp",
275-
targetFrameworkVersion: targetFrameworkVersion);
276-
253+
var configuredProject = CreateConfiguredProjectWithCommonProperties();
277254
var cancellationToken = CancellationToken.None;
278255

279256
var session = CreateInstance(
280257
hotReloadAgentManagerClient: new Lazy<IHotReloadAgentManagerClient>(() => hotReloadAgentManagerClient.Object),
281258
configuredProject: configuredProject,
282-
debugLaunchOptions: isDebugging ? 0 : DebugLaunchOptions.NoDebug,
283-
projectSystemOptions: IProjectSystemOptionsFactory.ImplementIsCorDebugWebAssemblyDebuggerEnabledAsync(isWasmCorDebugEnabled),
284-
callback: isWasmProject ? IProjectHotReloadSessionWebAssemblyCallbackFactory.Create() : null);
259+
debugLaunchOptions: 0);
285260

286261
// Act
287262
await session.StartSessionAsync(cancellationToken);
@@ -290,7 +265,7 @@ public async Task StartSessionAsync_WithDebugger_SetsCorrectFlags(bool isDebuggi
290265
hotReloadAgentManagerClient.Verify(
291266
client => client.AgentStartedAsync(
292267
session,
293-
expectedFlags,
268+
HotReloadAgentFlags.IsDebuggedProcess,
294269
It.IsAny<ManagedEditAndContinueProcessInfo>(),
295270
It.IsAny<RunningProjectInfo>(),
296271
cancellationToken),
@@ -586,8 +561,7 @@ private static ProjectHotReloadSession CreateInstance(
586561
DebugLaunchOptions debugLaunchOptions = DebugLaunchOptions.NoDebug,
587562
IProjectHotReloadBuildManager? buildManager = null,
588563
IProjectHotReloadLaunchProvider? launchProvider = null,
589-
IHotReloadDebugStateProvider? debugStateProvider = null,
590-
IProjectSystemOptions? projectSystemOptions = null)
564+
IHotReloadDebugStateProvider? debugStateProvider = null)
591565
{
592566
hotReloadAgentManagerClient ??= new(Mock.Of<IHotReloadAgentManagerClient>);
593567
hotReloadOutputService ??= new(Mock.Of<IHotReloadDiagnosticOutputService>);
@@ -612,7 +586,6 @@ private static ProjectHotReloadSession CreateInstance(
612586
buildManager ??= new Mock<IProjectHotReloadBuildManager>().Object;
613587
launchProvider ??= new Mock<IProjectHotReloadLaunchProvider>().Object;
614588
configuredProject ??= CreateConfiguredProjectWithCommonProperties();
615-
projectSystemOptions ??= new Mock<IProjectSystemOptions>().Object;
616589

617590
return new ProjectHotReloadSession(
618591
name,
@@ -625,36 +598,15 @@ private static ProjectHotReloadSession CreateInstance(
625598
configuredProject,
626599
launchProfile,
627600
debugLaunchOptions,
628-
projectSystemOptions,
629601
debugStateProvider);
630602
}
631603

632-
private static ConfiguredProject CreateConfiguredProjectWithCommonProperties(
633-
string projectPath = "C:\\Test\\Project.csproj",
634-
string targetFrameworkIdentifier = ".NETCoreApp",
635-
string targetFrameworkVersion = "6.0",
636-
string webAssemblyHotReloadCapabilities = "Baseline")
604+
private static ConfiguredProject CreateConfiguredProjectWithCommonProperties(string targetFramework = "net6.0", string projectPath = "C:\\Test\\Project.csproj")
637605
{
638-
var targetFramework = targetFrameworkIdentifier switch
639-
{
640-
".NETCoreApp" => "net" + targetFrameworkVersion,
641-
".NETFramework" => "net" + targetFrameworkVersion.Replace(".", ""),
642-
".NETStandard" => "netstandard" + targetFrameworkVersion,
643-
_ => throw new ArgumentException()
644-
};
645-
646-
var targetFrameworkMoniker = $"{targetFrameworkIdentifier}, Version=v{targetFrameworkVersion}";
647-
648606
var commonProperties = new Mock<IProjectProperties>();
649607
commonProperties.Setup(p => p.GetEvaluatedPropertyValueAsync(ConfigurationGeneral.TargetFrameworkProperty))
650608
.ReturnsAsync(targetFramework);
651609

652-
commonProperties.Setup(p => p.GetEvaluatedPropertyValueAsync(ConfigurationGeneral.TargetFrameworkMonikerProperty))
653-
.ReturnsAsync(targetFrameworkMoniker);
654-
655-
commonProperties.Setup(p => p.GetEvaluatedPropertyValueAsync("WebAssemblyHotReloadCapabilities"))
656-
.ReturnsAsync(webAssemblyHotReloadCapabilities);
657-
658610
var projectPropertiesProvider = new Mock<IProjectPropertiesProvider>();
659611
projectPropertiesProvider.Setup(p => p.GetCommonProperties())
660612
.Returns(commonProperties.Object);

0 commit comments

Comments
 (0)