Skip to content

Conversation

@Seth0x41
Copy link
Contributor

What type of PR is this? (check all applicable)

  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • ♻️ Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert
  • 🌐 Internationalization / Translation

Description

This PR adds support for C# (WebAssembly) compilation in LiveCodes.

  • added support for C#.
  • wrote the language docs.

Note: I didn’t add the formatter.

Related Tickets & Documents

Closes #531

Mobile & Desktop Screenshots/Recordings

Added tests?

  • πŸ‘ yes
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentations?

  • πŸ““ docs (./docs)
  • πŸ“• storybook (./storybook)
  • πŸ“œ README.md
  • πŸ™… no documentation needed

@netlify
Copy link

netlify bot commented Apr 17, 2025

βœ… Deploy Preview for livecodes ready!

Name Link
πŸ”¨ Latest commit 60cfe89
πŸ” Latest deploy log https://app.netlify.com/sites/livecodes/deploys/68064e42db54f200080fa82e
😎 Deploy Preview https://deploy-preview-798--livecodes.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hatemhosny
Copy link
Collaborator

Thanks a lot @Seth0x41
This is such a great addition to LiveCodes.

I have made some changes, many of which are just stylistic to keep consistency with the rest of the project.
However the most notable changes were related to refactoring the C# wasm script:

  • simplified the initialization step, with decreasing the number of variables and flags tracking this step.
  • kept the behaviour and variables consistent with other languages (e.g. Java, C++ (wasm))
  • this script runs in the context of the result page, with user code. So I avoid as much as possible any significant changes in the environment (e.g. avoid set/get for localstorage, modified the patched fetch to only affect the urls for blazor files, decrease global variables and keep them under livecodes, Blazor and DotNet)

Added the formatter (of Java, till we find a better one) and editor syntax highlighting.

I also modified docs to only reflect guidance for end users.
e.g. to guide contributors for updating .net version, I added a README in the repo that generates the runtime files.

By the way, we may move csharpBlazorWasmGenerator and csharp-wasm to @live-codes organization if you don't mind.

To generate translation json files, run npm run i18n-export (see i18n docs). The build now passes.

I do not like waiting arbitrary time here. This can be variable from a device to another. Is there a way to listen for an event to tell us that we are ready?

Please review the changes and let me know what you think.

I am very grateful for the amount and quality of your effort.
Thank you very much.

@hatemhosny
Copy link
Collaborator

I do not like waiting arbitrary time here. This can be variable from a device to another. Is there a way to listen for an event to tell us that we are ready?

I think I have fixed that.

@sonarqubecloud
Copy link

@Seth0x41
Copy link
Contributor Author

Hi @hatemhosny,
Thanks a lot for these changes, the code is much cleaner now. also, the idea of the test expression you implemented to solve the arbitrary waiting time issue is smart.
I have no problem moving csharpBlazorWasmGenerator and csharp-wasm to livecodes, it's a better idea to have everything gathered in one place.
Great work!

@hatemhosny
Copy link
Collaborator

hatemhosny commented Apr 21, 2025

Thank you @Seth0x41

I will merge this now.

Let me ask a question for consideration:
Do you think we can also support Razor Pages/CSHTML?
e.g. A razor page in the markup editor and the C# code in the script editor or a @code block
similar to this: https://www.syncfusion.com/pages/blazor-playground/

This is a useful repo and lists links to other projects:
https://github.com/jjonescz/DotNetLab

If you think this is feasable, let's open a new issue for that.
Obviously, this is not a high priority now, but will allow very nice use-cases.

Thank you.

@hatemhosny hatemhosny merged commit 3c86a9c into live-codes:develop Apr 21, 2025
15 checks passed
@livecodes-ci
Copy link
Contributor

livecodes-ci bot commented Apr 21, 2025

i18n Actions

Source PR has been merged into the default branch.

Maintainers can comment .i18n-update-push to trigger the i18n update workflow and push the changes to Lokalise.

@hatemhosny
Copy link
Collaborator

.i18n-update-push

@livecodes-ci
Copy link
Contributor

livecodes-ci bot commented Apr 21, 2025

i18n Actions: .i18n-update-push

Localization updated and pushed to Lokalise.

Name Description
New Branch for i18n i18n/Seth0x41/feat/add-csharp-wasm
Last Commit SHA 3c86a9c

Maintainers can comment .i18n-update-pull after translation is done to trigger the i18n pull workflow and pull the changes back to Github.

@hatemhosny
Copy link
Collaborator

.i18n-update-pull

@Seth0x41
Copy link
Contributor Author

@hatemhosny
I think I can do that, let's look into it more after we add F#.
Thanks for the merge πŸŽ‰πŸŽ‰

@hatemhosny
Copy link
Collaborator

@Seth0x41

Excellent!
Keep up the great work πŸ‘ πŸ‘ πŸš€

@hatemhosny
Copy link
Collaborator

.i18n-update-pull

1 similar comment
@hatemhosny
Copy link
Collaborator

.i18n-update-pull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: C# support

2 participants