-
Notifications
You must be signed in to change notification settings - Fork 28
CSharpWasm support JS side #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
45c3674
Add initial C# WebAssembly project structure and setup
daosgava 2b8ae27
Refine .gitignore to streamline ignored files and directories
daosgava da18768
Add C# support with compiler and runtime integration
daosgava 0f58d42
Refactor C# runtime integration: update event handling and remove unu…
daosgava 606ac85
Remove redundant console log for IDE initialization
daosgava 8b9ff86
Merge branch 'main' into wasm-csharp-interop
daosgava 4b302ed
Update comment for clarity in CSharpCompiler registration
daosgava d7f6529
Refactor C# WebAssembly integration: remove run button and related co…
daosgava 144c5e5
Remove redundant console log in project initializer for C# project cr…
daosgava 2d6035c
CSharpWasm.dll update
daosgava cff1e1c
Overload write_line function
daosgava f4b75ae
add error handling and namespace
daosgava 92583f0
fix indentation, use sample from splash kit website
daosgava 4358d72
Add comments with future work
daosgava de6d8e5
Improve comments and remove unnecessary methods
daosgava eb51219
add parseMethods function and generated bindings
daosgava 1453d30
Remove unnecessary comments
daosgava 0068ea7
Address newline character issue.
daosgava 1551b4c
Merge branch 'main' into wasm-csharp-js
Oliver-Quail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ out/ | |
| splashkit/ | ||
| generated/ | ||
| __pycache__/ | ||
| _framework/ | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { dotnet } from "./wwwroot/_framework/dotnet.js"; | ||
| import methods from "./splashKitMethods.generated.js"; | ||
|
|
||
| const parseMethods = (methods) => { | ||
| const methodList = methods | ||
| .split(",") | ||
| .map((method) => method.trim().replace("\n", "")) | ||
| .filter(Boolean); | ||
|
|
||
| const bindingsFunctions = {}; | ||
|
|
||
| for (const name of methodList) { | ||
| try { | ||
| bindingsFunctions[name] = eval(name); | ||
| } catch (e) { | ||
| console.warn(e); | ||
| } | ||
| } | ||
|
|
||
| return bindingsFunctions; | ||
| }; | ||
|
|
||
| const loadDotNet = async () => { | ||
| const { setModuleImports, getAssemblyExports, getConfig } = await dotnet | ||
| .withDiagnosticTracing(false) | ||
| .withApplicationArgumentsFromQuery() | ||
| .create(); | ||
|
|
||
| const skFunctions = parseMethods(methods); | ||
|
|
||
| setModuleImports("main.js", { | ||
| window: { | ||
| location: { | ||
| href: () => globalThis.window.location.href, | ||
| }, | ||
| }, | ||
| SplashKitBackendWASM: skFunctions, | ||
| }); | ||
|
|
||
| const config = getConfig(); | ||
| const exports = await getAssemblyExports(config.mainAssemblyName); | ||
| return exports; | ||
| }; | ||
|
|
||
| const CompileAndRun = async (code, reportError) => { | ||
| try { | ||
| const exports = await loadDotNet(); | ||
| const result = await exports.CSharpCodeRunner.CompileAndRun(code); | ||
| if (result.includes("Compilation failed")) { | ||
| const errors = result.split(":"); | ||
| const errorLine = errors[1].split("Line"); | ||
|
|
||
| const indexCorrector = 1; | ||
| const filePath = "__USERCODE__/code/main.cs"; | ||
| reportError( | ||
| filePath, | ||
| result, | ||
| Number(errorLine[1]) + indexCorrector, | ||
| null, | ||
| true, | ||
| ); | ||
| } | ||
| } catch (error) { | ||
| console.error("Error during code execution:", error); | ||
| } | ||
| }; | ||
|
|
||
| // This event will be trigger by the csharp compiler | ||
| document.addEventListener("compileAndRun", (ev) => { | ||
| CompileAndRun(ev.detail.program[0].source, ev.detail.reportError); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed when running the buildAndCopy.sh script.

It created files in Browser_IDE/CSharpWasm/bin
Is this supposed to be ignored two
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, those are the actual libraries that allow compiling C# in the browser :)