MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / preReleaseCheck

Function preReleaseCheck

Extension/src/LanguageServer/extension.ts:1496–1537  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1494}
1495
1496export async function preReleaseCheck(): Promise<void> {
1497 const displayedPreReleasePrompt: PersistentState<boolean> = new PersistentState<boolean>("CPP.displayedPreReleasePrompt", false);
1498 const isOnPreRelease: PersistentState<boolean> = new PersistentState<boolean>("CPP.isOnPreRelease", false);
1499
1500 if (util.getCppToolsTargetPopulation() === TargetPopulation.Insiders) {
1501 isOnPreRelease.Value = true;
1502 return;
1503 }
1504
1505 // First we need to make sure the user isn't already on a pre-release version and hasn't dismissed this prompt before.
1506 if (!isOnPreRelease.Value && !displayedPreReleasePrompt.Value && util.getCppToolsTargetPopulation() === TargetPopulation.Public) {
1507 // Get the info on the latest version from the marketplace to check if there is a pre-release version available.
1508 const response = await fetch('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', {
1509 method: 'POST',
1510 headers: {
1511 Accept: 'application/json; api-version=3.0-preview',
1512 'Content-Type': 'application/json',
1513 'User-Agent': 'vscode-cpptools'
1514 },
1515 body: '{"filters": [{"criteria": [{"filterType": 7, "value": "ms-vscode.cpptools"}]}], "flags": 529}'
1516 }).catch(logAndReturn.undefined);
1517
1518 telemetry.logLanguageServerEvent("marketplaceFetch", undefined, { status: response?.status ?? 0 });
1519
1520 const data: any = await response?.json().catch(logAndReturn.undefined);
1521
1522 const preReleaseAvailable = data?.results?.[0]?.extensions?.[0]?.versions?.[0]?.properties?.some((e: object) => Object.values(e).includes("Microsoft.VisualStudio.Code.PreRelease"));
1523
1524 // If the user isn't on the pre-release version, but one is available, prompt them to install it.
1525 if (preReleaseAvailable) {
1526 displayedPreReleasePrompt.Value = true;
1527 const message: string = localize("prerelease.message", "A pre-release version of the C/C++ extension is available. Would you like to switch to it?");
1528 const yes: string = localize("yes.button", "Yes");
1529 const no: string = localize("no.button", "No");
1530 void vscode.window.showInformationMessage(message, yes, no).then((selection) => {
1531 if (selection === yes) {
1532 void vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true }).then(undefined, logAndReturn.undefined);
1533 }
1534 });
1535 }
1536 }
1537}
1538
1539// This uses several workarounds for interacting with the hover feature.
1540// A proposal for dynamic hover content would help, such as the one here (https://github.com/microsoft/vscode/issues/195394)

Callers

nothing calls this directly

Calls 4

valuesMethod · 0.80
catchMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected