Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ crate-type = ["cdylib"]

[dependencies]
zed_extension_api = "0.7.0"
serde = { version = "1.0", features = ["derive"] }
fs_extra = "1.3.0"
116 changes: 116 additions & 0 deletions debug_adapter_schemas/netcoredbg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Zed NetCoreDbg Debug Adapter Protocol Configuration",
"description": "JSON schema for netcoredbg debug adapter protocol launch and attach configurations",
"type": "object",
"properties": {
"request": {
"type": "string",
"enum": [
"launch",
"attach"
],
"description": "The request type - either 'launch' to start a new process or 'attach' to connect to an existing process"
}
},
"required": [
"request"
],
"allOf": [
{
"if": {
"properties": {
"request": {
"const": "launch"
}
}
},
"then": {
"properties": {
"request": true,
"program": {
"type": "string",
"pattern": "\\.(dll|exe)$",
"description": "Path to the executable assembly (.dll or .exe) to launch. This is the main entry point of your .NET application. NetCoreDbg will use 'dotnet' as the runtime and pass this as the first argument."
},
"args": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Command line arguments to pass to the program. These arguments are appended after the program path when launching with 'dotnet'."
},
"cwd": {
"type": "string",
"description": "Working directory for the launched process. This is crucial for .NET applications as it determines where configuration files (like appsettings.json), relative file paths, and other resources are resolved from. For ASP.NET Core apps, this affects content root discovery and static file serving. If not specified, defaults to the workspace root directory.",
"default": "${ZED_WORKTREE_ROOT}"
},
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"default": {},
"description": "Environment variables to set for the launched process. These are key-value pairs that will be available to your application at runtime."
},
"stopAtEntry": {
"type": "boolean",
"default": false,
"description": "Whether to stop at the entry point (main method) of the program. When true, the debugger will break at the first line of user code, allowing you to step through from the very beginning."
},
"justMyCode": {
"type": "boolean",
"default": true,
"description": "Enable Just My Code debugging. When true, the debugger will only step through and break in user-written code, skipping framework and library code. This matches the default behavior of Microsoft's vsdbg."
},
"enableStepFiltering": {
"type": "boolean",
"default": true,
"description": "Enable step filtering to automatically step over properties, operators, and other code constructs that are typically not interesting during debugging. This matches the default behavior of Microsoft's vsdbg."
},
"tcp_connection": {
"type": "string",
"default": "localhost:4711",
"description": "TCP Connection to connect with to netcoredbg"
}
},
"required": [
"program"
]
}
},
{
"if": {
"properties": {
"request": {
"const": "attach"
}
}
},
"then": {
"properties": {
"request": true,
"processId": {
"oneOf": [
{
"type": "integer",
"minimum": 1,
"description": "Numeric process ID to attach to"
},
{
"type": "string",
"pattern": "^[0-9]+$",
"description": "String representation of process ID to attach to"
}
],
"description": "The process ID of the running .NET application to attach to. Can be specified as a number or string representation of a number. The target process must be a .NET Core application with debugging enabled."
}
},
"required": [
"processId"
]
}
}
]
}
15 changes: 15 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,23 @@ language = "CSharp"
repository = "https://github.com/tree-sitter/tree-sitter-c-sharp"
commit = "485f0bae0274ac9114797fc10db6f7034e4086e3"

[debug_adapters.netcoredbg]
schema_path = "debug_adapter_schemas/netcoredbg.json"

[debug_locators.csharp-test-runner]

# Used to run `csharp-language-server --download` after an update
[[capabilities]]
kind = "process:exec"
command = "*"
args = ["--download"]

[[capabilities]]
kind = "download_file"
host = "github.com"
path = ["qwadrox", "netcoredbg", "**"]

[[capabilities]]
kind = "download_file"
host = "objects.githubusercontent.com"
path = ["**"]
1 change: 1 addition & 0 deletions languages/csharp/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ brackets = [
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
{ start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },
]
debuggers = ["netcoredbg"]
100 changes: 100 additions & 0 deletions languages/csharp/runnables.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
; =========================
; Test method with namespace
; =========================
(
(namespace_declaration
name: (_) @csharp_namespace
body: (declaration_list
(class_declaration
name: (identifier) @csharp_class_name @csharp_csproj_hint
body: (declaration_list
(method_declaration
(attribute_list
(attribute
name: (_) @attribute_name
(#match? @attribute_name "^(Fact|Theory|Test|TestCase|TestCaseSource|TestMethod|DataTestMethod)$")))
name: (identifier) @run @csharp_method_name)))))
(#set! tag csharp-test-method)
)

; ======================================
; Test method with file-scoped namespace
; ======================================
(
(file_scoped_namespace_declaration
name: (_) @csharp_namespace
(class_declaration
name: (identifier) @csharp_class_name @csharp_csproj_hint
body: (declaration_list
(method_declaration
(attribute_list
(attribute
name: (_) @attribute_name
(#match? @attribute_name "^(Fact|Theory|Test|TestCase|TestCaseSource|TestMethod|DataTestMethod)$")))
name: (identifier) @run @csharp_method_name))))
(#set! tag csharp-test-method)
)

; ============================
; Test method without namespace
; (anchored to top-level only)
; ============================
(
(compilation_unit
(class_declaration
name: (identifier) @csharp_class_name @csharp_csproj_hint
body: (declaration_list
(method_declaration
(attribute_list
(attribute
name: (_) @attribute_name
(#match? @attribute_name "^(Fact|Theory|Test|TestCase|TestCaseSource|TestMethod|DataTestMethod)$")))
name: (identifier) @run @csharp_method_name))))
(#set! tag csharp-test-method)
)

; ===============================
; Test class with namespace
; ===============================
(
(namespace_declaration
name: (_) @csharp_namespace
body: (declaration_list
(class_declaration
(attribute_list
(attribute
name: (_) @class_attribute
(#match? @class_attribute "^(TestFixture|TestClass)$")))
name: (identifier) @run @csharp_class_name)))
(#set! tag csharp-test-class)
)

; =====================================
; Test class with file-scoped namespace
; =====================================
(
(file_scoped_namespace_declaration
name: (_) @csharp_namespace
(class_declaration
(attribute_list
(attribute
name: (_) @class_attribute
(#match? @class_attribute "^(TestFixture|TestClass)$")))
name: (identifier) @run @csharp_class_name))
(#set! tag csharp-test-class)
)

; ==============================
; Test class without namespace
; (anchored to top-level only)
; ==============================
(
(compilation_unit
(class_declaration
(attribute_list
(attribute
name: (_) @class_attribute
(#match? @class_attribute "^(TestFixture|TestClass)$")))
name: (identifier) @run @csharp_class_name))
(#set! tag csharp-test-class)
)
60 changes: 60 additions & 0 deletions languages/csharp/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[
{
"label": "Test ${ZED_CUSTOM_csharp_namespace:}.${ZED_CUSTOM_csharp_class_name:}.${ZED_CUSTOM_csharp_method_name:}",
"command": "dotnet",
"args": [
"test",
"--filter",
"FullyQualifiedName=${ZED_CUSTOM_csharp_namespace:}.${ZED_CUSTOM_csharp_class_name:}.${ZED_CUSTOM_csharp_method_name:}"
],
"cwd": "$ZED_DIRNAME",
"use_new_terminal": false,
"reveal": "always",
"tags": [
"csharp-test-method"
],
"env": {
"CSHARP_TEST_NAMESPACE": "${ZED_CUSTOM_csharp_namespace:}",
"CSHARP_TEST_CLASS": "${ZED_CUSTOM_csharp_class_name:}",
"CSHARP_TEST_METHOD": "${ZED_CUSTOM_csharp_method_name:}",
"CSHARP_TEST_FILE_DIR": "$ZED_DIRNAME"
}
},
{
"label": "Test class ${ZED_CUSTOM_csharp_namespace:}.${ZED_CUSTOM_csharp_class_name:}",
"command": "dotnet",
"args": [
"test",
"--filter",
"FullyQualifiedName~${ZED_CUSTOM_csharp_namespace:}.${ZED_CUSTOM_csharp_class_name:}"
],
"cwd": "$ZED_DIRNAME",
"use_new_terminal": false,
"reveal": "always",
"tags": [
"csharp-test-class"
],
"env": {
"CSHARP_TEST_NAMESPACE": "${ZED_CUSTOM_csharp_namespace:}",
"CSHARP_TEST_CLASS": "${ZED_CUSTOM_csharp_class_name:}",
"CSHARP_TEST_METHOD": "",
"CSHARP_TEST_FILE_DIR": "$ZED_DIRNAME"
}
},
{
"label": "Test project",
"command": "dotnet",
"args": [
"test"
],
"cwd": "$ZED_DIRNAME",
"use_new_terminal": false,
"reveal": "always",
"tags": [
"csharp-test-all"
],
"env": {
"CSHARP_TEST_FILE_DIR": "$ZED_DIRNAME"
}
}
]
Loading