Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions build/webpack/loaders/fixGetosRequire.js

This file was deleted.

14 changes: 0 additions & 14 deletions build/webpack/loaders/fixGetosRequire.ts

This file was deleted.

12 changes: 1 addition & 11 deletions build/webpack/webpack.debugadapter.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ const config = {
}
]
},
{
// Do not use __dirname in getos when using require.
test: /getos[\\\/]index.js$/,
use: [
{
loader: path.join(__dirname, 'loaders', 'fixGetosRequire.js')
}
]
},
{
test: /\.ts$/,
exclude: /node_modules/,
Expand All @@ -55,8 +46,7 @@ const config = {
'commonjs'
],
plugins: [
...common_1.getDefaultPlugins('extension'),
new webpack_1.ContextReplacementPlugin(/getos/, /logic\/.*.js/)
...common_1.getDefaultPlugins('extension')
],
resolve: {
extensions: ['.ts', '.js'],
Expand Down
12 changes: 1 addition & 11 deletions build/webpack/webpack.debugadapter.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ const config: Configuration = {
}
]
},
{
// Do not use __dirname in getos when using require.
test: /getos[\\\/]index.js$/,
use: [
{
loader: path.join(__dirname, 'loaders', 'fixGetosRequire.js')
}
]
},
{
test: /\.ts$/,
exclude: /node_modules/,
Expand All @@ -58,8 +49,7 @@ const config: Configuration = {
'commonjs'
],
plugins: [
...getDefaultPlugins('extension'),
new ContextReplacementPlugin(/getos/, /logic\/.*.js/)
...getDefaultPlugins('extension')
],
resolve: {
extensions: ['.ts', '.js'],
Expand Down
10 changes: 0 additions & 10 deletions build/webpack/webpack.extension.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ const config = {
}
]
},
{
// Do not use __dirname in getos when using require.
test: /getos[\\\/]index.js$/,
use: [
{
loader: path.join(__dirname, 'loaders', 'fixGetosRequire.js')
}
]
},
{
test: /\.ts$/,
use: [
Expand All @@ -70,7 +61,6 @@ const config = {
],
plugins: [
...common_1.getDefaultPlugins('extension'),
new webpack_1.ContextReplacementPlugin(/getos/, /logic\/.*.js/),
new WrapperPlugin({
test: /\extension.js$/,
// Import source map warning file only if source map is enabled.
Expand Down
10 changes: 0 additions & 10 deletions build/webpack/webpack.extension.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ const config: Configuration = {
}
]
},
{
// Do not use __dirname in getos when using require.
test: /getos[\\\/]index.js$/,
use: [
{
loader: path.join(__dirname, 'loaders', 'fixGetosRequire.js')
}
]
},
{
test: /\.ts$/,
use: [
Expand All @@ -75,7 +66,6 @@ const config: Configuration = {
],
plugins: [
...getDefaultPlugins('extension'),
new ContextReplacementPlugin(/getos/, /logic\/.*.js/),
new WrapperPlugin({
test: /\extension.js$/,
// Import source map warning file only if source map is enabled.
Expand Down
1 change: 1 addition & 0 deletions news/2 Fixes/3693.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lowering threshold for Language Server support on a platform.
18 changes: 0 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@
"compile-webviews-verbose": "npx webpack --config webpack.datascience-ui.config.js",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./out/test/standardTest.js && node ./out/test/multiRootTest.js",
"test:unittests": "mocha --opts ./build/.mocha.unittests.opts",
"test:unittests": "mocha --opts ./build/.mocha.unittests.opts --grep='PlatformService'",
"test:unittests:cover": "nyc --nycrc-path ./build/.nycrc npm run test:unittests",
"test:functional": "mocha --opts ./build/.mocha.functional.opts",
"test:functional:cover": "nyc--nycrc-path ./build/.nycrc npm run test:functional",
Expand All @@ -1886,7 +1886,6 @@
"fs-extra": "^4.0.3",
"fuzzy": "^0.1.3",
"get-port": "^3.2.0",
"getos": "^3.1.0",
"glob": "^7.1.2",
"iconv-lite": "^0.4.21",
"inversify": "^4.11.1",
Expand Down
63 changes: 3 additions & 60 deletions src/client/common/dotnet/services/linuxCompatibilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,19 @@
'use strict';

import { inject, injectable } from 'inversify';
import { SemVer } from 'semver';
import { traceDecorators, traceError } from '../../logger';
import { IPlatformService } from '../../platform/types';
import { OSDistro } from '../../utils/platform';
import { parseVersion } from '../../utils/version';
import { IOSDotNetCompatibilityService } from '../types';

// Versions on https://github.com/dotnet/core/blob/master/release-notes/2.1/2.1-supported-os.md
// We are not goind to restrict to exact versions.
// Its possible .net core updates will go out before we can update this code.
// So lets assume that .net core will be supported on this minimum versions.
const versionsPerDistro = new Map<OSDistro, string[]>();
versionsPerDistro.set(OSDistro.RHEL, ['6.0.0', '7.0.0']);
versionsPerDistro.set(OSDistro.CentOS, ['7.0.0']);
versionsPerDistro.set(OSDistro.Oracle, ['7.0.0']);
versionsPerDistro.set(OSDistro.Fedora, ['27.0.0', '28.0.0']);
versionsPerDistro.set(OSDistro.Debian, ['9.0.0', '8.7.0']);
versionsPerDistro.set(OSDistro.Ubuntu, ['18.04.0', '16.04.0', '14.04.0']);
versionsPerDistro.set(OSDistro.Mint, ['18.0.0', '17.0.0']);
versionsPerDistro.set(OSDistro.Suse, ['42.3.0', '12.0.0']);
versionsPerDistro.set(OSDistro.Alpine, ['3.7.0']);

@injectable()
export class LinuxDotNetCompatibilityService implements IOSDotNetCompatibilityService {
constructor(@inject(IPlatformService) private readonly platformService: IPlatformService) { }
@traceDecorators.verbose('Checking support of .NET')
public async isSupported() {
const distro = await this.platformService.getOSDistro();
if (!versionsPerDistro.has(distro)) {
traceError(`.NET is not supported on Linux Distro '${distro}'`);
return false;
}

const minimumVersions = versionsPerDistro.get(distro)!;
const version = await this.platformService.getVersion();
return this.checkIfVersionsAreSupported(version, minimumVersions);
}

@traceDecorators.verbose('Checking support of Linux Distro Version')
private async checkIfVersionsAreSupported(version: SemVer, minimumSupportedVersions: string[]): Promise<boolean> {
if (!Array.isArray(minimumSupportedVersions) || minimumSupportedVersions.length === 0) {
if (!this.platformService.is64bit) {
traceError('.NET is not supported on 32 Bit Linux');
return false;
}
if (minimumSupportedVersions.length === 1) {
// If we have only one version, then check if OS version is greater or same.
return version.compare(minimumSupportedVersions[0]) >= 0;
}

// If we have more than one version, then
// Check if OS version is greater than the max of the versions provided, if yes, the allow it.
// E.g. if versions 18.0, 16.0, 14.0 are supported by .NET core
// Then we assume 19, 20 are supported as well.
const sorted = minimumSupportedVersions.slice().map(ver => parseVersion(ver)!);
sorted.sort((a, b) => a.compare(b));
if (version.compare(sorted[sorted.length - 1]) >= 0) {
return true;
}

// Else look for exact major versions and compare against the minor.
// E.g. if versions 18.0, 16.0, 14.0 are supported by .NET core
// Then we assume 16.1, 14.1, 14.2 are supported.
const matchingMajorVersions = sorted.filter(item => item.major === version.major);
if (matchingMajorVersions.length > 0 && version.minor >= matchingMajorVersions[0].minor) {
return true;
}

// Rest are not supported.
// E.g. if versions 18.0, 16.0, 14.0 are supported by .NET core
// 17, 15 are not supported.
// Similarly, 13, 12,10 are not supported.
return false;
return true;
}
}
11 changes: 2 additions & 9 deletions src/client/common/dotnet/services/windowsCompatibilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@

'use strict';

import { inject, injectable } from 'inversify';
import { IPlatformService } from '../../platform/types';
import { injectable } from 'inversify';
import { IOSDotNetCompatibilityService } from '../types';

// Min version on https://github.com/dotnet/core/blob/master/release-notes/2.1/2.1-supported-os.md is 10.12.
// Lets just assume that anything after Win 7SP1 are supported.
const minVersion = '6.1.7601';

@injectable()
export class WindowsDotNetCompatibilityService implements IOSDotNetCompatibilityService {
constructor(@inject(IPlatformService) private readonly platformService: IPlatformService) { }
public async isSupported() {
const version = await this.platformService.getVersion();
return version.compare(minVersion) >= 0;
return true;
}
}
72 changes: 2 additions & 70 deletions src/client/common/platform/platformService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,21 @@ import { coerce, SemVer } from 'semver';
import { sendTelemetryEvent } from '../../telemetry';
import { PLATFORM_INFO, PlatformErrors } from '../../telemetry/constants';
import { traceDecorators, traceError } from '../logger';
import { OSDistro, OSType } from '../utils/platform';
import { OSType } from '../utils/platform';
import { parseVersion } from '../utils/version';
import { NON_WINDOWS_PATH_VARIABLE_NAME, WINDOWS_PATH_VARIABLE_NAME } from './constants';
import { IPlatformService } from './types';

@injectable()
export class PlatformService implements IPlatformService {
public readonly osType: OSType = getOSType();
public distro?: OSDistro;
public version?: SemVer;
public get pathVariableName() {
return this.isWindows ? WINDOWS_PATH_VARIABLE_NAME : NON_WINDOWS_PATH_VARIABLE_NAME;
}
public get virtualEnvBinName() {
return this.isWindows ? 'Scripts' : 'bin';
}
@traceDecorators.verbose('Get OS Distro')
public async getOSDistro(): Promise<OSDistro> {
if (this.distro) {
return this.distro;
}
switch (this.osType) {
case OSType.Windows:
case OSType.OSX:
return this.distro = OSDistro.Unknown;
default:
const result = await getLinuxDistro();
this.distro = result[0];
this.version = result[1];
return this.distro;
}
}
@traceDecorators.verbose('Get Platform Version')
public async getVersion(): Promise<SemVer> {
if (this.version) {
Expand All @@ -64,11 +47,7 @@ export class PlatformService implements IPlatformService {
return parseVersion(os.release());
}
default:
const result = await getLinuxDistro();
sendTelemetryEvent(PLATFORM_INFO, undefined, { distro: result[0], osVersion: `${result[1].major}.${result[1].minor}.${result[1].patch}` });
this.distro = result[0];
this.version = result[1];
return this.version;
throw new Error('Not Supported');
}
}

Expand Down Expand Up @@ -100,50 +79,3 @@ function getOSType(platform: string = process.platform): OSType {
return OSType.Unknown;
}
}

async function getLinuxDistro(): Promise<[OSDistro, SemVer]> {
let distro: OSDistro = OSDistro.Unknown;
let version = new SemVer('0.0.0');
return new Promise<[OSDistro, SemVer]>((resolve, reject) => {
// tslint:disable-next-line:no-require-imports
const getos = require('getos') as typeof import('getos');
// tslint:disable-next-line:no-any
getos((exc: Error, info: any) => {
if (exc) {
sendTelemetryEvent(PLATFORM_INFO, undefined, { failureType: PlatformErrors.FailedToGetLinuxInfo });
return reject(exc);
}
distro = getLinuxDistroFromName(info.dist);
version = parseVersion(info.release);
resolve([distro, version]);
});
});
}

function getLinuxDistroFromName(name: string): OSDistro {
name = name.toLowerCase();
// See https://github.com/zyga/os-release-zoo.
if (/ubuntu/.test(name)) {
return OSDistro.Ubuntu;
} else if (/debian/.test(name)) {
return OSDistro.Debian;
} else if (/rhel/.test(name) || /red hat/.test(name)) {
return OSDistro.RHEL;
} else if (/fedora/.test(name)) {
return OSDistro.Fedora;
} else if (/alpine/.test(name)) {
return OSDistro.Alpine;
} else if (/mint/.test(name)) {
return OSDistro.Mint;
} else if (/centos/.test(name)) {
return OSDistro.CentOS;
} else if (/suse/.test(name)) {
return OSDistro.Suse;
} else if (/gentoo/.test(name)) {
return OSDistro.Suse;
} else if (/arch/.test(name)) {
return OSDistro.Arch;
} else {
return OSDistro.Unknown;
}
}
3 changes: 1 addition & 2 deletions src/client/common/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fs from 'fs';
import * as fsextra from 'fs-extra';
import { SemVer } from 'semver';
import { Disposable } from 'vscode';
import { Architecture, OSDistro, OSType } from '../utils/platform';
import { Architecture, OSType } from '../utils/platform';

export enum RegistryHive {
HKCU, HKLM
Expand All @@ -28,7 +28,6 @@ export interface IPlatformService {
readonly isMac: boolean;
readonly isLinux: boolean;
readonly is64bit: boolean;
getOSDistro(): Promise<OSDistro>;
getVersion(): Promise<SemVer>;
}

Expand Down
Loading