Skip to content

Commit c9d18d9

Browse files
committed
Migrate unit test debug options to common option
1 parent 388eef2 commit c9d18d9

File tree

7 files changed

+241
-217
lines changed

7 files changed

+241
-217
lines changed

package.json

Lines changed: 209 additions & 209 deletions
Large diffs are not rendered by default.

src/features/dotnetTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export default class TestManager extends AbstractProvider {
393393
environmentVariables: Map<string, string>,
394394
debuggerEventsPipeName: string
395395
) {
396-
const debugOptions = vscode.workspace.getConfiguration('csharp').get('unitTestDebuggingOptions');
396+
const debugOptions = this.optionProvider.GetLatestOptions().commonOptions.unitTestDebuggingOptions;
397397

398398
// Get the initial set of options from the workspace setting
399399
let result: any;

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,7 @@ export class RoslynLanguageServer {
577577
client.onRequest<RoslynProtocol.DebugAttachParams, RoslynProtocol.DebugAttachResult, void>(
578578
RoslynProtocol.DebugAttachRequest.type,
579579
async (request) => {
580-
let debugOptions: any = vscode.workspace.getConfiguration('csharp').get('unitTestDebuggingOptions');
581-
if (typeof debugOptions !== 'object') {
582-
debugOptions = {};
583-
}
584-
580+
const debugOptions = this.optionProvider.GetLatestOptions().commonOptions.unitTestDebuggingOptions;
585581
const debugConfiguration: vscode.DebugConfiguration = {
586582
...debugOptions,
587583
name: '.NET Core Attach',

src/shared/migrateOptions.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { types } from 'util';
67
import { ConfigurationTarget, vscode, WorkspaceConfiguration } from '../vscodeAdapter';
78

89
// Option in the array should be identical to each other, except the name.
@@ -65,6 +66,10 @@ export const migrateOptions = [
6566
omnisharpOption: 'csharp.testsCodeLens.enabled',
6667
roslynOption: 'dotnet.codeLens.enableTestsCodeLens',
6768
},
69+
{
70+
omnisharpOption: 'csharp.unitTestDebuggingOptions',
71+
roslynOption: 'dotnet.unitTestDebuggingOptions',
72+
},
6873
];
6974

7075
export async function MigrateOptions(vscode: vscode): Promise<void> {
@@ -84,12 +89,25 @@ export async function MigrateOptions(vscode: vscode): Promise<void> {
8489
continue;
8590
}
8691

87-
if (roslynOptionValue == inspectionValueOfRoslynOption.defaultValue) {
92+
if (shouldMove(roslynOptionValue, inspectionValueOfRoslynOption.defaultValue)) {
8893
await MoveOptionsValue(omnisharpOption, roslynOption, configuration);
8994
}
9095
}
9196
}
9297

98+
function shouldMove(roslynOptionValue: unknown, defaultInspectValueOfRoslynOption: unknown): boolean {
99+
if (roslynOptionValue == defaultInspectValueOfRoslynOption) {
100+
return true;
101+
}
102+
103+
// For certain kinds of complex object options, vscode will return a proxy object which isn't comparable to the default empty object {}.
104+
if (types.isProxy(roslynOptionValue)) {
105+
return JSON.stringify(roslynOptionValue) === JSON.stringify(defaultInspectValueOfRoslynOption);
106+
}
107+
108+
return false;
109+
}
110+
93111
async function MoveOptionsValue(
94112
fromOption: string,
95113
toOption: string,

src/shared/options.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ export class Options {
9292
}
9393
}
9494

95+
const unitTestDebuggingOptions = Options.readOption<object>(
96+
config,
97+
'dotnet.unitTestDebuggingOptions',
98+
{},
99+
'csharp.unitTestDebuggingOptions'
100+
);
101+
95102
// Omnisharp Server Options
96103

97104
const monoPath = Options.readOption<string>(config, 'omnisharp.monoPath', '');
@@ -305,6 +312,7 @@ export class Options {
305312
useOmnisharpServer: useOmnisharpServer,
306313
excludePaths: excludePaths,
307314
defaultSolution: defaultSolution,
315+
unitTestDebuggingOptions: unitTestDebuggingOptions,
308316
},
309317
{
310318
useModernNet: useModernNet,
@@ -437,6 +445,7 @@ export interface CommonOptions {
437445

438446
/** The default solution; this has been normalized to a full file path from the workspace folder it was configured in, or the string "disable" if that has been disabled */
439447
defaultSolution: string;
448+
unitTestDebuggingOptions: object;
440449
}
441450

442451
const CommonOptionsThatTriggerReload: ReadonlyArray<keyof CommonOptions> = [

src/tools/generateOptionsSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export function GenerateOptionsSchema() {
183183
'For debug extension development only: if a port is specified VS Code tries to connect to a debug adapter running in server mode',
184184
default: 4711,
185185
};
186-
packageJSON.contributes.configuration[0].properties['csharp.unitTestDebuggingOptions'].properties =
186+
packageJSON.contributes.configuration[1].properties['dotnet.unitTestDebuggingOptions'].properties =
187187
unitTestDebuggingOptions;
188188

189189
// Delete old debug options

test/unitTests/fakes/fakeOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function getEmptyOptions(): Options {
1414
useOmnisharpServer: true,
1515
excludePaths: [],
1616
defaultSolution: '',
17+
unitTestDebuggingOptions: {},
1718
},
1819
{
1920
useModernNet: false,

0 commit comments

Comments
 (0)