{"id":22238386,"url":"https://github.com/89netram/browser-csharp","last_synced_at":"2026-01-24T18:03:05.304Z","repository":{"id":39061413,"uuid":"279290635","full_name":"89netraM/browser-csharp","owner":"89netraM","description":"Executes C# snippets in the browser","archived":false,"fork":false,"pushed_at":"2023-03-05T05:49:27.000Z","size":1105,"stargazers_count":2,"open_issues_count":26,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T00:04:35.822Z","etag":null,"topics":["c-sharp","runtime-compilation","wasm"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/89netraM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-13T12:01:04.000Z","updated_at":"2024-07-31T15:28:21.000Z","dependencies_parsed_at":"2023-02-08T00:00:44.529Z","dependency_job_id":null,"html_url":"https://github.com/89netraM/browser-csharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/89netraM%2Fbrowser-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/89netraM%2Fbrowser-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/89netraM%2Fbrowser-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/89netraM%2Fbrowser-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/89netraM","download_url":"https://codeload.github.com/89netraM/browser-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084610,"owners_count":20558248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","runtime-compilation","wasm"],"created_at":"2024-12-03T03:16:27.265Z","updated_at":"2026-01-24T18:03:05.275Z","avatar_url":"https://github.com/89netraM.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browser C#\n\nExecutes C# snippets in the browser.\n\n## Installation\n\nInstall using `npm`:\n```\nnpm install browser-csharp\n```\n\nThe WASM files for .NET **must** be included as static assets in the correct\nway:\n\n1. The folder `./node_modules/browser-csharp/out/_framework` **must** be\n   included as `./_framework` relative to the `\u003cbase/\u003e` of your HTML file.\n2. You **must** include a reference to the WASM .NET entry file:  \n   `\u003cscript src=\"_framework/blazor.webassembly.js\"\u003e\u003c/script\u003e`\n\nAfter doing this you can include the client library in JS/TS with a regular\n`require`/`import`.\n\n## Usage\n\nInclude a reference to the library:\n```TypeScript\nconst BrowserCSharp = require(\"browser-csharp\").BrowserCSharp; // JS\nimport { BrowserCSharp } from \"browser-csharp\";                // TS\n```\n\nWait for the WASM library to initiate:\n```TypeScript\nBrowserCSharp.OnReady(success =\u003e { /* Callback */ });\n```\n\nRun a code snippet:\n```TypeScript\nBrowserCSharp.ExecuteScript(`Console.WriteLine(\"Hello from C#\");`)\n.then(response =\u003e {\n\tresponse.stdErr // String with errors (parsing and compilation)\n\tresponse.stdOut // String with C# output (runtime)\n\tresponse.result // The return value of the the expression\n});\n```\n\nWith an extra argument (a string) the code snippet can be run in the context of\nprevious code snippets, that was run with the same context id.  \nThis is good for creating REPLs.\n```TypeScript\nBrowserCSharp.ExecuteScript(codeSnippet, contextId)\n```\nThe return is the same, a `Promise` that resolves with an object of the same\nshape.\n\n## Example\n\nFor an example of what this package can do, look in the [`./example`](https://github.com/89netraM/browser-csharp/example/) folder for the code and [here](https://åsberg.net/browser-csharp/) for a live demo.\n\n## Development\n\nThis package requires that .NET Core is installed for development. [Download the\nSDK here](https://dotnet.microsoft.com/download).\n\nTo test the wasm part during development run `dotnet run` in the wasm directory\nto start a dev server. It will only include the wasm part, so use the following\nsnippet to invoke the code.\n\n```JavaScript\nDotNet.invokeMethodAsync(\n\t\"BrowserCSharp\", \"ExecuteScript\",\n\t`String.Concat(\"apa\".Select(c=\u003e(char)(c+1)))`\n).then(console.log)\n```\n\nThere's not much to test with the TypeScript part, but you can build it alone\nwith `npx gulp ts-build`.\n\nBuilding everything at once can be done with `npx gulp ts-build wasm-build`, or\n`npm run prepack` 🤷‍♀️.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F89netram%2Fbrowser-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F89netram%2Fbrowser-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F89netram%2Fbrowser-csharp/lists"}