Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"csharp-test-profile",
"${workspaceRoot}/test/untrustedWorkspace/integrationTests/testAssets/empty/.vscode/empty.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/untrustedWorkspace/integrationTests",
"--extensionTestsPath=${workspaceRoot}/out/test/untrustedWorkspace/integrationTests/index.js",
"--log",
"ms-dotnettools.csharp:trace"
],
Expand Down Expand Up @@ -56,7 +56,7 @@
"csharp-test-profile",
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests",
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests/index.js",
"--log",
"ms-dotnettools.csharp:trace"
],
Expand Down Expand Up @@ -84,7 +84,7 @@
"csharp-test-profile",
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/devkit_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests",
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests/index.js",
"--log",
"ms-dotnettools.csharp:trace"
],
Expand Down Expand Up @@ -112,7 +112,7 @@
"csharp-test-profile",
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/RazorApp/.vscode/RazorApp.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests",
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests/index.js",
"--log",
"ms-dotnettools.csharp:trace"
],
Expand All @@ -139,7 +139,7 @@
"csharp-test-profile",
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_${input:omnisharpAssetName}.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests/index.js"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
Expand All @@ -164,7 +164,7 @@
"csharp-test-profile",
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_lsp_${input:omnisharpAssetName}.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests/index.js"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
Expand Down
6 changes: 3 additions & 3 deletions __mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscodeAdapter from '../src/vscodeAdapter';
import { getFakeVsCode } from '../test/fakes';
import * as vscodeAdapter from '../src/vscodeAdapter.ts';
import { getFakeVsCode } from '../test/fakes.ts';

// This module creates a manual mock for the vscode module for running in unit tests.
// Jest will automatically pick this up as it is in the __mocks__ directory next to node_modules.

// We can consider switching to an actual jest mock (instead of this manual fake) once we entirely
// remove the old test framework (mocha/chai).
const vscode: vscodeAdapter.vscode = getFakeVsCode();
module.exports = vscode;
export const { commands, languages, window, workspace, extensions, Uri, version, env, l10n } = vscode;
25 changes: 20 additions & 5 deletions baseJestConfig.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import { fileURLToPath } from 'node:url';
import { createDefaultEsmPreset, createDefaultPreset } from 'ts-jest';

const packageJson = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
const tsconfig = fileURLToPath(new URL('./tsconfig.json', import.meta.url));
const tsconfigPath = fileURLToPath(new URL('./tsconfig.json', import.meta.url));
const jestTsconfigPath = fileURLToPath(new URL('./tsconfig.jest.json', import.meta.url));
// The override lets tooling validate the ESM transform before the repository package type changes.
const useESM = packageJson.type === 'module' || process.env.JEST_USE_ESM === 'true';
const tsJestPreset = useESM
? createDefaultEsmPreset({ tsconfig })
: createDefaultPreset({ tsconfig });
? createDefaultEsmPreset({ tsconfig: tsconfigPath })
: createDefaultPreset({ tsconfig: tsconfigPath });
const commonProjectConfig = {
testEnvironment: 'node',
transformIgnorePatterns: ['/dist/.+\\.js'],
};

/**
* Defines a base project config that we can re-use across the project specific jest configs.
Expand All @@ -21,13 +26,23 @@ const tsJestPreset = useESM
/** @type {import('jest').Config} */
export const baseProjectConfig = {
...tsJestPreset,
testEnvironment: 'node',
transformIgnorePatterns: ['/dist/.+\\.js'],
...commonProjectConfig,
...(useESM
? {
moduleNameMapper: {
// TypeScript rewrites source .ts specifiers to .js before Jest resolves the source module.
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}
: {}),
};

// VS Code's packaged extension host strips the Node flag required by Jest's VM-module ESM runtime.
export const baseIntegrationProjectConfig = {
...createDefaultPreset({ tsconfig: jestTsconfigPath }),
...commonProjectConfig,
moduleNameMapper: {
// TypeScript rewrites source .ts specifiers to .js before Jest resolves the source module.
'^(\\.{1,2}/.*)\\.js$': '$1',
},
};
5 changes: 0 additions & 5 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ async function main() {
banner: {
js: [
`import { createRequire } from 'node:module';`,
`import { dirname as commonJsDirname } from 'node:path';`,
`import { fileURLToPath as commonJsFileURLToPath } from 'node:url';`,
`const require = createRequire(import.meta.url);`,
`// Temporary CommonJS globals until bundled source usages are converted to ESM.`,
`const __filename = commonJsFileURLToPath(import.meta.url);`,
`const __dirname = commonJsDirname(__filename);`,
].join('\n'),
},
minify: production,
Expand Down
10 changes: 9 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ const compatibleHeaderPlugin = fixupPluginRules({

export default defineConfig([
{
ignores: ['out/**', 'dist/**', 'wallaby.js', 'eslint.config.mjs', 'esbuild.mjs', '**/*.d.ts'],
ignores: [
'out/**',
'dist/**',
'.vscode-test/**',
'wallaby.js',
'eslint.config.mjs',
'esbuild.mjs',
'**/*.d.ts',
],
},
{
files: ['**/*.ts'],
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "csharp",
"publisher": "ms-dotnettools",
"version": "42.42.42-placeholder",
"type": "module",
"description": "Base language support for C#",
"displayName": "C#",
"author": "Microsoft Corporation",
Expand Down Expand Up @@ -78,9 +79,9 @@
"l10nDevGenerateXlf": "npx @vscode/l10n-dev generate-xlf ./package.nls.json ./l10n/bundle.l10n.json --outFile ./loc/vscode-csharp.xlf",
"l10nDevImportXlf": "npx @vscode/l10n-dev import-xlf ./loc/vscode-csharp.*.xlf --outDir ./l10n && move l10n\\package.nls.*.json .",
"lint": "npx eslint ./",
"omnisharptest": "npm run packageDev && npx tsx tasks/tests/omnisharptest.ts",
"omnisharptest:integration": "npm run packageDev && npx tsx tasks/tests/omnisharptestIntegration.ts",
"omnisharptest:unit": "npm run compileDev && npx tsx tasks/tests/omnisharptestUnit.ts",
"omnisharptest": "npm run packageDev && node --experimental-vm-modules --import tsx tasks/tests/omnisharptest.ts",
"omnisharptest:integration": "npm run packageDev && node --experimental-vm-modules --import tsx tasks/tests/omnisharptestIntegration.ts",
"omnisharptest:unit": "npm run compileDev && node --experimental-vm-modules --import tsx tasks/tests/omnisharptestUnit.ts",
"package": "npm run compile && node esbuild.mjs --production && npm run signJs",
"packageDev": "npm run compileDev && node esbuild.mjs",
"prepare": "npm run installDependencies",
Expand All @@ -90,13 +91,13 @@
"signJs": "npx tsx tasks/signing/signJs.ts",
"signVsix": "npx tsx tasks/signing/signVsix.ts",
"test": "npm run test:unit && npm run test:artifacts",
"test:artifacts": "npm run compileDev && npx tsx tasks/tests/testArtifacts.ts",
"test:artifacts": "npm run compileDev && node --experimental-vm-modules --import tsx tasks/tests/testArtifacts.ts",
"test:integration": "npm run test:integration:csharp && npm run test:integration:devkit && npm run test:integration:razor:cohost && npm run test:integration:untrusted",
"test:integration:csharp": "npm run packageDev && npx tsx tasks/tests/testIntegrationCsharp.ts",
"test:integration:devkit": "npm run packageDev && npx tsx tasks/tests/testIntegrationDevkit.ts",
"test:integration:razor:cohost": "npm run packageDev && npx tsx tasks/tests/testIntegrationRazorCohost.ts",
"test:integration:untrusted": "npm run packageDev && npx tsx tasks/tests/testIntegrationUntrusted.ts",
"test:unit": "npm run compileDev && npx tsx tasks/tests/testUnit.ts",
"test:integration:csharp": "npm run packageDev && node --experimental-vm-modules --import tsx tasks/tests/testIntegrationCsharp.ts",
"test:integration:devkit": "npm run packageDev && node --experimental-vm-modules --import tsx tasks/tests/testIntegrationDevkit.ts",
"test:integration:razor:cohost": "npm run packageDev && node --experimental-vm-modules --import tsx tasks/tests/testIntegrationRazorCohost.ts",
"test:integration:untrusted": "npm run packageDev && node --experimental-vm-modules --import tsx tasks/tests/testIntegrationUntrusted.ts",
"test:unit": "npm run compileDev && node --experimental-vm-modules --import tsx tasks/tests/testUnit.ts",
"updateChangelog": "npx tsx tasks/snap/updateChangelog.ts",
"updatePackageDependencies": "npx tsx tasks/debugger/updatePackageDependencies.ts",
"updateRoslynVersion": "npx tsx tasks/packaging/updateRoslynVersion.ts",
Expand Down Expand Up @@ -160,7 +161,7 @@
"tmp": "0.2.7",
"ts-jest": "^29.4.1",
"tsx": "^4.20.6",
"typescript": "5.6.2",
"typescript": "5.7.3",
"typescript-eslint": "^8.65.0",
"vscode-oniguruma": "^1.6.1",
"vscode-textmate": "^6.0.0"
Expand Down
18 changes: 9 additions & 9 deletions src/activateOmniSharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { OmnisharpExtensionExports } from './csharpExtensionExports';
import { PlatformInformation } from './shared/platform';
import { OmnisharpExtensionExports } from './csharpExtensionExports.ts';
import { PlatformInformation } from './shared/platform.ts';
import { Observable } from 'rxjs';
import { NetworkSettingsProvider } from './networkSettings';
import TelemetryReporter from '@vscode/extension-telemetry';
import { activateOmniSharpLanguageServer } from './omnisharp/omnisharpLanguageServer';
import { EventStream } from './eventStream';
import { razorOptions } from './shared/options';
import { activateRazorOmniSharpExtension } from './razor/razorOmnisharp';
import { NetworkSettingsProvider } from './networkSettings.ts';
import { ITelemetryReporter } from './shared/telemetryReporter.ts';
import { activateOmniSharpLanguageServer } from './omnisharp/omnisharpLanguageServer.ts';
import { EventStream } from './eventStream.ts';
import { razorOptions } from './shared/options.ts';
import { activateRazorOmniSharpExtension } from './razor/razorOmnisharp.ts';

export function activateOmniSharp(
context: vscode.ExtensionContext,
Expand All @@ -21,7 +21,7 @@ export function activateOmniSharp(
networkSettingsProvider: NetworkSettingsProvider,
eventStream: EventStream,
csharpChannel: vscode.OutputChannel,
reporter: TelemetryReporter,
reporter: ITelemetryReporter,
getCoreClrDebugPromise: (languageServerStarted: Promise<any>) => Promise<void>
): OmnisharpExtensionExports {
// activate language services
Expand Down
40 changes: 20 additions & 20 deletions src/activateRoslyn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { CSharpExtensionExports } from './csharpExtensionExports';
import { PlatformInformation } from './shared/platform';
import { CSharpExtensionExports } from './csharpExtensionExports.ts';
import { PlatformInformation } from './shared/platform.ts';
import { Observable } from 'rxjs';
import { EventStream } from './eventStream';
import TelemetryReporter from '@vscode/extension-telemetry';
import { RoslynLanguageServer } from './lsptoolshost/server/roslynLanguageServer';
import { CSharpDevKitExports } from './csharpDevKitExports';
import { RoslynLanguageServerEvents, ServerState } from './lsptoolshost/server/languageServerEvents';
import { activateRoslynLanguageServer, createCaptureActivityLogs } from './lsptoolshost/activate';
import Descriptors from './lsptoolshost/solutionSnapshot/descriptors';
import { getBrokeredServiceContainer } from './lsptoolshost/serviceBroker/brokeredServicesHosting';
import { debugSessionTracker } from './coreclrDebug/provisionalDebugSessionTracker';
import { RoslynLanguageServerExport } from './lsptoolshost/extensions/roslynLanguageServerExportChannel';
import { BlazorDebugConfigurationProvider } from './razor/src/blazorDebug/blazorDebugConfigurationProvider';
import { languageServerOptions } from './shared/options';
import { csharpDevkitExtensionId } from './utils/getCSharpDevKit';
import { EventStream } from './eventStream.ts';
import { ITelemetryReporterWithLevel } from './shared/telemetryReporter.ts';
import { RoslynLanguageServer } from './lsptoolshost/server/roslynLanguageServer.ts';
import { CSharpDevKitExports } from './csharpDevKitExports.ts';
import { RoslynLanguageServerEvents, ServerState } from './lsptoolshost/server/languageServerEvents.ts';
import { activateRoslynLanguageServer, createCaptureActivityLogs } from './lsptoolshost/activate.ts';
import Descriptors from './lsptoolshost/solutionSnapshot/descriptors.ts';
import { getBrokeredServiceContainer } from './lsptoolshost/serviceBroker/brokeredServicesHosting.ts';
import { debugSessionTracker } from './coreclrDebug/provisionalDebugSessionTracker.ts';
import { RoslynLanguageServerExport } from './lsptoolshost/extensions/roslynLanguageServerExportChannel.ts';
import { BlazorDebugConfigurationProvider } from './razor/src/blazorDebug/blazorDebugConfigurationProvider.ts';
import { languageServerOptions } from './shared/options.ts';
import { csharpDevkitExtensionId } from './utils/getCSharpDevKit.ts';
import { GlobalBrokeredServiceContainer } from '@microsoft/servicehub-framework';
import { SolutionSnapshotProvider } from './lsptoolshost/solutionSnapshot/solutionSnapshotProvider';
import { BuildResultDiagnostics } from './lsptoolshost/diagnostics/buildResultReporterService';
import { getComponentFolder } from './lsptoolshost/extensions/builtInComponents';
import { ObservableLogOutputChannel } from './lsptoolshost/logging/observableLogOutputChannel';
import { SolutionSnapshotProvider } from './lsptoolshost/solutionSnapshot/solutionSnapshotProvider.ts';
import { BuildResultDiagnostics } from './lsptoolshost/diagnostics/buildResultReporterService.ts';
import { getComponentFolder } from './lsptoolshost/extensions/builtInComponents.ts';
import { ObservableLogOutputChannel } from './lsptoolshost/logging/observableLogOutputChannel.ts';

export function activateRoslyn(
context: vscode.ExtensionContext,
platformInfo: PlatformInformation,
optionStream: Observable<void>,
eventStream: EventStream,
csharpChannel: vscode.LogOutputChannel,
reporter: TelemetryReporter,
reporter: ITelemetryReporterWithLevel,
csharpDevkitExtension: vscode.Extension<CSharpDevKitExports> | undefined,
getCoreClrDebugPromise: (languageServerStarted: Promise<any>) => Promise<void>
): CSharpExtensionExports {
Expand Down
4 changes: 2 additions & 2 deletions src/checkSupportedPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { PlatformInformation } from './shared/platform';
import { ActionOption, showErrorMessage } from './shared/observers/utils/showMessage';
import { PlatformInformation } from './shared/platform.ts';
import { ActionOption, showErrorMessage } from './shared/observers/utils/showMessage.ts';

export function checkIsSupportedPlatform(context: vscode.ExtensionContext, platformInfo: PlatformInformation): boolean {
if (!isSupportedPlatform(platformInfo)) {
Expand Down
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as cp from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { AbsolutePath } from './packageManager/absolutePath';
import { AbsolutePath } from './packageManager/absolutePath.ts';

let extensionPath: string;

Expand Down
2 changes: 1 addition & 1 deletion src/compositeDisposable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Subscription } from 'rxjs';
import Disposable, { IDisposable } from './disposable';
import Disposable, { IDisposable } from './disposable.ts';

export default class CompositeDisposable extends Disposable {
private disposables = new Subscription();
Expand Down
Loading
Loading