Skip to content

Commit bf8aa4c

Browse files
committed
Merge remote-tracking branch 'origin/remove_vscode_disposable' into remove_vscode_disposable
2 parents b16712b + c587ffe commit bf8aa4c

File tree

4 files changed

+20
-28
lines changed

4 files changed

+20
-28
lines changed

src/features/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function registerCommands(server: OmniSharpServer, eventStream: E
4646
let d7 = vscode.commands.registerCommand('dotnet.generateAssets', async () => generateAssets(server));
4747

4848
// Register command for remote process picker for attach
49-
let d8 = vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args));
49+
let d8 = vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args, platformInfo));
5050

5151
// Register command for adapter executable command.
5252
let d9 = vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream));

src/features/processPicker.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class RemoteAttachPicker {
191191
return args.map(arg => this.quoteArg(arg)).join(" ");
192192
}
193193

194-
public static async ShowAttachEntries(args: any): Promise<string> {
194+
public static async ShowAttachEntries(args: any, platformInfo: PlatformInformation): Promise<string> {
195195
// Create remote attach output channel for errors.
196196
if (!RemoteAttachPicker._channel) {
197197
RemoteAttachPicker._channel = vscode.window.createOutputChannel('remote-attach');
@@ -216,7 +216,7 @@ export class RemoteAttachPicker {
216216
let pipeTransport = this.getPipeTransportOptions(args.pipeTransport, os.platform());
217217

218218
return RemoteAttachPicker.createPipeCmd(pipeTransport.pipeProgram, pipeTransport.pipeArgs, pipeTransport.quoteArgs)
219-
.then(async pipeCmd => RemoteAttachPicker.getRemoteOSAndProcesses(pipeCmd))
219+
.then(async pipeCmd => RemoteAttachPicker.getRemoteOSAndProcesses(pipeCmd, platformInfo))
220220
.then(processes => {
221221
let attachPickOptions: vscode.QuickPickOptions = {
222222
matchOnDescription: true,
@@ -229,10 +229,10 @@ export class RemoteAttachPicker {
229229
}
230230
}
231231

232-
public static async getRemoteOSAndProcesses(pipeCmd: string): Promise<AttachItem[]> {
232+
public static async getRemoteOSAndProcesses(pipeCmd: string, platformInfo: PlatformInformation): Promise<AttachItem[]> {
233233
const scriptPath = path.join(getExtensionPath(), 'scripts', 'remoteProcessPickerScript');
234234

235-
return execChildProcessAndOutputErrorToChannel(`${pipeCmd} < ${scriptPath}`, null, RemoteAttachPicker._channel).then(output => {
235+
return execChildProcessAndOutputErrorToChannel(`${pipeCmd} < ${scriptPath}`, null, RemoteAttachPicker._channel, platformInfo).then(output => {
236236
// OS will be on first line
237237
// Processess will follow if listed
238238
let lines = output.split(/\r?\n/);
@@ -504,23 +504,21 @@ async function execChildProcess(process: string, workingDirectory: string): Prom
504504
// VSCode cannot find the path "c:\windows\system32\bash.exe" as bash.exe is only available on 64bit OS.
505505
// It can be invoked from "c:\windows\sysnative\bash.exe", so adding "c:\windows\sysnative" to path if we identify
506506
// VSCode is running in windows and doesn't have it in the path.
507-
async function GetSysNativePathIfNeeded(): Promise<NodeJS.ProcessEnv> {
508-
return PlatformInformation.GetCurrent().then(platformInfo => {
509-
let env = process.env;
510-
if (platformInfo.isWindows() && platformInfo.architecture === "x86_64") {
511-
let sysnative: String = process.env.WINDIR + "\\sysnative";
512-
env.Path = process.env.PATH + ";" + sysnative;
513-
}
507+
async function GetSysNativePathIfNeeded(platformInfo: PlatformInformation): Promise<NodeJS.ProcessEnv> {
508+
let env = process.env;
509+
if (platformInfo.isWindows() && platformInfo.architecture === "x86_64") {
510+
let sysnative: String = process.env.WINDIR + "\\sysnative";
511+
env.Path = process.env.PATH + ";" + sysnative;
512+
}
514513

515-
return env;
516-
});
514+
return env;
517515
}
518516

519-
async function execChildProcessAndOutputErrorToChannel(process: string, workingDirectory: string, channel: vscode.OutputChannel): Promise<string> {
517+
async function execChildProcessAndOutputErrorToChannel(process: string, workingDirectory: string, channel: vscode.OutputChannel, platformInfo: PlatformInformation): Promise<string> {
520518
channel.appendLine(`Executing: ${process}`);
521519

522520
return new Promise<string>(async (resolve, reject) => {
523-
return GetSysNativePathIfNeeded().then(newEnv => {
521+
return GetSysNativePathIfNeeded(platformInfo).then(newEnv => {
524522
child_process.exec(process, { cwd: workingDirectory, env: newEnv, maxBuffer: 500 * 1024 }, (error: Error, stdout: string, stderr: string) => {
525523
let channelOutput = "";
526524

src/omnisharp/launcher.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ export interface LaunchResult {
204204
monoVersion?: string;
205205
}
206206

207-
export async function launchOmniSharp(cwd: string, args: string[], launchInfo: LaunchInfo): Promise<LaunchResult> {
207+
export async function launchOmniSharp(cwd: string, args: string[], launchInfo: LaunchInfo, platformInfo: PlatformInformation): Promise<LaunchResult> {
208208
return new Promise<LaunchResult>((resolve, reject) => {
209-
launch(cwd, args, launchInfo)
209+
launch(cwd, args, launchInfo, platformInfo)
210210
.then(result => {
211211
// async error - when target not not ENEOT
212212
result.process.on('error', err => {
@@ -222,8 +222,7 @@ export async function launchOmniSharp(cwd: string, args: string[], launchInfo: L
222222
});
223223
}
224224

225-
async function launch(cwd: string, args: string[], launchInfo: LaunchInfo): Promise<LaunchResult> {
226-
const platformInfo = await PlatformInformation.GetCurrent();
225+
async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platformInfo: PlatformInformation): Promise<LaunchResult> {
227226
const options = Options.Read();
228227

229228
if (options.useEditorFormattingSettings) {
@@ -323,7 +322,7 @@ function launchNixMono(launchPath: string, monoVersion: string, cwd: string, arg
323322
return {
324323
process,
325324
command: launchPath,
326-
monoVersion,
325+
monoVersion,
327326
};
328327
}
329328

src/omnisharp/server.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,15 @@ export class OmniSharpServer {
8888
private _options: Options;
8989

9090
private _omnisharpManager: OmnisharpManager;
91-
private eventStream: EventStream;
9291
private updateProjectDebouncer = new Subject<ObservableEvents.ProjectModified>();
9392
private firstUpdateProject: boolean;
94-
private vscode: vscode;
9593

96-
constructor(vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, eventStream: EventStream, packageJSON: any, platformInfo: PlatformInformation) {
97-
this.eventStream = eventStream;
98-
this.vscode = vscode;
94+
constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, packageJSON: any, private platformInfo: PlatformInformation) {
9995
this._requestQueue = new RequestQueueCollection(this.eventStream, 8, request => this._makeRequest(request));
10096
let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, packageJSON, platformInfo);
10197
this._omnisharpManager = new OmnisharpManager(downloader, platformInfo);
10298
this.updateProjectDebouncer.debounceTime(1500).subscribe((event) => { this.updateProjectInfo(); });
10399
this.firstUpdateProject = true;
104-
105100
}
106101

107102
public isRunning(): boolean {
@@ -326,7 +321,7 @@ export class OmniSharpServer {
326321
this._fireEvent(Events.BeforeServerStart, solutionPath);
327322

328323
try {
329-
let launchResult = await launchOmniSharp(cwd, args, launchInfo);
324+
let launchResult = await launchOmniSharp(cwd, args, launchInfo, this.platformInfo);
330325
this.eventStream.post(new ObservableEvents.OmnisharpLaunch(launchResult.monoVersion, launchResult.command, launchResult.process.pid));
331326

332327
this._serverProcess = launchResult.process;

0 commit comments

Comments
 (0)