From 2eb966431fa9598377d11bdc5acdd1f74238155f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 17 Jun 2022 12:54:31 +0200 Subject: [PATCH 1/2] Pass sources, to fix native debug --- .../DesignMode/DesignModeClient.cs | 1 + .../Client/ProxyExecutionManager.cs | 18 ++++++++++++------ .../Client/Interfaces/AttachDebuggerInfo.cs | 3 +++ .../PublicAPI/net/PublicAPI.Unshipped.txt | 5 ++++- .../TestProcessAttachDebuggerPayload.cs | 5 +++++ .../VsTestConsoleRequestSender.cs | 8 +++++++- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs index 381e714a32..60bffdb837 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs @@ -368,6 +368,7 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo, Cance { var payload = new EditorAttachDebuggerPayload { + Sources = attachDebuggerInfo.Sources, TargetFramework = attachDebuggerInfo.TargetFramework?.ToString(), ProcessID = attachDebuggerInfo.ProcessId, }; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs index e8ceacd854..e55bb30182 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs @@ -40,6 +40,7 @@ internal class ProxyExecutionManager : IProxyExecutionManager, IBaseProxy, IInte private readonly IFileHelper _fileHelper; private readonly IDataSerializer _dataSerializer; + private List _testSources; private bool _isCommunicationEstablished; private ProxyOperationManager _proxyOperationManager; @@ -172,21 +173,21 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRu { EqtTrace.Verbose("ProxyExecutionManager: Test host is always Lazy initialize."); - var testSources = new List( + _testSources = new List( testRunCriteria.HasSpecificSources ? testRunCriteria.Sources // If the test execution is with a test filter, group them by sources. : testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key)); _isCommunicationEstablished = _proxyOperationManager.SetupChannel( - testSources, + _testSources, testRunCriteria.TestRunSettings); if (_isCommunicationEstablished) { _proxyOperationManager.CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); - InitializeExtensions(testSources); + InitializeExtensions(_testSources); // This code should be in sync with InProcessProxyExecutionManager.StartTestRun // execution context. @@ -218,7 +219,7 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRu _testHostManager, runsettings, executionContext, - testSources); + _testSources); _proxyOperationManager.RequestSender.StartTestRun(runRequest, this); } else @@ -227,7 +228,7 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRu _testHostManager, runsettings, executionContext, - testSources); + _testSources); _proxyOperationManager.RequestSender.StartTestRun(runRequest, this); } } @@ -347,11 +348,16 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo) // TestHost did not provide any additional TargetFramework info for the process it wants to attach to, // specify the TargetFramework of the testhost, in case it is just an old testhost that is not aware // of this capability. - if (attachDebuggerInfo.TargetFramework == default(string)) + if (attachDebuggerInfo.TargetFramework is null) { attachDebuggerInfo.TargetFramework = _proxyOperationManager.TestHostManagerFramework.ToString(); }; + if (attachDebuggerInfo.Sources is null || !attachDebuggerInfo.Sources.Any()) + { + attachDebuggerInfo.Sources = _testSources; + } + return _baseTestRunEventsHandler.AttachDebuggerToProcess(attachDebuggerInfo); } diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/AttachDebuggerInfo.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/AttachDebuggerInfo.cs index d67fa81edb..cec061d0a4 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/AttachDebuggerInfo.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/AttachDebuggerInfo.cs @@ -1,10 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Generic; + namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; public class AttachDebuggerInfo { public int ProcessId { get; set; } public string? TargetFramework { get; set; } + public ICollection? Sources { get; set; } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt index 5f282702bb..36b5a40472 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt @@ -1 +1,4 @@ - \ No newline at end of file +Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.get -> System.Collections.Generic.ICollection +Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.set -> void +Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.get -> System.Collections.Generic.ICollection +Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.set -> void \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs index 728ab90c60..129b62911b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections; +using System.Collections.Generic; using System.Runtime.Serialization; namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -43,4 +45,7 @@ public class EditorAttachDebuggerPayload [DataMember] public string? TargetFramework { get; set; } + + [DataMember] + public ICollection? Sources { get; set; } } diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs index 61aad0044d..33c1ad1b32 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs @@ -1447,7 +1447,13 @@ private void AttachDebuggerToProcess(ITestHostLauncher customHostLauncher, Messa switch (customHostLauncher) { case ITestHostLauncher3 launcher3: - ackPayload.Attached = launcher3.AttachDebuggerToProcess(new AttachDebuggerInfo { ProcessId = attachDebuggerPayload.ProcessID, TargetFramework = attachDebuggerPayload.TargetFramework }, CancellationToken.None); + var attachDebuggerInfo = new AttachDebuggerInfo + { + ProcessId = attachDebuggerPayload.ProcessID, + TargetFramework = attachDebuggerPayload.TargetFramework, + Sources = attachDebuggerPayload.Sources, + }; + ackPayload.Attached = launcher3.AttachDebuggerToProcess(attachDebuggerInfo, CancellationToken.None); break; case ITestHostLauncher2 launcher2: ackPayload.Attached = launcher2.AttachDebuggerToProcess(attachDebuggerPayload.ProcessID); From 48f05f1efa7f1f1b35ca4668829be29a77cc139c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 17 Jun 2022 13:00:28 +0200 Subject: [PATCH 2/2] public api --- .../PublicAPI/PublicAPI.Shipped.txt | 4 ++++ .../PublicAPI/net/PublicAPI.Unshipped.txt | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt index 3e4e800065..f60fbb21e7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt @@ -961,3 +961,7 @@ Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryCompleteEventArg Microsoft.VisualStudio.TestPlatform.ObjectModel.RunConfiguration.DefaultPlatform.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture? Microsoft.VisualStudio.TestPlatform.ObjectModel.RunConfiguration.DefaultPlatform.set -> void Microsoft.VisualStudio.TestPlatform.ObjectModel.RunConfiguration.DefaultPlatformSet.get -> bool +Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.get -> System.Collections.Generic.ICollection +Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.set -> void +Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.get -> System.Collections.Generic.ICollection +Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.set -> void diff --git a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt index 36b5a40472..5f282702bb 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/net/PublicAPI.Unshipped.txt @@ -1,4 +1 @@ -Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.get -> System.Collections.Generic.ICollection -Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.set -> void -Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.get -> System.Collections.Generic.ICollection -Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.set -> void \ No newline at end of file + \ No newline at end of file