Protect against no versions of .NET to recommend (#1768)
* Update Dependencies * Remove is online Is-online now requires ES6. It has not been maintained in over 2 years. The checks it does are fairly rudimentary. We only rely on this code to try to diagnose the error which has already happened. I would trust this code rather than rely on external libraries. * Fix timeout logic for no is online * Fix Linting Issues * Protect against no versions of .NET to recommend The API contract is to return an IDotnetVersion which is an array of versions. If there are no packages of .NET available to install, we should have a specific message for that and return an empty array instead of what we do right now, which is a - returning a bad version b - returning undefined c - erroring out * respond to linter to accept any error type
This commit is contained in:
Родитель
2895d85bc2
Коммит
cc510402c2
|
@ -360,19 +360,28 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
|||
else
|
||||
{
|
||||
const linuxResolver = new LinuxVersionResolver(sdkContext, utilContext);
|
||||
const suggestedVersion = await linuxResolver.getRecommendedDotnetVersion('sdk' as LinuxInstallType);
|
||||
const osAgnosticVersionData = await getAvailableVersions(commandContext, customWebWorker, !onRecommendationMode);
|
||||
const resolvedSupportPhase = osAgnosticVersionData?.find((version : IDotnetVersion) =>
|
||||
customVersionResolver.getMajorMinor(version.version) === customVersionResolver.getMajorMinor(suggestedVersion))?.supportPhase ?? 'active';
|
||||
// Assumption : The newest version is 'active' support, but we can't gaurantee that.
|
||||
// If the linux version is too old it will eventually support no active versions of .NET, which would cause a failure.
|
||||
// The best we can give it is the newest working version, which is the most likely to be supported, and mark it as active so we can use it.
|
||||
try
|
||||
{
|
||||
const suggestedVersion = await linuxResolver.getRecommendedDotnetVersion('sdk' as LinuxInstallType);
|
||||
const osAgnosticVersionData = await getAvailableVersions(commandContext, customWebWorker, !onRecommendationMode);
|
||||
const resolvedSupportPhase = osAgnosticVersionData?.find((version : IDotnetVersion) =>
|
||||
customVersionResolver.getMajorMinor(version.version) === customVersionResolver.getMajorMinor(suggestedVersion))?.supportPhase ?? 'active';
|
||||
// Assumption : The newest version is 'active' support, but we can't gaurantee that.
|
||||
// If the linux version is too old it will eventually support no active versions of .NET, which would cause a failure.
|
||||
// The best we can give it is the newest working version, which is the most likely to be supported, and mark it as active so we can use it.
|
||||
|
||||
return [
|
||||
{ version: suggestedVersion, channelVersion: `${customVersionResolver.getMajorMinor(suggestedVersion)}`,
|
||||
supportStatus: Number(customVersionResolver.getMajor(suggestedVersion)) % 2 === 0 ? 'lts' : 'sts',
|
||||
supportPhase: resolvedSupportPhase }
|
||||
];
|
||||
return [
|
||||
{ version: suggestedVersion, channelVersion: `${customVersionResolver.getMajorMinor(suggestedVersion)}`,
|
||||
supportStatus: Number(customVersionResolver.getMajor(suggestedVersion)) % 2 === 0 ? 'lts' : 'sts',
|
||||
supportPhase: resolvedSupportPhase }
|
||||
];
|
||||
}
|
||||
// tslint:disable no-any
|
||||
catch(error : any)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
// tslint:enable no-any
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { CommandExecutorCommand } from '../Utils/CommandExecutorCommand';
|
|||
import { DotnetDistroSupportStatus } from './LinuxVersionResolver';
|
||||
import { LinuxInstallType } from './LinuxInstallType';
|
||||
import { IDistroDotnetSDKProvider } from './IDistroDotnetSDKProvider';
|
||||
import { DotnetVersionResolutionError } from '../EventStream/EventStreamEvents';
|
||||
/* tslint:disable:no-any */
|
||||
|
||||
export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
|
||||
|
@ -209,6 +210,14 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
|
|||
}
|
||||
}
|
||||
|
||||
if(maxVersion === '0')
|
||||
{
|
||||
const err = new DotnetVersionResolutionError(new Error(`No packages for .NET are available.
|
||||
Please refer to https://learn.microsoft.com/en-us/dotnet/core/install/linux if you'd link to install .NET.`), null);
|
||||
this.context.eventStream.post(err);
|
||||
throw(err);
|
||||
}
|
||||
|
||||
// Most distros support only 100 band .NET versions, so we default to that here.
|
||||
return `${this.JsonDotnetVersion(maxVersion)}.1xx`;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче