Skip to content

Commit

Permalink
Merged PR 467493: Clean up double debugConfigurationProvider
Browse files Browse the repository at this point in the history
Clean up double debugConfigurationProvider

# Why
When adding support for the new attach to process drop down,
a secondary debugConfigurationProvider was created instead
of extending off of the existing one.

Related PR: dotnet#4509

# Changes

This PR refactors DebugConfigurationProvider.ts into two classes.

The new `BaseVsDbgConfigurationProvider` (originally the `DotnetDebugConfigurationProvider`) will be used for resolving the debug configuration for the debug adapter without any workspace information.

Providers that will provide initial configurations can extend off of this base class, such as the `DotnetWorkspaceConfigurationProvider` (originally the `CSharpConfigurationProvider`)
which is used by the Omnisharp and Roslyn LSP.

DotnetWorkspaceConfigurationProvider uses
IWorkspaceDebugInformationProvider to provide initial configurations.

Other notes:
- Also ran formatting on configurationProvider.ts because the open brace
style was mixed.
- Also removed DevCertCreationFailure

# Testing
I validated:
- [x] `dotnet.generateAssets` works.
- [x] F5 debug with no .vscode will generate assets.
- [x] Web launch will still ask for cert.
  • Loading branch information
WardenGnaw committed Apr 27, 2023
1 parent 0042992 commit c184cb8
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 296 deletions.
10 changes: 6 additions & 4 deletions src/coreclr-debug/activate.ts
Expand Up @@ -12,14 +12,16 @@ import { DebuggerPrerequisiteWarning, DebuggerPrerequisiteFailure, DebuggerNotIn
import { EventStream } from '../EventStream';
import { getRuntimeDependencyPackageWithId } from '../tools/RuntimeDependencyPackageUtils';
import { getDotnetInfo } from '../utils/getDotnetInfo';
import { DotnetDebugConfigurationProvider } from './debugConfigurationProvider';
import { Options } from '../shared/options';
import { RemoteAttachPicker } from '../features/processPicker';
import CompositeDisposable from '../CompositeDisposable';
import { BaseVsDbgConfigurationProvider } from '../shared/configurationProvider';
import OptionProvider from '../shared/observers/OptionProvider';

export async function activate(thisExtension: vscode.Extension<any>, context: vscode.ExtensionContext, platformInformation: PlatformInformation, eventStream: EventStream, options: Options) {
export async function activate(thisExtension: vscode.Extension<any>, context: vscode.ExtensionContext, platformInformation: PlatformInformation, eventStream: EventStream, csharpOutputChannel: vscode.OutputChannel, optionProvider: OptionProvider) {
let disposables = new CompositeDisposable();

const options: Options = optionProvider.GetLatestOptions();
const debugUtil = new CoreClrDebugUtil(context.extensionPath);

if (!CoreClrDebugUtil.existsSync(debugUtil.debugAdapterDir())) {
Expand Down Expand Up @@ -59,8 +61,8 @@ export async function activate(thisExtension: vscode.Extension<any>, context: vs
}));

const factory = new DebugAdapterExecutableFactory(debugUtil, platformInformation, eventStream, thisExtension.packageJSON, thisExtension.extensionPath, options);
disposables.add(vscode.debug.registerDebugConfigurationProvider('coreclr', new DotnetDebugConfigurationProvider(platformInformation, eventStream, options)));
disposables.add(vscode.debug.registerDebugConfigurationProvider('clr', new DotnetDebugConfigurationProvider(platformInformation, eventStream, options)));
/** 'clr' type does not have a intial configuration provider, but we need to register it to support the common debugger features listed in {@link BaseVsDbgConfigurationProvider} */
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('clr', new BaseVsDbgConfigurationProvider(platformInformation, optionProvider, csharpOutputChannel)));
disposables.add(vscode.debug.registerDebugAdapterDescriptorFactory('coreclr', factory));
disposables.add(vscode.debug.registerDebugAdapterDescriptorFactory('clr', factory));

Expand Down
186 changes: 0 additions & 186 deletions src/coreclr-debug/debugConfigurationProvider.ts

This file was deleted.

8 changes: 5 additions & 3 deletions src/lsptoolshost/debugger.ts
Expand Up @@ -6,12 +6,14 @@
import * as vscode from 'vscode';
import { State } from 'vscode-languageclient/node';
import { addAssetsIfNecessary, generateAssets } from '../shared/assets';
import { CSharpConfigurationProvider } from '../shared/configurationProvider';
import { DotnetWorkspaceConfigurationProvider } from '../shared/workspaceConfigurationProvider';
import { IWorkspaceDebugInformationProvider } from '../shared/IWorkspaceDebugInformationProvider';
import { RoslynLanguageServer } from './roslynLanguageServer';
import { RoslynWorkspaceDebugInformationProvider } from './RoslynWorkspaceDebugConfigurationProvider';
import { PlatformInformation } from '../shared/platform';
import OptionProvider from '../shared/observers/OptionProvider';

export function registerDebugger(context: vscode.ExtensionContext, languageServer: RoslynLanguageServer) {
export function registerDebugger(context: vscode.ExtensionContext, languageServer: RoslynLanguageServer, platformInfo: PlatformInformation, optionProvider: OptionProvider, csharpOutputChannel: vscode.OutputChannel) {
let workspaceInformationProvider: IWorkspaceDebugInformationProvider = new RoslynWorkspaceDebugInformationProvider(languageServer);

// TODO - we need to respond to some kind of actual load events for two reasons
Expand All @@ -26,6 +28,6 @@ export function registerDebugger(context: vscode.ExtensionContext, languageServe
context.subscriptions.push(disposable);

// Register ConfigurationProvider
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('coreclr', new CSharpConfigurationProvider(workspaceInformationProvider)));
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('coreclr', new DotnetWorkspaceConfigurationProvider(workspaceInformationProvider, platformInfo, optionProvider, csharpOutputChannel)));
context.subscriptions.push(vscode.commands.registerCommand('dotnet.generateAssets', async (selectedIndex) => generateAssets(workspaceInformationProvider, selectedIndex)));
}
8 changes: 4 additions & 4 deletions src/lsptoolshost/roslynLanguageServer.ts
Expand Up @@ -438,22 +438,22 @@ export class SolutionSnapshotProvider implements ISolutionSnapshotProvider {
}
}

export async function activateRoslynLanguageServer(context: vscode.ExtensionContext, platformInfo: PlatformInformation, optionsProvider: OptionProvider, outputChannel: vscode.OutputChannel) {
export async function activateRoslynLanguageServer(context: vscode.ExtensionContext, platformInfo: PlatformInformation, optionProvider: OptionProvider, outputChannel: vscode.OutputChannel) {

// Create a channel for outputting general logs from the language server.
_channel = outputChannel;
// Create a separate channel for outputting trace logs - these are incredibly verbose and make other logs very difficult to see.
_traceChannel = vscode.window.createOutputChannel("C# LSP Trace Logs");

_languageServer = new RoslynLanguageServer(platformInfo, optionsProvider, context);
_languageServer = new RoslynLanguageServer(platformInfo, optionProvider, context);

// Register any commands that need to be handled by the extension.
registerCommands(context, _languageServer);

// Register any needed debugger components that need to communicate with the language server.
registerDebugger(context, _languageServer);
registerDebugger(context, _languageServer, platformInfo, optionProvider, _channel);

let options = optionsProvider.GetLatestOptions();
let options = optionProvider.GetLatestOptions();
let source = new vscode.CancellationTokenSource();
vscode.workspace.onDidChangeTextDocument(async e => {
if (!options.languageServerOptions.documentSelector.includes(e.document.languageId))
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Expand Up @@ -223,7 +223,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
let coreClrDebugPromise = Promise.resolve();
if (runtimeDependenciesExist) {
// activate coreclr-debug
coreClrDebugPromise = coreclrdebug.activate(context.extension, context, platformInfo, eventStream, optionProvider.GetLatestOptions());
coreClrDebugPromise = coreclrdebug.activate(context.extension, context, platformInfo, eventStream, csharpChannel, optionProvider);
}

if (!useOmnisharpServer) {
Expand Down
2 changes: 1 addition & 1 deletion src/omnisharp/EventType.ts
Expand Up @@ -85,7 +85,7 @@ export enum EventType {
TelemetryErrorEvent = 78,
OmnisharpServerRequestCancelled = 79,
BackgroundDiagnosticStatus = 80,
DevCertCreationFailure = 81,
// DevCertCreationFailure = 81, Removed as we push to output channel directly
ShowChannel = 82,
}

Expand Down
4 changes: 2 additions & 2 deletions src/omnisharp/extension.ts
Expand Up @@ -7,7 +7,7 @@ import * as utils from './utils';
import * as vscode from 'vscode';
import { addAssetsIfNecessary } from '../shared/assets';
import { safeLength, sum } from '../common';
import { CSharpConfigurationProvider } from '../shared/configurationProvider';
import { DotnetWorkspaceConfigurationProvider } from '../shared/workspaceConfigurationProvider';
import { OmniSharpServer } from './server';
import TestManager from '../features/dotnetTest';
import registerCommands from '../features/commands';
Expand Down Expand Up @@ -132,7 +132,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an
}));

// Register ConfigurationProvider
disposables.add(vscode.debug.registerDebugConfigurationProvider('coreclr', new CSharpConfigurationProvider(workspaceInformationProvider)));
disposables.add(vscode.debug.registerDebugConfigurationProvider('coreclr', new DotnetWorkspaceConfigurationProvider(workspaceInformationProvider, platformInfo, optionProvider, outputChannel)));

context.subscriptions.push(disposables);

Expand Down
4 changes: 0 additions & 4 deletions src/omnisharp/loggingEvents.ts
Expand Up @@ -350,10 +350,6 @@ export class DotNetTestDebugComplete implements BaseEvent {
export class DownloadValidation implements BaseEvent {
type = EventType.DownloadValidation;
}
export class DevCertCreationFailure implements BaseEvent {
type = EventType.DevCertCreationFailure;
constructor(public errorMessage: string) { }
}
export class ShowChannel implements BaseEvent {
type = EventType.ShowChannel;
}

0 comments on commit c184cb8

Please sign in to comment.