Compare commits

...

9 commits

Author SHA1 Message Date
Ivan
c840d3e3d7
Add link to CSharpRepl in README 2026-06-01 16:22:19 +02:00
Ivan
6c6553b41b
Update README with requirements and usage details
Added requirements and usage instructions for the plugin.
2026-06-01 16:21:34 +02:00
Ivan
1118b80ccf Make timeouts show an error message instead of success 2026-06-01 09:17:15 +02:00
Ivan
b8c899bdbe
Update LICENSE 2026-05-29 12:05:07 +02:00
Ivan
0684cdc0bb
Bump version from 1.0.2 to 1.0.3 2026-05-29 11:44:03 +02:00
Ivan
c6bd967ba3 Add artifact attestations 2026-05-29 11:41:57 +02:00
Ivan
c6cdd54672
Bump version to 1.0.2 in manifest.json 2026-05-29 11:30:36 +02:00
Ivan
ceafe637a7 Update README.md 2026-05-29 11:09:59 +02:00
Ivan
ab337f6194 Remove Obsidian from description 2026-05-29 11:09:21 +02:00
6 changed files with 36 additions and 9 deletions

View file

@ -9,7 +9,9 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
attestations: write
contents: write contents: write
id-token: write
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -23,6 +25,13 @@ jobs:
npm install npm install
npm run build npm run build
- name: Attest release artifacts
uses: actions/attest-build-provenance@v2
with:
subject-path: |
main.js
styles.css
- name: Create release - name: Create release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,4 +1,4 @@
Copyright (C) 2020-2025 by Dynalist Inc. Copyright (C) 2026 OHM Engineering.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

View file

@ -1,6 +1,9 @@
# C# Snippet Runner # CSharp Snippet Runner
Obsidian plugin that adds a run button to C# code blocks. It uses [CSharpRepl](https://github.com/waf/CSharpRepl) to execute the snippets and displays the output directly in the note.
<img width="960" height="487" alt="Schermafbeelding 2026-05-29 110157" src="https://github.com/user-attachments/assets/233e5535-0cf4-4c75-ba27-8af9a36315ec" />
Obsidian plugin that adds a run button to C# code blocks. It uses CSharpRepl to execute the snippets and displays the output directly in the note.
## Features ## Features
@ -11,6 +14,17 @@ Obsidian plugin that adds a run button to C# code blocks. It uses CSharpRepl to
- Saves output and arguments per snippet in the plugin `responses` folder - Saves output and arguments per snippet in the plugin `responses` folder
- Restores saved output/arguments when notes are rendered - Restores saved output/arguments when notes are rendered
## Requirements
- Obsidian version >= 1.12.7
- [dotnet SDK](https://dotnet.microsoft.com/en-us/download) installed on your PC
## Usage
- Add a code snippet to your Obsidian note with one of these tags: `csharp`, `cs`, `c#`, `net`, `.net` or `dotnet`
- Optionally enter args
- Click `Run C#`
See [CSharpRepl](https://github.com/waf/CSharpRepl) on how to use with includes and nuget packages
## Development ## Development
```bash ```bash

View file

@ -1,9 +1,9 @@
{ {
"id": "csharp-snippet-runner", "id": "csharp-snippet-runner",
"name": "CSharp Snippet Runner", "name": "CSharp Snippet Runner",
"version": "1.0.0", "version": "1.0.4",
"minAppVersion": "1.12.7", "minAppVersion": "1.12.7",
"description": "Run C# code blocks in Obsidian using an auto-installed CSharpRepl runtime.", "description": "Run C# code blocks using an auto-installed CSharpRepl runtime.",
"author": "OHM Engineering", "author": "OHM Engineering",
"authorUrl": "https://github.com/OHM-Engineering", "authorUrl": "https://github.com/OHM-Engineering",
"isDesktopOnly": false "isDesktopOnly": false

View file

@ -283,7 +283,11 @@ export default class CSharpSnippetRunnerPlugin extends Plugin {
clearTimeout(timeoutHandle); clearTimeout(timeoutHandle);
if (timedOut) { if (timedOut) {
resolve({ stdout, stderr }); const timeoutError = new Error(`CSharpRepl execution timed out after ${timeoutMs}ms. Increase the timeout setting and try again.`) as ReplExecutionError;
timeoutError.code = 'ETIMEDOUT';
timeoutError.stdout = stdout;
timeoutError.stderr = stderr;
reject(timeoutError);
return; return;
} }

View file

@ -6,7 +6,7 @@ export interface CSharpSnippetSettings {
} }
export const DEFAULT_SETTINGS: CSharpSnippetSettings = { export const DEFAULT_SETTINGS: CSharpSnippetSettings = {
executionTimeoutMs: 3000, executionTimeoutMs: 10000,
}; };
export class CSharpSnippetSettingTab extends PluginSettingTab { export class CSharpSnippetSettingTab extends PluginSettingTab {
@ -29,7 +29,7 @@ export class CSharpSnippetSettingTab extends PluginSettingTab {
.setName('Execution timeout (ms)') .setName('Execution timeout (ms)')
.setDesc('Maximum time to wait before stopping execution and returning captured output.') .setDesc('Maximum time to wait before stopping execution and returning captured output.')
.addText((text) => text .addText((text) => text
.setPlaceholder('3000') .setPlaceholder('10000')
.setValue(String(this.plugin.settings.executionTimeoutMs)) .setValue(String(this.plugin.settings.executionTimeoutMs))
.onChange(async (value) => { .onChange(async (value) => {
const parsed = Number.parseInt(value, 10); const parsed = Number.parseInt(value, 10);