From 2138920a09cb76d57e8bb5c40465dbf491fcb273 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Tue, 11 Jul 2023 11:50:22 -0700 Subject: [PATCH] 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. --- src/csharpExtensionExports.ts | 1 + src/main.ts | 2 ++ .../blazorDebugConfigurationProvider.ts | 14 +++++++------- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/csharpExtensionExports.ts b/src/csharpExtensionExports.ts index 9a6ce0a74..1d4b879e5 100644 --- a/src/csharpExtensionExports.ts +++ b/src/csharpExtensionExports.ts @@ -20,4 +20,5 @@ export interface CSharpExtensionExports { initializationFinished: () => Promise; logDirectory: string; profferBrokeredServices: (container: GlobalBrokeredServiceContainer) => void; + determineBrowserType: () => Promise; } diff --git a/src/main.ts b/src/main.ts index 5248d50b7..dab3185b1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -51,6 +51,7 @@ import Descriptors from './lsptoolshost/services/descriptors'; import { GlobalBrokeredServiceContainer } from '@microsoft/servicehub-framework'; import { CSharpExtensionExports, OmnisharpExtensionExports } from './csharpExtensionExports'; import { csharpDevkitExtensionId, getCSharpDevKit } from './utils/getCSharpDevKit'; +import { BlazorDebugConfigurationProvider } from './razor/src/blazorDebug/blazorDebugConfigurationProvider'; export async function activate( context: vscode.ExtensionContext @@ -288,6 +289,7 @@ export async function activate( }, profferBrokeredServices: (container) => profferBrokeredServices(context, container), logDirectory: context.logUri.fsPath, + determineBrowserType: BlazorDebugConfigurationProvider.determineBrowserType, }; } else { return { diff --git a/src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts b/src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts index 528ed5a51..16144aef1 100644 --- a/src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts +++ b/src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts @@ -15,9 +15,9 @@ import showInformationMessage from '../../../shared/observers/utils/showInformat import showErrorMessage from '../../../observers/utils/showErrorMessage'; export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurationProvider { - private readonly autoDetectUserNotice = `Run and Debug: auto-detection found {0} for a launch browser`; - private readonly edgeBrowserType = 'msedge'; - private readonly chromeBrowserType = 'chrome'; + private static readonly autoDetectUserNotice = `Run and Debug: auto-detection found {0} for a launch browser`; + private static readonly edgeBrowserType = 'msedge'; + private static readonly chromeBrowserType = 'chrome'; constructor(private readonly logger: RazorLogger, private readonly vscodeType: typeof vscode) {} @@ -125,10 +125,10 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati const configBrowser = configuration.browser; const browserType = configBrowser === 'edge' - ? this.edgeBrowserType + ? BlazorDebugConfigurationProvider.edgeBrowserType : configBrowser === 'chrome' - ? this.chromeBrowserType - : await this.determineBrowserType(); + ? BlazorDebugConfigurationProvider.chromeBrowserType + : await BlazorDebugConfigurationProvider.determineBrowserType(); if (!browserType) { return; } @@ -172,7 +172,7 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati } } - private async determineBrowserType() { + public static async determineBrowserType() { // There was no browser specified by the user, so we will do some auto-detection to find a browser, // favoring chrome if multiple valid options are installed. const chromeBrowserFinder = new ChromeBrowserFinder(process.env, promises, null);