diff --git a/.editorconfig b/.editorconfig index 15e8611b7..7086a0511 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,6 @@ indent_size = 4 trim_trailing_whitespace = true # 2 space indentation and utf-8 for *.yml, package.json, and .json files under src -[{*.yml,package.json,src/**/*.json}] +[{*.yml,package.json,*.json}] indent_size = 2 charset = utf-8 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9801a0c42..be75d9df2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: - name: Setup virtual display run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - - name: Install .NET Core 5.0 SDK + - name: Install .NET Core 6.0 SDK uses: actions/setup-dotnet@v1.7.2 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Install Node.js 15.x uses: actions/setup-node@v1 diff --git a/package-lock.json b/package-lock.json index e3626570f..2c708ca95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,6 +48,7 @@ "@types/unzipper": "^0.9.1", "@types/vscode": "1.65.0", "@types/yauzl": "2.9.1", + "@vscode/test-electron": "2.1.3", "archiver": "5.3.0", "chai": "4.3.4", "chai-arrays": "2.2.0", @@ -72,7 +73,6 @@ "typescript": "4.2.4", "unzipper": "0.10.11", "vsce": "1.100.2", - "vscode-test": "1.6.1", "webpack": "5.34.0", "webpack-cli": "4.6.0" }, @@ -351,6 +351,36 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "node_modules/@vscode/test-electron": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.1.3.tgz", + "integrity": "sha512-ps/yJ/9ToUZtR1dHfWi1mDXtep1VoyyrmGKC3UnIbScToRQvbUjyy1VMqnMEW3EpMmC3g7+pyThIPtPyCLHyow==", + "dev": true, + "dependencies": { + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "^5.0.0", + "rimraf": "^3.0.2", + "unzipper": "^0.10.11" + }, + "engines": { + "node": ">=8.9.3" + } + }, + "node_modules/@vscode/test-electron/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz", @@ -8782,38 +8812,6 @@ "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.0.0.tgz", "integrity": "sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==" }, - "node_modules/vscode-test": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.6.1.tgz", - "integrity": "sha512-086q88T2ca1k95mUzffvbzb7esqQNvJgiwY4h29ukPhFo8u+vXOOmelUoU5EQUHs3Of8+JuQ3oGdbVCqaxuTXA==", - "deprecated": "This package has been renamed to @vscode/test-electron, please update to the new name", - "dev": true, - "license": "MIT", - "dependencies": { - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "^5.0.0", - "rimraf": "^3.0.2", - "unzipper": "^0.10.11" - }, - "engines": { - "node": ">=8.9.3" - } - }, - "node_modules/vscode-test/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/vscode-uri": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.8.tgz", @@ -9634,6 +9632,29 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "@vscode/test-electron": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.1.3.tgz", + "integrity": "sha512-ps/yJ/9ToUZtR1dHfWi1mDXtep1VoyyrmGKC3UnIbScToRQvbUjyy1VMqnMEW3EpMmC3g7+pyThIPtPyCLHyow==", + "dev": true, + "requires": { + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "^5.0.0", + "rimraf": "^3.0.2", + "unzipper": "^0.10.11" + }, + "dependencies": { + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, "@webassemblyjs/ast": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz", @@ -16360,29 +16381,6 @@ "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.0.0.tgz", "integrity": "sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==" }, - "vscode-test": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.6.1.tgz", - "integrity": "sha512-086q88T2ca1k95mUzffvbzb7esqQNvJgiwY4h29ukPhFo8u+vXOOmelUoU5EQUHs3Of8+JuQ3oGdbVCqaxuTXA==", - "dev": true, - "requires": { - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "^5.0.0", - "rimraf": "^3.0.2", - "unzipper": "^0.10.11" - }, - "dependencies": { - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } - } - }, "vscode-uri": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.8.tgz", diff --git a/package.json b/package.json index f3f2a4ab6..3629f0c27 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "@types/unzipper": "^0.9.1", "@types/vscode": "1.65.0", "@types/yauzl": "2.9.1", + "@vscode/test-electron": "2.1.3", "archiver": "5.3.0", "chai": "4.3.4", "chai-arrays": "2.2.0", @@ -121,7 +122,6 @@ "typescript": "4.2.4", "unzipper": "0.10.11", "vsce": "1.100.2", - "vscode-test": "1.6.1", "webpack": "5.34.0", "webpack-cli": "4.6.0" }, @@ -921,30 +921,15 @@ }, "omnisharp.useModernNet": { "type": "boolean", - "default": false, + "default": true, "scope": "window", - "title": "Use .NET 6 build of OmniSharp (experimental)", - "description": "Use OmniSharp build for .NET 6. This version _does not_ support non-SDK-style .NET Framework projects, including Unity. SDK-style Framework, .NET Core, and .NET 5+ projects should see significant performance improvements, but there may still be bugs. Please open issues if you find any bugs." - }, - "omnisharp.useGlobalMono": { - "type": "string", - "default": "auto", - "enum": [ - "auto", - "always", - "never" - ], - "enumDescriptions": [ - "Automatically launch OmniSharp with internal \"mono\", since \"mono\" 6.12.0 does not support .NET Core 3.1.40x or .NET 5 SDKs.", - "Always launch OmniSharp with \"mono\". If version 6.4.0 or greater is not available on the PATH, an error will be printed.", - "Never launch OmniSharp on a globally-installed Mono." - ], - "description": "Launch OmniSharp with the globally-installed Mono. If set to \"always\", \"mono\" version 6.4.0 or greater must be available on the PATH. If set to \"auto\", OmniSharp will be launched with \"mono\" if version 6.4.0 or greater is available on the PATH." + "title": "Use .NET 6 build of OmniSharp", + "description": "Use OmniSharp build for .NET 6. This version _does not_ support non-SDK-style .NET Framework projects, including Unity. SDK-style Framework, .NET Core, and .NET 5+ projects should see significant performance improvements." }, "omnisharp.monoPath": { "type": "string", "scope": "machine", - "description": "Specifies the path to a mono installation to use when \"useGlobalMono\" is set to \"always\", instead of the default system one. Example: \"/Library/Frameworks/Mono.framework/Versions/Current\"" + "description": "Specifies the path to a mono installation to use when \"useModernNet\" is set to false, instead of the default system one. Example: \"/Library/Frameworks/Mono.framework/Versions/Current\"" }, "omnisharp.dotnetPath": { "type": "string", diff --git a/src/features/reportIssue.ts b/src/features/reportIssue.ts index 5a87d5ebc..be8bcf373 100644 --- a/src/features/reportIssue.ts +++ b/src/features/reportIssue.ts @@ -85,12 +85,9 @@ async function getMonoIfPlatformValid(isValidPlatformForMono: boolean, options: if (isValidPlatformForMono) { let monoVersion: string; try { - let globalMonoInfo = await monoResolver.getHostExecutableInfo(options); - if (globalMonoInfo) { - monoVersion = `OmniSharp using global mono :${globalMonoInfo.version}`; - } - else { - monoVersion = `OmniSharp using built-in mono`; + let monoInfo = await monoResolver.getHostExecutableInfo(options); + if (monoInfo) { + monoVersion = `OmniSharp using mono :${monoInfo.version}`; } } catch (error) { diff --git a/src/observers/OmnisharpLoggerObserver.ts b/src/observers/OmnisharpLoggerObserver.ts index 309af92f4..274a79c84 100644 --- a/src/observers/OmnisharpLoggerObserver.ts +++ b/src/observers/OmnisharpLoggerObserver.ts @@ -58,7 +58,7 @@ export class OmnisharpLoggerObserver extends BaseLoggerObserver { this.logger.append(`OmniSharp server started`); if (event.hostVersion) { this.logger.append(` with ${event.hostIsMono ? 'Mono' : '.NET'} ${event.hostVersion}`); - if (event.hostPath !== undefined) { + if (event.hostPath?.length > 0) { this.logger.append(` (${event.hostPath})`); } } diff --git a/src/observers/OptionChangeObserver.ts b/src/observers/OptionChangeObserver.ts index 3553131c1..9b7caa118 100644 --- a/src/observers/OptionChangeObserver.ts +++ b/src/observers/OptionChangeObserver.ts @@ -14,7 +14,6 @@ type OptionsKey = keyof Options; const omniSharpOptions: ReadonlyArray = [ "path", - "useGlobalMono", "enableMsBuildLoadProjectsOnDemand", "waitForDebugger", "loggingLevel", diff --git a/src/omnisharp/OmniSharpMonoResolver.ts b/src/omnisharp/OmniSharpMonoResolver.ts index 71c566795..839400918 100644 --- a/src/omnisharp/OmniSharpMonoResolver.ts +++ b/src/omnisharp/OmniSharpMonoResolver.ts @@ -17,15 +17,16 @@ export class OmniSharpMonoResolver implements IHostExecutableResolver { } private async configureEnvironmentAndGetInfo(options: Options): Promise { - let env = { ...process.env }; + const env = { ...process.env }; let monoPath: string; - if (options.useGlobalMono !== "never" && options.monoPath.length > 0) { + + if (options.monoPath.length > 0) { env['PATH'] = path.join(options.monoPath, 'bin') + path.delimiter + env['PATH']; env['MONO_GAC_PREFIX'] = options.monoPath; monoPath = options.monoPath; } - let version = await this.getMonoVersion(env); + const version = await this.getMonoVersion(env); return { version, @@ -35,29 +36,21 @@ export class OmniSharpMonoResolver implements IHostExecutableResolver { } public async getHostExecutableInfo(options: Options): Promise { - let monoInfo = await this.configureEnvironmentAndGetInfo(options); - let isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`); - if (options.useGlobalMono === "always") { - let isMissing = monoInfo.version === undefined; - if (isMissing) { - const suggestedAction = options.monoPath.length > 0 - ? "Update the \"omnisharp.monoPath\" setting to point to the folder containing Mono's '/bin' folder." - : "Ensure that Mono's '/bin' folder is added to your environment's PATH variable."; - throw new Error(`Unable to find Mono. ${suggestedAction}`); - } - - if (!isValid) { - throw new Error(`Found Mono version ${monoInfo.version}. Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`); - } - - return monoInfo; + const monoInfo = await this.configureEnvironmentAndGetInfo(options); + const isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`); + + const isMissing = monoInfo.version === undefined; + if (isMissing) { + const suggestedAction = options.monoPath + ? "Update the \"omnisharp.monoPath\" setting to point to the folder containing Mono's '/bin' folder." + : "Ensure that Mono's '/bin' folder is added to your environment's PATH variable."; + throw new Error(`Unable to find Mono. ${suggestedAction}`); } - else if (options.useGlobalMono === "auto" && isValid) { - // While waiting for Mono to ship with a MSBuild version 16.8 or higher, we will treat "auto" - // as "Use included Mono". - // return monoInfo; + + if (!isValid) { + throw new Error(`Found Mono version ${monoInfo.version}. Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`); } - return undefined; + return monoInfo; } } diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index a2ff4b0b0..cb09b318d 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -312,21 +312,7 @@ async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platf return launchWindows(launchInfo.LaunchPath, cwd, args); } - let monoInfo = await monoResolver.getHostExecutableInfo(options); - - if (monoInfo) { - const launchPath = launchInfo.MonoLaunchPath || launchInfo.LaunchPath; - let childEnv = monoInfo.env; - return { - ...launchNixMono(launchPath, cwd, args, childEnv, options.waitForDebugger), - hostIsMono: true, - hostVersion: monoInfo.version, - hostPath: monoInfo.path - }; - } - else { - return launchNix(launchInfo.LaunchPath, cwd, args); - } + return await launchNix(launchInfo, cwd, args, options, monoResolver); } function getConfigurationValue(globalConfig: vscode.WorkspaceConfiguration, csharpConfig: vscode.WorkspaceConfiguration, @@ -393,20 +379,20 @@ function launchWindows(launchPath: string, cwd: string, args: string[]): LaunchR }; } -function launchNix(launchPath: string, cwd: string, args: string[]): LaunchResult { - let process = spawn(launchPath, args, { - detached: false, - cwd: cwd - }); +async function launchNix(launchInfo: LaunchInfo, cwd: string, args: string[], options: Options, monoResolver: IHostExecutableResolver): Promise { + const monoInfo = await monoResolver.getHostExecutableInfo(options); + const launchPath = launchInfo.MonoLaunchPath || launchInfo.LaunchPath; return { - process, + process: launchNixMono(launchPath, cwd, args, monoInfo.env, options.waitForDebugger), command: launchPath, - hostIsMono: false + hostIsMono: true, + hostVersion: monoInfo.version, + hostPath: monoInfo.path }; } -function launchNixMono(launchPath: string, cwd: string, args: string[], environment: NodeJS.ProcessEnv, useDebugger: boolean): LaunchResult { +function launchNixMono(launchPath: string, cwd: string, args: string[], environment: NodeJS.ProcessEnv, useDebugger: boolean): ChildProcess { let argsCopy = args.slice(0); // create copy of details args argsCopy.unshift(launchPath); argsCopy.unshift("--assembly-loader=strict"); @@ -422,9 +408,5 @@ function launchNixMono(launchPath: string, cwd: string, args: string[], environm env: environment }); - return { - process, - command: launchPath, - hostIsMono: true - }; + return process; } diff --git a/src/omnisharp/options.ts b/src/omnisharp/options.ts index 99610bd3f..06cf0e478 100644 --- a/src/omnisharp/options.ts +++ b/src/omnisharp/options.ts @@ -9,7 +9,6 @@ export class Options { constructor( public path: string, public useModernNet: boolean, - public useGlobalMono: string, public waitForDebugger: boolean, public loggingLevel: string, public autoStart: boolean, @@ -62,16 +61,13 @@ export class Options { // are supported below. In particular, these are: // // - "csharp.omnisharp" -> "omnisharp.path" - // - "csharp.omnisharpUsesMono" -> "omnisharp.useMono" - // - "omnisharp.useMono" -> "omnisharp.useGlobalMono" const omnisharpConfig = vscode.workspace.getConfiguration('omnisharp'); const csharpConfig = vscode.workspace.getConfiguration('csharp'); const razorConfig = vscode.workspace.getConfiguration('razor'); const path = Options.readPathOption(csharpConfig, omnisharpConfig); - const useModernNet = omnisharpConfig.get("useModernNet", false); - const useGlobalMono = Options.readUseGlobalMonoOption(omnisharpConfig, csharpConfig); + const useModernNet = omnisharpConfig.get("useModernNet", true); // VS Code coerces unset string settings to the empty string. // Thus, to avoid dealing with the empty string AND undefined, @@ -96,7 +92,7 @@ export class Options { const useEditorFormattingSettings = omnisharpConfig.get('useEditorFormattingSettings', true); const enableRoslynAnalyzers = omnisharpConfig.get('enableRoslynAnalyzers', false); - const enableEditorConfigSupport = omnisharpConfig.get('enableEditorConfigSupport', false); + const enableEditorConfigSupport = omnisharpConfig.get('enableEditorConfigSupport', true); const enableDecompilationSupport = omnisharpConfig.get('enableDecompilationSupport', false); const enableImportCompletion = omnisharpConfig.get('enableImportCompletion', false); const enableAsyncCompletion = omnisharpConfig.get('enableAsyncCompletion', false); @@ -109,7 +105,7 @@ export class Options { const showTestsCodeLens = csharpConfig.get('testsCodeLens.enabled', true); const filteredSymbolsCodeLens = csharpConfig.get('referencesCodeLens.filteredSymbols', []); - const useSemanticHighlighting = csharpConfig.get('semanticHighlighting.enabled', false); + const useSemanticHighlighting = csharpConfig.get('semanticHighlighting.enabled', true); const inlayHintsEnableForParameters = csharpConfig.get('inlayHints.parameters.enabled', false); const inlayHintsForLiteralParameters = csharpConfig.get('inlayHints.parameters.forLiteralParameters', false); @@ -148,7 +144,6 @@ export class Options { return new Options( path, useModernNet, - useGlobalMono, waitForDebugger, loggingLevel, autoStart, @@ -230,23 +225,4 @@ export class Options { return ''; } } - - private static readUseGlobalMonoOption(omnisharpConfig: WorkspaceConfiguration, csharpConfig: WorkspaceConfiguration): string { - function toUseGlobalMonoValue(value?: boolean): string | undefined { - if (value === undefined) { - return undefined; - } - - // True means 'always' and false means 'auto'. - return value ? "always" : "auto"; - } - - // If 'omnisharp.useGlobalMono' is set, use that. - // Otherwise, for backcompat, look for 'omnisharp.useMono' and 'csharp.omnisharpUsesMono'. - // If both of those aren't found, return 'auto' as the default value. - return omnisharpConfig.get('useGlobalMono') ?? - toUseGlobalMonoValue(omnisharpConfig.get('useMono')) ?? - toUseGlobalMonoValue(csharpConfig.get('omnisharpUsesMono')) ?? - "auto"; - } } diff --git a/tasks/offlinePackagingTasks.ts b/tasks/offlinePackagingTasks.ts index 147e361a6..86cd34134 100644 --- a/tasks/offlinePackagingTasks.ts +++ b/tasks/offlinePackagingTasks.ts @@ -23,14 +23,16 @@ import { getRuntimeDependenciesPackages } from '../src/tools/RuntimeDependencyPa import { getAbsolutePathPackagesToInstall } from '../src/packageManager/getAbsolutePathPackagesToInstall'; import { isValidDownload } from '../src/packageManager/isValidDownload'; +const includeFrameworkOmniSharp = false; + export const offlinePackages = [ - { platformInfo: new PlatformInformation('win32', 'x86_64'), id: "win32-x64", isFramework: true }, - { platformInfo: new PlatformInformation('win32', 'x86'), id: "win32-ia32", isFramework: true }, - { platformInfo: new PlatformInformation('win32', 'arm64'), id: "win32-arm64", isFramework: true }, - { platformInfo: new PlatformInformation('linux', 'x86_64'), id: "linux-x64", isFramework: true }, - { platformInfo: new PlatformInformation('linux', 'arm64'), id: "linux-arm64", isFramework: true }, - { platformInfo: new PlatformInformation('darwin', 'x86_64'), id: "darwin-x64", isFramework: true }, - { platformInfo: new PlatformInformation('darwin', 'arm64'), id: "darwin-arm64", isFramework: true }, + { platformInfo: new PlatformInformation('win32', 'x86_64'), id: "win32-x64", isFramework: includeFrameworkOmniSharp }, + { platformInfo: new PlatformInformation('win32', 'x86'), id: "win32-ia32", isFramework: includeFrameworkOmniSharp }, + { platformInfo: new PlatformInformation('win32', 'arm64'), id: "win32-arm64", isFramework: includeFrameworkOmniSharp }, + { platformInfo: new PlatformInformation('linux', 'x86_64'), id: "linux-x64", isFramework: includeFrameworkOmniSharp }, + { platformInfo: new PlatformInformation('linux', 'arm64'), id: "linux-arm64", isFramework: includeFrameworkOmniSharp }, + { platformInfo: new PlatformInformation('darwin', 'x86_64'), id: "darwin-x64", isFramework: includeFrameworkOmniSharp }, + { platformInfo: new PlatformInformation('darwin', 'arm64'), id: "darwin-arm64", isFramework: includeFrameworkOmniSharp }, ]; export function getPackageName(packageJSON: any, vscodePlatformId: string) { diff --git a/test-plan.md b/test-plan.md index 6e029814f..a4e6dd960 100644 --- a/test-plan.md +++ b/test-plan.md @@ -475,17 +475,6 @@ Changing this option should result in a notification message at the bottom right * if the option is not set, the OmniSharp log should indicate that the registered MSBuild instance is either the Standalone MSBuild, a Visual Studio MSBuild instance, or a Mono MSBuild isntance. * if the option is set, the OmniSharp log should inlcude text like the following "OmniSharp server started with .NET 6.0.100" and "Registered MSBuild instance: .NET Core SDK 6.0.100 17.0.0 - "/usr/local/share/dotnet/sdk/6.0.100/". All language services should continue to work as expected when an SDK-style project is open. - #### omnisharp.useGlobalMono (for Linux/Mac) - This option can be set to any of the following values: - * "auto" - Will launch OmniSharp using mono if version>=5.2.0 is installed but will launch using the run script if that is not so. - * "always" - Will launch OmniSharp using mono if version>=5.2.0 is installed and will throw an error otherwise. - * "never" - Launches OmniSharp without using the global mono - - The value of OmniSharp path displayed in the OmniSharp log can be used to know if OmniSharp has launched using mono or not. If it is running using global mono, the path will end with "OmniSharp.exe" else the path will end with "run". - For using this option, mono version greater than or equal to 5.2.0 must be installed. If that is not so, setting this option to true, should give an error. - * If the option is not set, the OmniSharp path displayed in the "OmniSharp Log" should end with "run" - * If the option is set, the OmniSharp path as mentioned above should end with "OmniSharp.exe" - #### omnisharp.path Setting this path to any of the values as listed below, should start the OmniSharp server and display the correct OmniSharp path in the `OmniSharp Log`(View --> Output--> OmniSharp Log). * undefined - OmniSharp server must start using the copy of omnisharp shipped with the extension, that is, the OmniSharp path must be the extension path, followed by .omnisharp followed by the default omnisharp version as present in the package.json and the platform-specific executable. diff --git a/test/runFeatureTests.ts b/test/runFeatureTests.ts index bbc364717..e15073d00 100644 --- a/test/runFeatureTests.ts +++ b/test/runFeatureTests.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as path from 'path'; - -import { runTests } from 'vscode-test'; +import { runTests } from '@vscode/test-electron'; async function main() { try { @@ -26,4 +25,4 @@ async function main() { } } -main(); \ No newline at end of file +main(); diff --git a/test/runIntegrationTests.ts b/test/runIntegrationTests.ts index 3bdd3ddc6..978e440ea 100644 --- a/test/runIntegrationTests.ts +++ b/test/runIntegrationTests.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as path from 'path'; - -import { runTests } from 'vscode-test'; +import { runTests } from '@vscode/test-electron'; import { execChildProcess } from '../src/common'; function getSln(workspacePath: string): string | undefined { diff --git a/test/unitTests/Fakes/FakeMonoResolver.ts b/test/unitTests/Fakes/FakeMonoResolver.ts index 74dd14389..adb75f390 100644 --- a/test/unitTests/Fakes/FakeMonoResolver.ts +++ b/test/unitTests/Fakes/FakeMonoResolver.ts @@ -13,14 +13,14 @@ export const fakeMonoInfo: HostExecutableInformation = { }; export class FakeMonoResolver implements IHostExecutableResolver { - public getGlobalMonoCalled: boolean; + public getMonoCalled: boolean; constructor(public willReturnMonoInfo = true) { - this.getGlobalMonoCalled = false; + this.getMonoCalled = false; } async getHostExecutableInfo(): Promise { - this.getGlobalMonoCalled = true; + this.getMonoCalled = true; if (this.willReturnMonoInfo) { return Promise.resolve(fakeMonoInfo); } diff --git a/test/unitTests/Fakes/FakeOptions.ts b/test/unitTests/Fakes/FakeOptions.ts index f4b940a90..222ce14d0 100644 --- a/test/unitTests/Fakes/FakeOptions.ts +++ b/test/unitTests/Fakes/FakeOptions.ts @@ -9,7 +9,6 @@ export function getEmptyOptions(): Options { return new Options( /* path */"", /* useModernNet */false, - /* useGlobalMono */"", /* waitForDebugger */false, /* loggingLevel */"", /* autoStart */false, diff --git a/test/unitTests/OptionObserver/OptionChangeObserver.test.ts b/test/unitTests/OptionObserver/OptionChangeObserver.test.ts index 9e6e15ee2..b7e9ea9e7 100644 --- a/test/unitTests/OptionObserver/OptionChangeObserver.test.ts +++ b/test/unitTests/OptionObserver/OptionChangeObserver.test.ts @@ -39,7 +39,7 @@ suite("OmniSharpConfigChangeObserver", () => { { config: "omnisharp", section: "path", value: "somePath" }, { config: "omnisharp", section: "waitForDebugger", value: true }, { config: "omnisharp", section: "enableMsBuildLoadProjectsOnDemand", value: true }, - { config: "omnisharp", section: "useGlobalMono", value: "always" }, + { config: "omnisharp", section: "useModernNet", value: false }, { config: "omnisharp", section: 'loggingLevel', value: 'verbose' } ].forEach(elem => { suite(`When the ${elem.config} ${elem.section} changes`, () => { diff --git a/test/unitTests/features/reportIssue.test.ts b/test/unitTests/features/reportIssue.test.ts index f1f4fce9c..c87b7bea3 100644 --- a/test/unitTests/features/reportIssue.test.ts +++ b/test/unitTests/features/reportIssue.test.ts @@ -100,25 +100,18 @@ suite(`${reportIssue.name}`, () => { test("mono information is obtained when it is a valid mono platform", async () => { await reportIssue(vscode, eventStream, getDotnetInfo, isValidForMono, options, fakeMonoResolver); - expect(fakeMonoResolver.getGlobalMonoCalled).to.be.equal(true); + expect(fakeMonoResolver.getMonoCalled).to.be.equal(true); }); - test("mono version is put in the body when shouldUseGlobalMono returns a monoInfo", async () => { + test("mono version is put in the body when it is a valid mono platform", async () => { await reportIssue(vscode, eventStream, getDotnetInfo, isValidForMono, options, fakeMonoResolver); - expect(fakeMonoResolver.getGlobalMonoCalled).to.be.equal(true); + expect(fakeMonoResolver.getMonoCalled).to.be.equal(true); expect(issueBody).to.contain(fakeMonoInfo.version); }); - test("built-in mono usage message is put in the body when shouldUseGlobalMono returns a null", async () => { - fakeMonoResolver = new FakeMonoResolver(false); - await reportIssue(vscode, eventStream, getDotnetInfo, isValidForMono, options, fakeMonoResolver); - expect(fakeMonoResolver.getGlobalMonoCalled).to.be.equal(true); - expect(issueBody).to.contain(`OmniSharp using built-in mono`); - }); - test("mono information is not obtained when it is not a valid mono platform", async () => { await reportIssue(vscode, eventStream, getDotnetInfo, false, options, fakeMonoResolver); - expect(fakeMonoResolver.getGlobalMonoCalled).to.be.equal(false); + expect(fakeMonoResolver.getMonoCalled).to.be.equal(false); }); test("The url contains the name, publisher and version for all the extensions that are not builtin", async () => { diff --git a/test/unitTests/omnisharp/OmniSharpMonoResolver.test.ts b/test/unitTests/omnisharp/OmniSharpMonoResolver.test.ts index 806087b41..3f15ccb17 100644 --- a/test/unitTests/omnisharp/OmniSharpMonoResolver.test.ts +++ b/test/unitTests/omnisharp/OmniSharpMonoResolver.test.ts @@ -14,7 +14,6 @@ chaiUse(require('chai-as-promised')); suite(`${OmniSharpMonoResolver.name}`, () => { let getMonoCalled: boolean; - let environment: NodeJS.ProcessEnv; let options: Options; const monoPath = "monoPath"; @@ -23,12 +22,8 @@ suite(`${OmniSharpMonoResolver.name}`, () => { const requiredMonoVersion = "6.4.0"; const higherMonoVersion = "6.6.0"; - // Sets the meaning of UseGlobalMono "auto". When false, "auto" means "never". - const autoMeansAlways = false; - const getMono = (version: string) => async (env: NodeJS.ProcessEnv) => { getMonoCalled = true; - environment = env; return Promise.resolve(version); }; @@ -37,122 +32,35 @@ suite(`${OmniSharpMonoResolver.name}`, () => { options = getEmptyOptions(); }); - test(`it returns undefined if the version is less than ${requiredMonoVersion} and useGlobalMono is auto`, async () => { - let monoResolver = new OmniSharpMonoResolver(getMono(lowerMonoVersion)); - let monoInfo = await monoResolver.getHostExecutableInfo({ - ...options, - useGlobalMono: "auto", - monoPath: monoPath - }); - expect(monoInfo).to.be.undefined; - }); - - test("it returns undefined if useGlobalMono is never", async () => { + test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion}`, async () => { let monoResolver = new OmniSharpMonoResolver(getMono(higherMonoVersion)); let monoInfo = await monoResolver.getHostExecutableInfo({ ...options, - useGlobalMono: "never", monoPath: monoPath }); - expect(monoInfo).to.be.undefined; - }); - test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion} and useGlobalMono is always`, async () => { - let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion)); - let monoInfo = await monoResolver.getHostExecutableInfo({ - ...options, - useGlobalMono: "always", - monoPath: monoPath - }); - - expect(monoInfo.version).to.be.equal(requiredMonoVersion); + expect(monoInfo.version).to.be.equal(higherMonoVersion); expect(monoInfo.path).to.be.equal(monoPath); }); - test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion} and useGlobalMono is auto`, async () => { - let monoResolver = new OmniSharpMonoResolver(getMono(higherMonoVersion)); - let monoInfo = await monoResolver.getHostExecutableInfo({ - ...options, - useGlobalMono: "auto", - monoPath: monoPath - }); - - if (!autoMeansAlways) { - expect(monoInfo).to.be.undefined; - } - else { - expect(monoInfo.version).to.be.equal(higherMonoVersion); - expect(monoInfo.path).to.be.equal(monoPath); - } - }); - - test(`it throws exception if getGlobalMonoInfo is always and version<${requiredMonoVersion}`, async () => { + test(`it throws exception if version is less than ${requiredMonoVersion}`, async () => { let monoResolver = new OmniSharpMonoResolver(getMono(lowerMonoVersion)); await expect(monoResolver.getHostExecutableInfo({ ...options, - useGlobalMono: "always", monoPath: monoPath })).to.be.rejected; }); - test("sets the environment with the monoPath id useGlobalMono is auto", async () => { + test("sets the environment with the monoPath", async () => { let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion)); let monoInfo = await monoResolver.getHostExecutableInfo({ ...options, - useGlobalMono: "auto", - monoPath: monoPath - }); - - if (!autoMeansAlways) { - expect(monoInfo).to.be.undefined; - } - else { - expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin')); - expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath); - } - }); - - test("sets the environment with the monoPath id useGlobalMono is auto", async () => { - let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion)); - let monoInfo = await monoResolver.getHostExecutableInfo({ - ...options, - useGlobalMono: "auto", - monoPath: monoPath - }); - - if (!autoMeansAlways) { - expect(monoInfo).to.be.undefined; - } - else { - expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin')); - expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath); - } - }); - - test("doesn't set the environment with the monoPath if useGlobalMono is never", async () => { - let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion)); - await monoResolver.getHostExecutableInfo({ - ...options, - useGlobalMono: "never", - monoPath: monoPath - }); - - expect(getMonoCalled).to.be.equal(true); - expect(environment["PATH"] || "").to.not.contain(join(monoPath, 'bin')); - expect(environment["MONO_GAC_PREFIX"]).to.be.undefined; - }); - - test("getMono is called with the environment that includes the monoPath if the useGlobalMono is auto or always", async () => { - let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion)); - await monoResolver.getHostExecutableInfo({ - ...options, - useGlobalMono: "auto", monoPath: monoPath }); expect(getMonoCalled).to.be.equal(true); - expect(environment["PATH"]).to.contain(join(monoPath, 'bin')); - expect(environment["MONO_GAC_PREFIX"]).to.be.equal(monoPath); + expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin')); + expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath); }); }); diff --git a/test/unitTests/optionStream.test.ts b/test/unitTests/optionStream.test.ts index ea7b7cf0a..9b91b8d24 100644 --- a/test/unitTests/optionStream.test.ts +++ b/test/unitTests/optionStream.test.ts @@ -37,7 +37,6 @@ suite('OptionStream', () => { test('Returns the default options if there is no change', () => { options.path.should.equal(""); - options.useGlobalMono.should.equal("auto"); options.waitForDebugger.should.equal(false); options.loggingLevel.should.equal("information"); options.autoStart.should.equal(true); @@ -52,7 +51,7 @@ suite('OptionStream', () => { options.maxFindSymbolsItems.should.equal(1000); options.enableMsBuildLoadProjectsOnDemand.should.equal(false); options.enableRoslynAnalyzers.should.equal(false); - options.enableEditorConfigSupport.should.equal(false); + options.enableEditorConfigSupport.should.equal(true); options.enableDecompilationSupport.should.equal(false); options.enableImportCompletion.should.equal(false); options.enableAsyncCompletion.should.equal(false); diff --git a/test/unitTests/options.test.ts b/test/unitTests/options.test.ts index c3d9d25d5..611363ebd 100644 --- a/test/unitTests/options.test.ts +++ b/test/unitTests/options.test.ts @@ -14,7 +14,6 @@ suite("Options tests", () => { const vscode = getVSCodeWithConfig(); const options = Options.Read(vscode); options.path.should.equal(""); - options.useGlobalMono.should.equal("auto"); options.monoPath.should.equal(""); options.waitForDebugger.should.equal(false); options.loggingLevel.should.equal("information"); @@ -31,7 +30,7 @@ suite("Options tests", () => { options.maxFindSymbolsItems.should.equal(1000); options.enableMsBuildLoadProjectsOnDemand.should.equal(false); options.enableRoslynAnalyzers.should.equal(false); - options.enableEditorConfigSupport.should.equal(false); + options.enableEditorConfigSupport.should.equal(true); options.enableDecompilationSupport.should.equal(false); options.enableImportCompletion.should.equal(false); options.analyzeOpenDocumentsOnly.should.equal(false); @@ -82,42 +81,6 @@ suite("Options tests", () => { options.loggingLevel.should.equal("debug"); }); - test('BACK-COMPAT: "omnisharp.useMono": true == "omnisharp.useGlobalMono": "always"', () => { - const vscode = getVSCodeWithConfig(); - updateConfig(vscode, 'omnisharp', 'useMono', true); - - const options = Options.Read(vscode); - - options.useGlobalMono.should.equal("always"); - }); - - test('BACK-COMPAT: "omnisharp.useMono": false == "omnisharp.useGlobalMono": "auto"', () => { - const vscode = getVSCodeWithConfig(); - updateConfig(vscode, 'omnisharp', 'useMono', false); - - const options = Options.Read(vscode); - - options.useGlobalMono.should.equal("auto"); - }); - - test('BACK-COMPAT: "csharp.omnisharpUsesMono": true == "omnisharp.useGlobalMono": "always"', () => { - const vscode = getVSCodeWithConfig(); - updateConfig(vscode, 'csharp', 'omnisharpUsesMono', true); - - const options = Options.Read(vscode); - - options.useGlobalMono.should.equal("always"); - }); - - test('BACK-COMPAT: "csharp.omnisharpUsesMono": false == "omnisharp.useGlobalMono": "auto"', () => { - const vscode = getVSCodeWithConfig(); - updateConfig(vscode, 'csharp', 'omnisharpUsesMono', false); - - const options = Options.Read(vscode); - - options.useGlobalMono.should.equal("auto"); - }); - test('BACK-COMPAT: "csharp.omnisharp" is used if it is set and "omnisharp.path" is not', () => { const vscode = getVSCodeWithConfig(); updateConfig(vscode, 'csharp', 'omnisharp', 'OldPath');