Skip to content

Commit 2138920

Browse files
authored
Add determineBrowserType to CSharpExtensionExports (#5911)
This PR exports the BlazorDebugConfigurationProvider.determineBrowserType method that it could be used in vscode-dotnettools to help determine the browser the user wants to use.
1 parent 0b2bf6d commit 2138920

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/csharpExtensionExports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export interface CSharpExtensionExports {
2020
initializationFinished: () => Promise<void>;
2121
logDirectory: string;
2222
profferBrokeredServices: (container: GlobalBrokeredServiceContainer) => void;
23+
determineBrowserType: () => Promise<string | undefined>;
2324
}

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import Descriptors from './lsptoolshost/services/descriptors';
5151
import { GlobalBrokeredServiceContainer } from '@microsoft/servicehub-framework';
5252
import { CSharpExtensionExports, OmnisharpExtensionExports } from './csharpExtensionExports';
5353
import { csharpDevkitExtensionId, getCSharpDevKit } from './utils/getCSharpDevKit';
54+
import { BlazorDebugConfigurationProvider } from './razor/src/blazorDebug/blazorDebugConfigurationProvider';
5455

5556
export async function activate(
5657
context: vscode.ExtensionContext
@@ -288,6 +289,7 @@ export async function activate(
288289
},
289290
profferBrokeredServices: (container) => profferBrokeredServices(context, container),
290291
logDirectory: context.logUri.fsPath,
292+
determineBrowserType: BlazorDebugConfigurationProvider.determineBrowserType,
291293
};
292294
} else {
293295
return {

src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import showInformationMessage from '../../../shared/observers/utils/showInformat
1515
import showErrorMessage from '../../../observers/utils/showErrorMessage';
1616

1717
export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
18-
private readonly autoDetectUserNotice = `Run and Debug: auto-detection found {0} for a launch browser`;
19-
private readonly edgeBrowserType = 'msedge';
20-
private readonly chromeBrowserType = 'chrome';
18+
private static readonly autoDetectUserNotice = `Run and Debug: auto-detection found {0} for a launch browser`;
19+
private static readonly edgeBrowserType = 'msedge';
20+
private static readonly chromeBrowserType = 'chrome';
2121

2222
constructor(private readonly logger: RazorLogger, private readonly vscodeType: typeof vscode) {}
2323

@@ -125,10 +125,10 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
125125
const configBrowser = configuration.browser;
126126
const browserType =
127127
configBrowser === 'edge'
128-
? this.edgeBrowserType
128+
? BlazorDebugConfigurationProvider.edgeBrowserType
129129
: configBrowser === 'chrome'
130-
? this.chromeBrowserType
131-
: await this.determineBrowserType();
130+
? BlazorDebugConfigurationProvider.chromeBrowserType
131+
: await BlazorDebugConfigurationProvider.determineBrowserType();
132132
if (!browserType) {
133133
return;
134134
}
@@ -172,7 +172,7 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
172172
}
173173
}
174174

175-
private async determineBrowserType() {
175+
public static async determineBrowserType() {
176176
// There was no browser specified by the user, so we will do some auto-detection to find a browser,
177177
// favoring chrome if multiple valid options are installed.
178178
const chromeBrowserFinder = new ChromeBrowserFinder(process.env, promises, null);

0 commit comments

Comments
 (0)