Skip to content

Quick Attempt To Preemptively Load Cache #2284

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
15 changes: 14 additions & 1 deletion vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
* This accounts for pmc installs, snap installs, bash configurations, and other non-standard installations such as homebrew.
*/
const dotnetFindPathRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.findPath}`, async (commandContext: IDotnetFindPathContext): Promise<IDotnetAcquireResult | undefined> =>
{
return findPath(commandContext);
});

async function findPath(commandContext: IDotnetFindPathContext): Promise<IDotnetAcquireResult | undefined>
{
globalEventStream.post(new DotnetFindPathCommandInvoked(`The find path command was invoked.`, commandContext));

Expand Down Expand Up @@ -590,7 +595,7 @@ onHostfxrRecord : ${JSON.stringify(dotnetOnHostfxrRecord)}
Requirement:
${JSON.stringify(commandContext)}`));
return undefined;
});
}

async function getPathIfValid(path: string | undefined, validator: IDotnetConditionValidator, commandContext: IDotnetFindPathContext): Promise<string | undefined>
{
Expand Down Expand Up @@ -845,6 +850,14 @@ We will try to install .NET, but are unlikely to be able to connect to the serve
return null;
}

// Preemptively load the cacheable information for other extensions to try to increase performance.
const commonCaseCallingContext = { version: '9.0', mode: 'aspnetcore', requestingExtensionId: 'self', installType: 'local', architecture: os.platform() } as IDotnetAcquireContext;
callWithErrorHandling(async () =>
{
await findPath({ acquireContext: commonCaseCallingContext, versionSpecRequirement: 'latestPatch', rejectPreviews: true });
}, getIssueContext(existingPathConfigWorker)(AcquireErrorConfiguration.DisableErrorPopups, 'initialization-find', commonCaseCallingContext.version), commonCaseCallingContext.requestingExtensionId)
.catch(() => {});

// Preemptively install .NET for extensions who tell us to in their package.json
const jsonInstaller = new JsonInstaller(globalEventStream, vsCodeExtensionContext);

Expand Down