Skip to content

Commit bd3a498

Browse files
authored
PR feedback
1 parent bf75f6e commit bd3a498

File tree

6 files changed

+28
-107
lines changed

6 files changed

+28
-107
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@
414414
"neutral"
415415
],
416416
"installTestPath": "./.roslynCopilot/Microsoft.VisualStudio.Copilot.Roslyn.LanguageServer.dll",
417-
"integrity": "0BD733B23A706226F2B429AB0CE35576FB474493C8E19C7B88311007876DE5CC",
418-
"isOptional": true
417+
"integrity": "0BD733B23A706226F2B429AB0CE35576FB474493C8E19C7B88311007876DE5CC"
419418
},
420419
{
421420
"id": "Debugger",

src/lsptoolshost/extensions/builtInComponents.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ export const componentInfo: { [key: string]: ComponentInfo } = {
2727
'Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll',
2828
'Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll',
2929
],
30-
isOptional: true,
3130
},
3231
razorDevKit: {
3332
defaultFolderName: '.razorDevKit',
3433
optionName: 'razorDevKit',
3534
componentDllPaths: ['Microsoft.VisualStudio.DevKit.Razor.dll'],
36-
isOptional: true,
3735
},
3836
razorExtension: {
3937
defaultFolderName: '.razorExtension',

src/packageManager/IPackage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ export interface IPackage {
1313
platformId?: string;
1414
integrity?: string;
1515
isFramework?: boolean;
16-
isOptional?: boolean;
1716
}

src/packageManager/absolutePathPackage.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export class AbsolutePathPackage implements IPackage {
2020
public fallbackUrl?: string,
2121
public platformId?: string,
2222
public integrity?: string,
23-
public isFramework?: boolean,
24-
public isOptional?: boolean
23+
public isFramework?: boolean
2524
) {}
2625

2726
public static getAbsolutePathPackage(pkg: Package, extensionPath: string) {
@@ -37,8 +36,7 @@ export class AbsolutePathPackage implements IPackage {
3736
pkg.fallbackUrl,
3837
pkg.platformId,
3938
pkg.integrity,
40-
pkg.isFramework,
41-
pkg.isOptional
39+
pkg.isFramework
4240
);
4341
}
4442
}

src/packageManager/downloadAndInstallPackages.ts

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,7 @@ export async function downloadAndInstallPackages(
2626
telemetryReporter?: ITelemetryReporter,
2727
token?: CancellationToken
2828
): Promise<boolean> {
29-
function sendInstallationFailureTelemetry(pkg: AbsolutePathPackage, installationStage: string, error: any): void {
30-
if (!telemetryReporter) {
31-
return;
32-
}
33-
34-
const telemetryProperties: { [key: string]: string } = {
35-
installStage: installationStage,
36-
packageId: pkg.id,
37-
isOptional: pkg.isOptional ? 'true' : 'false',
38-
};
39-
40-
if (error instanceof NestedError && error.err instanceof PackageError) {
41-
telemetryProperties['error.message'] = error.err.message;
42-
telemetryProperties['error.packageUrl'] = error.err.pkg.url;
43-
} else if (error instanceof PackageError) {
44-
telemetryProperties['error.message'] = error.message;
45-
telemetryProperties['error.packageUrl'] = error.pkg.url;
46-
}
47-
48-
const eventName = pkg.isOptional ? 'OptionalPackageInstallationFailed' : 'PackageInstallationFailed';
49-
telemetryReporter.sendTelemetryEvent(eventName, telemetryProperties);
50-
}
51-
29+
let downloadFailed = false;
5230
eventStream.post(new PackageInstallStart());
5331
for (const pkg of packages) {
5432
let installationStage = 'touchBeginFile';
@@ -89,12 +67,7 @@ export async function downloadAndInstallPackages(
8967
// Send telemetry for the failure
9068
sendInstallationFailureTelemetry(pkg, installationStage, error);
9169

92-
// If the package is optional, log and continue with the next package
93-
if (pkg.isOptional) {
94-
continue;
95-
}
96-
97-
return false;
70+
downloadFailed = true;
9871
} finally {
9972
try {
10073
if (await installFileExists(pkg.installPath, InstallFileType.Begin)) {
@@ -106,5 +79,27 @@ export async function downloadAndInstallPackages(
10679
}
10780
}
10881

109-
return true;
82+
return !downloadFailed;
83+
84+
function sendInstallationFailureTelemetry(pkg: AbsolutePathPackage, installationStage: string, error: any): void {
85+
if (!telemetryReporter) {
86+
return;
87+
}
88+
89+
const telemetryProperties: { [key: string]: string } = {
90+
installStage: installationStage,
91+
packageId: pkg.id,
92+
isOptional: pkg.isOptional ? 'true' : 'false',
93+
};
94+
95+
if (error instanceof NestedError && error.err instanceof PackageError) {
96+
telemetryProperties['error.message'] = error.err.message;
97+
telemetryProperties['error.packageUrl'] = error.err.pkg.url;
98+
} else if (error instanceof PackageError) {
99+
telemetryProperties['error.message'] = error.message;
100+
telemetryProperties['error.packageUrl'] = error.pkg.url;
101+
}
102+
103+
telemetryReporter.sendTelemetryEvent('PackageInstallationFailed', telemetryProperties);
104+
}
110105
}

test/omnisharp/omnisharpUnitTests/packages/downloadAndInstallPackages.test.ts

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -218,74 +218,6 @@ describe(`${downloadAndInstallPackages.name}`, () => {
218218
});
219219
});
220220

221-
describe('Optional packages', () => {
222-
test('Returns true and continues when an optional package fails to download', async () => {
223-
const optionalPackage = <AbsolutePathPackage[]>[
224-
{
225-
url: `${server.baseUrl}/notDownloadablePackage`,
226-
description: 'Optional Package',
227-
installPath: new AbsolutePath(tmpDirPath),
228-
isOptional: true,
229-
},
230-
];
231-
232-
const result = await downloadAndInstallPackages(
233-
optionalPackage,
234-
networkSettingsProvider,
235-
eventStream,
236-
downloadValidator
237-
);
238-
expect(result).toBe(true);
239-
});
240-
241-
test('Continues to install remaining packages after optional package fails', async () => {
242-
const tmpInstallDir2 = await CreateTmpDir(true);
243-
const mixedPackages = <AbsolutePathPackage[]>[
244-
{
245-
url: `${server.baseUrl}/notDownloadablePackage`,
246-
description: 'Optional Package',
247-
installPath: new AbsolutePath(tmpDirPath),
248-
isOptional: true,
249-
},
250-
{
251-
url: `${server.baseUrl}/downloadablePackage`,
252-
description: packageDescription,
253-
installPath: new AbsolutePath(tmpInstallDir2.name),
254-
},
255-
];
256-
257-
const result = await downloadAndInstallPackages(
258-
mixedPackages,
259-
networkSettingsProvider,
260-
eventStream,
261-
downloadValidator
262-
);
263-
expect(result).toBe(true);
264-
expect(await util.fileExists(path.join(tmpInstallDir2.name, 'install.Lock'))).toBe(true);
265-
tmpInstallDir2.dispose();
266-
});
267-
268-
test('InstallationFailure event is logged for optional package', async () => {
269-
const optionalPackage = <AbsolutePathPackage[]>[
270-
{
271-
url: `${server.baseUrl}/notDownloadablePackage`,
272-
description: 'Optional Package',
273-
installPath: new AbsolutePath(tmpDirPath),
274-
isOptional: true,
275-
},
276-
];
277-
278-
eventBus.getEvents(); // Clear any previous events
279-
await downloadAndInstallPackages(optionalPackage, networkSettingsProvider, eventStream, downloadValidator);
280-
const obtainedEvents = eventBus.getEvents();
281-
const installationFailureEvent = obtainedEvents.find(
282-
(event) => event instanceof InstallationFailure
283-
) as InstallationFailure;
284-
expect(installationFailureEvent).toBeDefined();
285-
expect(installationFailureEvent.stage).toEqual('downloadPackage');
286-
});
287-
});
288-
289221
afterEach(async () => {
290222
if (tmpInstallDir) {
291223
tmpInstallDir.dispose();

0 commit comments

Comments
 (0)