Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete settings checks for Blazor debugging #4964

Merged
merged 2 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}