Skip to content

Commit 33b1f66

Browse files
authored
Restored debugger support, using the MIT-licensed netcoredbg. (#4)
1 parent 49d4028 commit 33b1f66

File tree

8 files changed

+132
-35
lines changed

8 files changed

+132
-35
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# free-omnisharp-vscode
22

3-
C# extension for vscode-compatible editors **without** the debugger.
3+
C# extension for vscode-compatible editors.
44

55
## Why?
66
The debugger included in the official C# extension is [proprietary](https://aka.ms/VSCode-DotNet-DbgLicense) and is licensed to only work with Microsoft versions of vscode.
7+
This extension replaces it with a [custom version](https://github.com/jamsilva/netcoredbg) of [Samsung's MIT-licensed alternative](https://github.com/Samsung/netcoredbg/blob/master/LICENSE).
78

89
## Installation:
9-
this extension is published at [open-vsx.org](https://open-vsx.org/extension/muhammad-sammy/csharp).
10+
This extension is published at [open-vsx.org](https://open-vsx.org/extension/muhammad-sammy/csharp).
1011

1112
### Build from source:
1213
Requirements:
@@ -20,6 +21,8 @@ cd free-omnisharp-vscode
2021
2122
npm install
2223
24+
npm run compile
25+
2326
vsce package
2427
```
2528
then run `Extensions: Install from VSIX` from the command pallete and select the `csharp-VERSION_NUMBER.vsix` file.

RuntimeLicenses/license.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Omnisharp
2+
https://github.com/OmniSharp/omnisharp-vscode/blob/master/LICENSE.txt
23

34
MIT License
45

@@ -22,6 +23,34 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2223
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2324
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2425
SOFTWARE.
26+
27+
-------------------------------------------------------------------------------
28+
29+
netcoredbg
30+
https://github.com/Samsung/netcoredbg/blob/master/LICENSE
31+
32+
MIT License
33+
34+
Copyright (c) 2017 Samsung Electronics Co., LTD
35+
36+
Permission is hereby granted, free of charge, to any person obtaining a copy
37+
of this software and associated documentation files (the "Software"), to deal
38+
in the Software without restriction, including without limitation the rights
39+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40+
copies of the Software, and to permit persons to whom the Software is
41+
furnished to do so, subject to the following conditions:
42+
43+
The above copyright notice and this permission notice shall be included in all
44+
copies or substantial portions of the Software.
45+
46+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52+
SOFTWARE.
53+
2554
-------------------------------------------------------------------------------
2655

2756
Razor Language Server

debugger-launchjson.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ The debugger steps over properties and operators in managed code by default. In
166166
You can optionally enable or disable messages that should be logged to the output window. The flags in the logging field are: 'exceptions', 'moduleLoad', 'programOutput', 'engineLogging', and 'browserStdOut'.
167167

168168
## PipeTransport
169-
If you need to have the debugger to connect to a remote computer using another executable to relay standard input and output bewteen VS Code and the .NET Core debugger backend (vsdbg),
169+
If you need to have the debugger to connect to a remote computer using another executable to relay standard input and output bewteen VS Code and the .NET Core debugger backend (netcoredbg),
170170
then add the pipeTransport field folloing this schema:
171171

172172
"pipeTransport": {
173173
"pipeProgram": "ssh",
174174
"pipeArgs": [ "-T", "ExampleAccount@ExampleTargetComputer" ],
175-
"debuggerPath": "~/vsdbg/vsdbg",
175+
"debuggerPath": "/usr/bin/netcoredbg",
176176
"pipeCwd": "${workspaceFolder}",
177177
"quoteArgs": true
178178
}

package.json

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
},
193193
{
194194
"id": "OmniSharp",
195-
"description": "OmniSharp for OSX",
195+
"description": "OmniSharp for macOS",
196196
"url": "https://download.visualstudio.microsoft.com/download/pr/629d3d3b-feb3-4034-a8f7-3262b4bcdace/f57fe2aed239711c69cda6c82ee7a2bf/omnisharp-osx-1.37.2.zip",
197197
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.2/omnisharp-osx-1.37.2.zip",
198198
"installPath": ".omnisharp/1.37.2",
@@ -248,6 +248,51 @@
248248
"platformId": "linux-x64",
249249
"integrity": "41A1111915AA66224174B561FA70B1C88340AA5D9FEBC8B8583B19B68F8A4F00"
250250
},
251+
{
252+
"id": "Debugger",
253+
"description": ".NET Core Debugger (Windows / x64)",
254+
"url": "https://github.com/jamsilva/netcoredbg/releases/download/latest/netcoredbg-win64-master.zip",
255+
"installPath": ".debugger",
256+
"platforms": [
257+
"win32"
258+
],
259+
"architectures": [
260+
"x86_64"
261+
],
262+
"installTestPath": ".debugger/netcoredbg/netcoredbg.exe"
263+
},
264+
{
265+
"id": "Debugger",
266+
"description": ".NET Core Debugger (macOS / x64)",
267+
"url": "https://github.com/jamsilva/netcoredbg/releases/download/latest/netcoredbg-osx-master.zip",
268+
"installPath": ".debugger",
269+
"platforms": [
270+
"darwin"
271+
],
272+
"architectures": [
273+
"x86_64"
274+
],
275+
"binaries": [
276+
"netcoredbg/netcoredbg"
277+
],
278+
"installTestPath": ".debugger/netcoredbg/netcoredbg"
279+
},
280+
{
281+
"id": "Debugger",
282+
"description": ".NET Core Debugger (linux / x64)",
283+
"url": "https://github.com/jamsilva/netcoredbg/releases/download/latest/netcoredbg-linux-master.zip",
284+
"installPath": ".debugger",
285+
"platforms": [
286+
"linux"
287+
],
288+
"architectures": [
289+
"x86_64"
290+
],
291+
"binaries": [
292+
"netcoredbg/netcoredbg"
293+
],
294+
"installTestPath": ".debugger/netcoredbg/netcoredbg"
295+
},
251296
{
252297
"id": "Razor",
253298
"description": "Razor Language Server (Windows / x64)",
@@ -1174,7 +1219,7 @@
11741219
}
11751220
},
11761221
"pipeTransport": {
1177-
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (vsdbg).",
1222+
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (netcoredbg).",
11781223
"type": "object",
11791224
"required": [
11801225
"debuggerPath"
@@ -1183,7 +1228,7 @@
11831228
"pipeCwd": "${workspaceFolder}",
11841229
"pipeProgram": "enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'",
11851230
"pipeArgs": [],
1186-
"debuggerPath": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
1231+
"debuggerPath": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
11871232
},
11881233
"properties": {
11891234
"pipeCwd": {
@@ -1217,7 +1262,7 @@
12171262
"debuggerPath": {
12181263
"type": "string",
12191264
"description": "The full path to the debugger on the target machine.",
1220-
"default": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
1265+
"default": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
12211266
},
12221267
"pipeEnv": {
12231268
"type": "object",
@@ -1606,7 +1651,7 @@
16061651
}
16071652
},
16081653
"pipeTransport": {
1609-
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (vsdbg).",
1654+
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (netcoredbg).",
16101655
"type": "object",
16111656
"required": [
16121657
"debuggerPath"
@@ -1615,7 +1660,7 @@
16151660
"pipeCwd": "${workspaceFolder}",
16161661
"pipeProgram": "enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'",
16171662
"pipeArgs": [],
1618-
"debuggerPath": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
1663+
"debuggerPath": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
16191664
},
16201665
"properties": {
16211666
"pipeCwd": {
@@ -1649,7 +1694,7 @@
16491694
"debuggerPath": {
16501695
"type": "string",
16511696
"description": "The full path to the debugger on the target machine.",
1652-
"default": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
1697+
"default": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
16531698
},
16541699
"pipeEnv": {
16551700
"type": "object",
@@ -2004,7 +2049,7 @@
20042049
"pipeCwd": "^\"\\${workspaceFolder}\"",
20052050
"pipeProgram": "^\"${3:enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'}\"",
20062051
"pipeArgs": [],
2007-
"debuggerPath": "^\"${4:enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg}\""
2052+
"debuggerPath": "^\"${4:enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg}\""
20082053
}
20092054
}
20102055
},
@@ -2020,7 +2065,7 @@
20202065
"pipeCwd": "^\"\\${workspaceFolder}\"",
20212066
"pipeProgram": "^\"${1:enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'}\"",
20222067
"pipeArgs": [],
2023-
"debuggerPath": "^\"${2:enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg}\""
2068+
"debuggerPath": "^\"${2:enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg}\""
20242069
}
20252070
}
20262071
}
@@ -2271,7 +2316,7 @@
22712316
}
22722317
},
22732318
"pipeTransport": {
2274-
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (vsdbg).",
2319+
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (netcoredbg).",
22752320
"type": "object",
22762321
"required": [
22772322
"debuggerPath"
@@ -2280,7 +2325,7 @@
22802325
"pipeCwd": "${workspaceFolder}",
22812326
"pipeProgram": "enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'",
22822327
"pipeArgs": [],
2283-
"debuggerPath": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
2328+
"debuggerPath": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
22842329
},
22852330
"properties": {
22862331
"pipeCwd": {
@@ -2314,7 +2359,7 @@
23142359
"debuggerPath": {
23152360
"type": "string",
23162361
"description": "The full path to the debugger on the target machine.",
2317-
"default": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
2362+
"default": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
23182363
},
23192364
"pipeEnv": {
23202365
"type": "object",
@@ -2703,7 +2748,7 @@
27032748
}
27042749
},
27052750
"pipeTransport": {
2706-
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (vsdbg).",
2751+
"description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the .NET Core debugger backend executable (netcoredbg).",
27072752
"type": "object",
27082753
"required": [
27092754
"debuggerPath"
@@ -2712,7 +2757,7 @@
27122757
"pipeCwd": "${workspaceFolder}",
27132758
"pipeProgram": "enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'",
27142759
"pipeArgs": [],
2715-
"debuggerPath": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
2760+
"debuggerPath": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
27162761
},
27172762
"properties": {
27182763
"pipeCwd": {
@@ -2746,7 +2791,7 @@
27462791
"debuggerPath": {
27472792
"type": "string",
27482793
"description": "The full path to the debugger on the target machine.",
2749-
"default": "enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg"
2794+
"default": "enter the path for the debugger on the target machine, for example /usr/bin/netcoredbg"
27502795
},
27512796
"pipeEnv": {
27522797
"type": "object",

src/coreclr-debug/activate.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,23 @@ import { DotnetInfo } from '../utils/getDotnetInfo';
1616

1717
let _debugUtil: CoreClrDebugUtil = null;
1818

19-
export async function activate(thisExtension: vscode.Extension<CSharpExtensionExports>, context: vscode.ExtensionContext, platformInformation: PlatformInformation, eventStream: EventStream) { }
19+
export async function activate(thisExtension: vscode.Extension<CSharpExtensionExports>, context: vscode.ExtensionContext, platformInformation: PlatformInformation, eventStream: EventStream) {
20+
_debugUtil = new CoreClrDebugUtil(context.extensionPath);
21+
22+
if (!CoreClrDebugUtil.existsSync(_debugUtil.debugAdapterDir())) {
23+
let isInvalidArchitecture: boolean = await checkForInvalidArchitecture(platformInformation, eventStream);
24+
if (!isInvalidArchitecture) {
25+
eventStream.post(new DebuggerPrerequisiteFailure("[ERROR]: C# Extension failed to install the debugger package."));
26+
showInstallErrorMessage(eventStream);
27+
}
28+
} else if (!CoreClrDebugUtil.existsSync(_debugUtil.installCompleteFilePath())) {
29+
completeDebuggerInstall(platformInformation, eventStream);
30+
}
31+
32+
const factory = new DebugAdapterExecutableFactory(platformInformation, eventStream, thisExtension.packageJSON, thisExtension.extensionPath);
33+
context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory('coreclr', factory));
34+
context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory('clr', factory));
35+
}
2036

2137
async function checkForInvalidArchitecture(platformInformation: PlatformInformation, eventStream: EventStream): Promise<boolean> {
2238
if (platformInformation) {
@@ -64,6 +80,11 @@ async function completeDebuggerInstall(platformInformation: PlatformInformation,
6480
});
6581
}
6682

83+
function showInstallErrorMessage(eventStream: EventStream) {
84+
eventStream.post(new DebuggerNotInstalledFailure());
85+
vscode.window.showErrorMessage("An error occurred during installation of the .NET Core Debugger. The C# extension may need to be reinstalled.");
86+
}
87+
6788
function showDotnetToolsWarning(message: string): void {
6889
const config = vscode.workspace.getConfiguration('csharp');
6990
if (!config.get('suppressDotnetInstallWarning', false)) {
@@ -133,11 +154,11 @@ export class DebugAdapterExecutableFactory implements vscode.DebugAdapterDescrip
133154

134155
// use the executable specified in the package.json if it exists or determine it based on some other information (e.g. the session)
135156
if (!executable) {
136-
const command = path.join(common.getExtensionPath(), ".debugger", "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension());
157+
const command = path.join(common.getExtensionPath(), ".debugger", "netcoredbg", "netcoredbg" + CoreClrDebugUtil.getPlatformExeExtension());
137158
executable = new vscode.DebugAdapterExecutable(command);
138159
}
139160

140161
// make VS Code launch the DA executable
141162
return executable;
142163
}
143-
}
164+
}

src/coreclr-debug/debuggerEventsProtocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
// This contains the definition of messages that VsDbg-UI can send back to a listener which registers itself via the 'debuggerEventsPipeName'
6+
// This contains the definition of messages that netcoredbg can send back to a listener which registers itself via the 'debuggerEventsPipeName'
77
// property on a launch or attach request.
88
//
99
// All messages are sent as UTF-8 JSON text with a tailing '\n'
1010
export namespace DebuggerEventsProtocol {
1111
export module EventType {
12-
// Indicates that the vsdbg-ui has received the attach or launch request and is starting up
12+
// Indicates that the netcoredbg has received the attach or launch request and is starting up
1313
export const Starting = "starting";
14-
// Indicates that vsdbg-ui has successfully launched the specified process.
14+
// Indicates that netcoredbg has successfully launched the specified process.
1515
// The ProcessLaunchedEvent interface details the event payload.
1616
export const ProcessLaunched = "processLaunched";
1717
// Debug session is ending
@@ -38,4 +38,4 @@ export namespace DebuggerEventsProtocol {
3838
const message = packet.toString('utf-8', 0, packet.length - 1);
3939
return JSON.parse(message);
4040
}
41-
}
41+
}

0 commit comments

Comments
 (0)