Skip to content

Commit

Permalink
Merge pull request dotnet#791 from nagilson/nagilson-list-sdks
Browse files Browse the repository at this point in the history
Add API Surface to get newest available runtimes + SDKs
  • Loading branch information
nagilson authored Jun 7, 2023
2 parents c2b449d + 5d917d4 commit efcba6b
Show file tree
Hide file tree
Showing 18 changed files with 414 additions and 148 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ project.lock.json
*.ncrunchsolution
*.*sdf
*.ipch
*.js
*.d.ts
*.js.map
.build/
.vs/
launchSettings.json
Expand Down
16 changes: 11 additions & 5 deletions Documentation/contributing-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ You can contribute to .NET Core with issues and PRs. Simply filing issues for pr

We use and recommend the following workflow:

1. Create an issue for your work.
1. Create an issue for your work.
- You can skip this step for trivial changes.
- Reuse an existing issue on the topic, if there is one.
- Use [CODE_OWNERS.TXT](../CODE_OWNERS.txt) to find relevant maintainers and @ mention them to ask for feedback on your issue.
- Get agreement from the team and the community that your proposed change is a good one.
- If your change adds a new API, follow the [API Review Process](https://github.com/dotnet/corefx/blob/main/Documentation/project-docs/api-review-process.md) (but replace CoreFX with this repo).
- If your change adds a new API, follow the [API Review Process](https://github.com/dotnet/corefx/blob/main/Documentation/project-docs/api-review-process.md) (but replace CoreFX with this repo).
- Clearly state that you are going to take on implementing it, if that's the case. You can request that the issue be assigned to you. Note: The issue filer and the implementer don't have to be the same person.
2. Create a personal fork of the repository on GitHub (if you don't already have one).
3. Create a branch off of main (`git checkout -b mybranch`).
- Name the branch so that it clearly communicates your intentions, such as issue-123 or githubhandle-issue.
3. Create a branch off of main (`git checkout -b mybranch`).
- Name the branch so that it clearly communicates your intentions, such as issue-123 or githubhandle-issue.
- Branches are useful since they isolate your changes from incoming changes from upstream. They also enable you to create multiple PRs from the same fork.
4. Make and commit your changes.
- Please follow our [Commit Messages](contributing.md#commit-messages) guidance.
5. Add new tests corresponding to your change, if applicable.
If you are having difficulty debugging changes, note that you can add breakpoints into the tests for the library, runtime, or SDK by opening their corresponding workspace folder and launching the debug tab for their tests in VS Code. If you want to breakpoint the code, you'll need to breakpoint the test in typescript, but then every reload add breakpoints to the JS code generated from the typescript code if you want to debug code outside of the tests thesmelves that the tests run.
6. Build the repository with your changes.
- Make sure that the builds are clean.
- Make sure that the tests are all passing, including your new tests.
Expand All @@ -37,6 +38,11 @@ Note: It is OK to create your PR as "[WIP]" on the upstream repo before the impl

Before making a pull request, be sure to build and test your changes locally with the build script ([windows](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/build.cmd), [mac](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/build.sh)) and test script ([windows](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/test.cmd), [mac](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/test.sh)). To lint your changes, run the test script with the parameter `--tslint`

You can also test only a specific set of tests using the following parameters with the test script:
Test SDK Extension Only: `test sdk` (Tests the SDK extension only.)
Test SDK Extension Only: `test rnt` (Tests the runtime extension only.)
Test SDK Extension Only: `test lib` (Tests the library only.)

## Building a .VSIX

To build an installable .vsix file locally, navigate to the directory containing the extension's package.json (either `vscode-dotnet-runtime-extension` or `vscode-dotnet-sdk-extension`) run the following commands:
Expand All @@ -54,7 +60,7 @@ If the CI build fails for any reason, the PR issue will be updated with a link t

## PR Feedback

Microsoft team and community members will provide feedback on your change. Community feedback is highly valued. You will often see the absence of team feedback if the community has already provided good review feedback.
Microsoft team and community members will provide feedback on your change. Community feedback is highly valued. You will often see the absence of team feedback if the community has already provided good review feedback.

1 or more Microsoft team members will review every PR prior to merge. They will often reply with "LGTM, modulo comments". That means that the PR will be merged once the feedback is resolved. "LGTM" == "looks good to me".

Expand Down
22 changes: 10 additions & 12 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
"capabilities": {
"virtualWorkspaces": true
},
"activationEvents": [
"onCommand:sample.helloworld",
"onCommand:sample.dotnet.acquire",
"onCommand:sample.dotnet.acquireStatus",
"onCommand:sample.dotnet.uninstallAll",
"onCommand:sample.dotnet.concurrentTest",
"onCommand:sample.dotnet.showAcquisitionLog",
"onCommand:sample.dotnet-sdk.acquire",
"onCommand:sample.dotnet-sdk.acquireStatus",
"onCommand:sample.dotnet-sdk.uninstallAll",
"onCommand:sample.dotnet-sdk.showAcquisitionLog"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
Expand Down Expand Up @@ -82,6 +70,16 @@
"command": "sample.dotnet-sdk.showAcquisitionLog",
"title": "Show .NET SDK acquisition log",
"category": "Sample"
},
{
"command": "sample.dotnet-sdk.listVersions",
"title": "Using the SDK Extension, list the newest versions of the .NET SDK or .NET Runtime.",
"category": "Sample"
},
{
"command": "sample.dotnet-sdk.recommendedVersion",
"title": "Show the recommended version of the SDK to install.",
"category": "Sample"
}
]
},
Expand Down
45 changes: 43 additions & 2 deletions sample/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import * as cp from 'child_process';
import * as path from 'path';
import * as vscode from 'vscode';
import { IDotnetAcquireResult } from 'vscode-dotnet-runtime-library';
import {
IDotnetAcquireResult,
IDotnetListVersionsResult,
IDotnetVersion
} from 'vscode-dotnet-runtime-library';
import * as runtimeExtension from 'vscode-dotnet-runtime';
import * as sdkExtension from 'vscode-dotnet-sdk';

Expand Down Expand Up @@ -34,6 +38,7 @@ export function activate(context: vscode.ExtensionContext) {
runtimeExtension.activate(context);
sdkExtension.activate(context);


// --------------------------------------------------------------------------

// -------------------runtime extension registrations------------------------
Expand Down Expand Up @@ -90,6 +95,7 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleAcquireStatusRegistration = vscode.commands.registerCommand('sample.dotnet.acquireStatus', async (version) => {
if (!version) {
version = await vscode.window.showInputBox({
Expand All @@ -107,6 +113,7 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleDotnetUninstallAllRegistration = vscode.commands.registerCommand('sample.dotnet.uninstallAll', async () => {
try {
await vscode.commands.executeCommand('dotnet.uninstallAll');
Expand All @@ -115,6 +122,7 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleConcurrentTest = vscode.commands.registerCommand('sample.dotnet.concurrentTest', async () => {
try {
vscode.commands.executeCommand('dotnet.showAcquisitionLog');
Expand All @@ -131,6 +139,7 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet.showAcquisitionLog', async () => {
try {
await vscode.commands.executeCommand('dotnet.showAcquisitionLog');
Expand All @@ -145,7 +154,8 @@ ${stderr}`);
sampleAcquireStatusRegistration,
sampleDotnetUninstallAllRegistration,
sampleConcurrentTest,
sampleShowAcquisitionLogRegistration);
sampleShowAcquisitionLogRegistration,
);

// --------------------------------------------------------------------------

Expand All @@ -167,6 +177,7 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleSDKAcquireStatusRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.acquireStatus', async (version) => {
if (!version) {
version = await vscode.window.showInputBox({
Expand All @@ -184,6 +195,33 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleSDKlistVersions = vscode.commands.registerCommand('sample.dotnet-sdk.listVersions', async (getRuntimes : boolean) => {
if (!getRuntimes) {
getRuntimes = JSON.parse(await vscode.window.showInputBox({
placeHolder: 'false',
value: 'false',
prompt: 'Acquire Runtimes? Use `true` if so, else, give `false`.',
}) ?? 'false');
}

try {
const result : IDotnetListVersionsResult | undefined = await vscode.commands.executeCommand('dotnet-sdk.listVersions', { listRuntimes: getRuntimes });
vscode.window.showInformationMessage(`Available ${getRuntimes == false ? 'SDKS' : 'Runtimes'}: ${result?.map(x => x.version).join(", ")}`);
} catch (error) {
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleSDKrecommendedVersion = vscode.commands.registerCommand('sample.dotnet-sdk.recommendedVersion', async (getRuntimes : boolean) => {
try {
const result : IDotnetVersion | undefined = await vscode.commands.executeCommand('dotnet-sdk.recommendedVersion', { listRuntimes: getRuntimes });
vscode.window.showInformationMessage(`Recommended SDK Version to Install: ${result?.version}`);
} catch (error) {
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleSDKDotnetUninstallAllRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.uninstallAll', async () => {
try {
await vscode.commands.executeCommand('dotnet-sdk.uninstallAll');
Expand All @@ -192,6 +230,7 @@ ${stderr}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});

const sampleSDKShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.showAcquisitionLog', async () => {
try {
await vscode.commands.executeCommand('dotnet-sdk.showAcquisitionLog');
Expand All @@ -203,6 +242,8 @@ ${stderr}`);
context.subscriptions.push(
sampleSDKAcquireRegistration,
sampleSDKAcquireStatusRegistration,
sampleSDKlistVersions,
sampleSDKrecommendedVersion,
sampleSDKDotnetUninstallAllRegistration,
sampleSDKShowAcquisitionLogRegistration);
}
92 changes: 49 additions & 43 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,70 @@ if ($args[1] -eq '--tslint') {
Write-Host "`nTSLint Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
else
{
Write-Host "`nTSLint Succeeded.`n" -ForegroundColor $successColor
}
}

pushd vscode-dotnet-runtime-library
if (Test-Path node_modules) { rm -r -force node_modules }
npm ci --silent
npm run test
if ($LASTEXITCODE -ne 0)
{
Write-Host "`nAcquisition Library Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`nAcquisition Library Tests Succeeded.`n" -ForegroundColor $successColor
if ($args[1] -ne 'sdk' -and $args[1] -ne 'rnt') {
pushd vscode-dotnet-runtime-library
if (Test-Path node_modules) { rm -r -force node_modules }
npm ci --silent
npm run test
if ($LASTEXITCODE -ne 0)
{
Write-Host "`nAcquisition Library Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`nAcquisition Library Tests Succeeded.`n" -ForegroundColor $successColor
}
popd
}
popd

pushd vscode-dotnet-runtime-extension
if (Test-Path node_modules) { rm -r -force node_modules }
npm ci --silent
npm run test
if ($LASTEXITCODE -ne 0)
{
Write-Host "`n.NET Runtime Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`n.NET Runtime Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
if ($args[1] -ne 'sdk' -and $args[1] -ne 'lib') {
pushd vscode-dotnet-runtime-extension
if (Test-Path node_modules) { rm -r -force node_modules }
npm ci --silent
npm run test
if ($LASTEXITCODE -ne 0)
{
Write-Host "`n.NET Runtime Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`n.NET Runtime Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
}
popd
}
popd

pushd vscode-dotnet-sdk-extension
if (Test-Path node_modules) { rm -r -force node_modules }
npm ci --silent
npm run test
if ($LASTEXITCODE -ne 0)
{
Write-Host "`n.NET SDK Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`n.NET SDK Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
if ($args[1] -ne 'lib' -and $args[1] -ne 'rnt') {
pushd vscode-dotnet-sdk-extension
if (Test-Path node_modules) { rm -r -force node_modules }
npm ci --silent
npm run test
if ($LASTEXITCODE -ne 0)
{
Write-Host "`n.NET SDK Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`n.NET SDK Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
}
popd
}
popd

if ($result -ne 0)
if ($result -ne 0)
{
Write-Host "`n`nTests Failed.`n" -ForegroundColor $errorColor
exit $result
}
else
else
{
Write-Host "`n`nAll Tests Succeeded.`n" -ForegroundColor $successColor
Write-Host "`n`nAll Tests Succeeded.`n" -ForegroundColor $successColor
exit $result
}
3 changes: 1 addition & 2 deletions vscode-dotnet-runtime-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"onCommand:dotnet.acquireStatus",
"onCommand:dotnet.uninstallAll",
"onCommand:dotnet.showAcquisitionLog",
"onCommand:dotnet.ensureDotnetDependencies",
"onCommand:dotnet.reportIssue"
"onCommand:dotnet.ensureDotnetDependencies"
],
"main": "./dist/extension.js",
"types": "./dist/extension.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
WindowDisplayWorker,
} from 'vscode-dotnet-runtime-library';
import { dotnetCoreAcquisitionExtensionId } from './DotnetCoreAcquistionId';

// tslint:disable no-var-requires
const packageJson = require('../package.json');

Expand All @@ -55,6 +56,7 @@ namespace commandKeys {
export const ensureDotnetDependencies = 'ensureDotnetDependencies';
export const reportIssue = 'reportIssue';
}

const commandPrefix = 'dotnet';
const configPrefix = 'dotnetAcquisitionExtension';
const displayChannelName = '.NET Runtime';
Expand Down Expand Up @@ -130,6 +132,7 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
}, issueContext(commandContext.errorConfiguration, 'acquire', commandContext.version), commandContext.requestingExtensionId);
return dotnetPath;
});

const dotnetAcquireStatusRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.acquireStatus}`, async (commandContext: IDotnetAcquireContext) => {
const pathResult = callWithErrorHandling(async () => {
eventStream.post(new DotnetAcquisitionStatusRequested(commandContext.version, commandContext.requestingExtensionId));
Expand All @@ -139,10 +142,13 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
}, issueContext(commandContext.errorConfiguration, 'acquireRuntimeStatus'));
return pathResult;
});

const dotnetUninstallAllRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.uninstallAll}`, async (commandContext: IDotnetUninstallContext | undefined) => {
await callWithErrorHandling(() => acquisitionWorker.uninstallAll(), issueContext(commandContext ? commandContext.errorConfiguration : undefined, 'uninstallAll'));
});

const showOutputChannelRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.showAcquisitionLog}`, () => outputChannel.show(/* preserveFocus */ false));

const ensureDependenciesRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.ensureDotnetDependencies}`, async (commandContext: IDotnetEnsureDependenciesContext) => {
await callWithErrorHandling(async () => {
if (os.platform() !== 'linux') {
Expand All @@ -158,6 +164,7 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
}
}, issueContext(commandContext.errorConfiguration, 'ensureDependencies'));
});

const reportIssueRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.reportIssue}`, async () => {
const [url, issueBody] = formatIssueUrl(undefined, issueContext(AcquireErrorConfiguration.DisableErrorPopups, 'reportIssue'));
await vscode.env.clipboard.writeText(issueBody);
Expand Down
Loading

0 comments on commit efcba6b

Please sign in to comment.