Skip to content

Commit

Permalink
Merge pull request #4964 from 50Wliu/remove-blazor-debug-preview-checks
Browse files Browse the repository at this point in the history
Remove obsolete settings checks for Blazor debugging
  • Loading branch information
JoeRobich authored Dec 19, 2021
2 parents 83618ae + 5c3236c commit 5366059
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 68 deletions.
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,6 @@
"scope": "window",
"default": true,
"description": "Enable/disable default Razor formatter."
},
"razor.disableBlazorDebugPrompt": {
"type": "boolean",
"default": false,
"description": "Disable Blazor WebAssembly's debug requirements notification."
}
}
},
Expand Down Expand Up @@ -4010,4 +4005,4 @@
}
]
}
}
}
71 changes: 9 additions & 62 deletions src/omnisharp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ export async function requestWorkspaceInformation(server: OmniSharpServer) {
blazorWebAssemblyProjectFound = blazorWebAssemblyProjectFound || isProjectBlazorWebAssemblyProject;
}

if (blazorWebAssemblyProjectFound && !hasBlazorWebAssemblyDebugPrerequisites(server)) {
const configuration = vscode.workspace.getConfiguration('razor');
// There's a Blazor Web Assembly project but VSCode isn't configured to debug the WASM code, show a notification
// to help the user configure their VSCode appropriately.
showBlazorConfigurationRequiredPrompt(server, configuration);
if (blazorWebAssemblyProjectFound && !vscode.extensions.getExtension('ms-dotnettools.blazorwasm-companion')) {
// No need to await this call, we don't depend on the prompt being shown.
showBlazorDebuggingExtensionPrompt(server);
}
}

Expand Down Expand Up @@ -243,35 +241,6 @@ async function isBlazorWebAssemblyProject(project: MSBuildProject): Promise<bool
return false;
}

function hasBlazorWebAssemblyDebugPrerequisites(server: OmniSharpServer) {
const companionExtension = vscode.extensions.getExtension('ms-dotnettools.blazorwasm-companion');
if (!companionExtension) {
showBlazorDebuggingExtensionPrompt(server);
return false;
}

const debugJavaScriptConfigSection = vscode.workspace.getConfiguration('debug.javascript');
const usePreviewValue = debugJavaScriptConfigSection.get('usePreview');
if (usePreviewValue) {
// If usePreview is truthy it takes priority over the useV3 variants.
return true;
}

const debugNodeConfigSection = vscode.workspace.getConfiguration('debug.node');
const useV3NodeValue = debugNodeConfigSection.get('useV3');
if (!useV3NodeValue) {
return false;
}

const debugChromeConfigSection = vscode.workspace.getConfiguration('debug.chrome');
const useV3ChromeValue = debugChromeConfigSection.get('useV3');
if (!useV3ChromeValue) {
return false;
}

return true;
}

function isWebProject(project: MSBuildProject): boolean {
let projectFileText = fs.readFileSync(project.Path, 'utf8');

Expand All @@ -280,38 +249,16 @@ function isWebProject(project: MSBuildProject): boolean {
return projectFileText.toLowerCase().indexOf('sdk="microsoft.net.sdk.web"') >= 0;
}

function showBlazorConfigurationRequiredPrompt(server: OmniSharpServer, configuration: vscode.WorkspaceConfiguration) {
const disableBlazorDebugPrompt = configuration.get('disableBlazorDebugPrompt');

const promptShownKey = 'blazor_configuration_required_prompt_shown';
if (!disableBlazorDebugPrompt && !server.sessionProperties[promptShownKey]) {
server.sessionProperties[promptShownKey] = true;

vscode.window.showInformationMessage('Additional setup is required to debug Blazor WebAssembly applications.', 'Don\'t Ask Again', 'Learn more', 'Close')
.then(async result => {
if (result === 'Learn more') {
const uriToOpen = vscode.Uri.parse('https://aka.ms/blazordebugging#vscode');
await vscode.commands.executeCommand('vscode.open', uriToOpen);
}
if (result === 'Don\'t Ask Again') {
await configuration.update('disableBlazorDebugPrompt', true);
}
});
}
}

function showBlazorDebuggingExtensionPrompt(server: OmniSharpServer) {
async function showBlazorDebuggingExtensionPrompt(server: OmniSharpServer) {
const promptShownKey = 'blazor_debugging_extension_prompt_shown';
if (!server.sessionProperties[promptShownKey]) {
server.sessionProperties[promptShownKey] = true;

const msg = 'The Blazor WASM Debugging Extension is required to debug Blazor WASM apps in VS Code.';
vscode.window.showInformationMessage(msg, 'Install Extension', 'Close')
.then(async result => {
if (result === 'Install Extension') {
const uriToOpen = vscode.Uri.parse('vscode:extension/ms-dotnettools.blazorwasm-companion');
await vscode.commands.executeCommand('vscode.open', uriToOpen);
}
});
const result = await vscode.window.showInformationMessage(msg, 'Install Extension', 'Close');
if (result === 'Install Extension') {
const uriToOpen = vscode.Uri.parse('vscode:extension/ms-dotnettools.blazorwasm-companion');
await vscode.commands.executeCommand('vscode.open', uriToOpen);
}
}
}

0 comments on commit 5366059

Please sign in to comment.