Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass sources, to fix native debug #3777

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo, Cance
{
var payload = new EditorAttachDebuggerPayload
{
Sources = attachDebuggerInfo.Sources,
TargetFramework = attachDebuggerInfo.TargetFramework?.ToString(),
ProcessID = attachDebuggerInfo.ProcessId,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal class ProxyExecutionManager : IProxyExecutionManager, IBaseProxy, IInte

private readonly IFileHelper _fileHelper;
private readonly IDataSerializer _dataSerializer;
private List<string> _testSources;
private bool _isCommunicationEstablished;

private ProxyOperationManager _proxyOperationManager;
Expand Down Expand Up @@ -172,21 +173,21 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRu
{
EqtTrace.Verbose("ProxyExecutionManager: Test host is always Lazy initialize.");

var testSources = new List<string>(
_testSources = new List<string>(
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.
Expand Down Expand Up @@ -218,7 +219,7 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRu
_testHostManager,
runsettings,
executionContext,
testSources);
_testSources);
_proxyOperationManager.RequestSender.StartTestRun(runRequest, this);
}
else
Expand All @@ -227,7 +228,7 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRu
_testHostManager,
runsettings,
executionContext,
testSources);
_testSources);
_proxyOperationManager.RequestSender.StartTestRun(runRequest, this);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<string>? Sources { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>
Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo.Sources.set -> void
Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.get -> System.Collections.Generic.ICollection<string>
Microsoft.VisualStudio.TestPlatform.ObjectModel.EditorAttachDebuggerPayload.Sources.set -> void
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,4 +45,7 @@ public class EditorAttachDebuggerPayload

[DataMember]
public string? TargetFramework { get; set; }

[DataMember]
public ICollection<string>? Sources { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down