Merged
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff line change
Expand Up@@ -404,11 +404,11 @@ export class DebugSessionFeature extends LanguageClientConsumer

private getDotnetNamedConfigOrDefault(configName?: string): ResolveDebugConfigurationResult {
if (configName) {
const debugConfigs = workspace.getConfiguration("launch").get<DebugConfiguration[]>("configurations") ?? [];
return debugConfigs.find(({ type, request, name, dotnetDebuggerConfigName }) =>
const debugConfigs = this.getLaunchConfigurations();
return debugConfigs.find(({ type, request, name }) =>
type === "coreclr" &&
request === "attach" &&
name === dotnetDebuggerConfigName
name === configName
);
}

Expand All@@ -425,6 +425,11 @@ export class DebugSessionFeature extends LanguageClientConsumer
};
}

/** Fetches all available vscode launch configurations. This is abstracted out for easier testing */
private getLaunchConfigurations(): DebugConfiguration[] {
return workspace.getConfiguration("launch").get<DebugConfiguration[]>("configurations") ?? [];
}

private async resolveAttachDebugConfiguration(config: DebugConfiguration): Promise<ResolveDebugConfigurationResult> {
const platformDetails = getPlatformDetails();
const versionDetails = this.sessionManager.getPowerShellVersionDetails();
Expand DownExpand Up@@ -742,3 +747,4 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
this.waitingForClientToken = undefined;
}
}

Original file line numberDiff line numberDiff line change
Expand Up@@ -353,6 +353,56 @@ describe("DebugSessionFeature", () => {
assert.equal(actual!, null);
assert.match(logger.writeAndShowError.firstCall.args[0], /matching launch config was not found/);
});

it("Finds the correct dotnetDebuggerConfigName", async () => {
const foundDotnetConfig: DebugConfiguration = {
name: "TestDotnetAttachConfig",
request: "attach",
type: "coreclr",
};
const candidateDotnetConfigs: DebugConfiguration[] = [
{
name: "BadCandidate1",
type: "powershell",
request: "attach"
},
{
name: "BadCandidate2",
type: "coreclr",
request: "attach"
},
{ // This one has launch instead of attach and even tho it has same name, should not be matched
name: foundDotnetConfig.name,
type: "coreclr",
request: "launch"
},
foundDotnetConfig, //This is the one we want to match
{
name: foundDotnetConfig.name,
type: "notcoreclrExactly",
request: "attach"
},
{
name: `${foundDotnetConfig.name}notexactlythisname`,
type: "coreclr",
request: "attach"
}
];
const attachConfig = defaultDebugConfig;
attachConfig.script = "test.ps1"; // This bypasses the ${file} logic
attachConfig.createTemporaryIntegratedConsole = true;
attachConfig.attachDotnetDebugger = true;
attachConfig.dotnetDebuggerConfigName = foundDotnetConfig.name;
const debugSessionFeature = createDebugSessionFeatureStub({});

// The any is necessary to stub a private method
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Sinon.stub(debugSessionFeature, "getLaunchConfigurations" as any).returns(candidateDotnetConfigs);

const config = await debugSessionFeature.resolveDebugConfigurationWithSubstitutedVariables(undefined, attachConfig);

assert.deepStrictEqual(config!.dotnetAttachConfig, foundDotnetConfig);
});
});

describe("createDebugAdapterDescriptor", () => {
Expand Down