MCPcopy
hub / github.com/dotnet/vscode-csharp / activate

Function activate

src/main.ts:34–168  ·  view source on GitHub ↗
(
    context: vscode.ExtensionContext
)

Source from the content-addressed store, hash-verified

32import { LimitedActivationStatus } from './shared/limitedActivationStatus';
33
34export async function activate(
35 context: vscode.ExtensionContext
36): Promise<CSharpExtensionExports | OmnisharpExtensionExports | LimitedExtensionExports | null> {
37 // Start measuring the activation time
38 const startActivation = process.hrtime();
39
40 const csharpChannel = vscode.window.createOutputChannel('C#', { log: true });
41 csharpChannel.trace('Activating C# Extension');
42
43 util.setExtensionPath(context.extension.extensionPath);
44
45 const aiKey = context.extension.packageJSON.contributes.debuggers[0].aiKey;
46 const reporter = new TelemetryReporter(aiKey);
47 // ensure it gets properly disposed. Upon disposal the events will be flushed.
48 context.subscriptions.push(reporter);
49
50 const eventStream = new EventStream();
51 const csharpchannelObserver = new CsharpChannelObserver(csharpChannel);
52 const csharpLogObserver = new CsharpLoggerObserver(csharpChannel);
53 eventStream.subscribe(csharpchannelObserver.post);
54 eventStream.subscribe(csharpLogObserver.post);
55
56 let platformInfo: PlatformInformation;
57 try {
58 platformInfo = await PlatformInformation.GetCurrent();
59 } catch (error) {
60 eventStream.post(new ActivationFailure());
61 throw error;
62 }
63
64 // Verify that the current platform is supported by the extension and inform the user if not.
65 if (!checkIsSupportedPlatform(context, platformInfo)) {
66 return null;
67 }
68
69 await checkDotNetRuntimeExtensionVersion(context);
70
71 await MigrateOptions(vscode);
72 const optionStream = createOptionStream(vscode);
73
74 const requiredPackageIds: string[] = ['Debugger', 'Razor'];
75
76 const csharpDevkitExtension = getCSharpDevKit();
77 const useOmnisharpServer = !csharpDevkitExtension && commonOptions.useOmnisharpServer;
78 if (useOmnisharpServer) {
79 requiredPackageIds.push('OmniSharp');
80 }
81 requiredPackageIds.push('VSWebAssemblyBridge');
82 if (csharpDevkitExtension) {
83 requiredPackageIds.push('RoslynCopilot');
84 }
85
86 const networkSettingsProvider = vscodeNetworkSettingsProvider(vscode);
87 const useFramework = useOmnisharpServer && omnisharpOptions.useModernNet !== true;
88 const installDependencies: IInstallDependencies = async (dependencies: AbsolutePathPackage[]) =>
89 downloadAndInstallPackages(dependencies, networkSettingsProvider, eventStream, isValidDownload, reporter);
90
91 const runtimeDependenciesExist = await installRuntimeDependencies(

Callers

nothing calls this directly

Calls 15

subscribeMethod · 0.95
postMethod · 0.95
checkIsSupportedPlatformFunction · 0.90
MigrateOptionsFunction · 0.90
getCSharpDevKitFunction · 0.90
activateRoslynFunction · 0.90
activateOmniSharpFunction · 0.90
createOptionStreamFunction · 0.85
traceMethod · 0.80

Tested by

no test coverage detected