Skip to content
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

Automatic conversion from C# to Jurassic JavaScript #225

Open
immitev opened this issue Sep 25, 2023 · 2 comments
Open

Automatic conversion from C# to Jurassic JavaScript #225

immitev opened this issue Sep 25, 2023 · 2 comments
Labels

Comments

@immitev
Copy link

immitev commented Sep 25, 2023

There is a relatively popular open-source conversion library from C# to VB.NET https://github.com/icsharpcode/CodeConverter . I wonder how easy or complex will be to have something similar for C# to Jurassic JS?

@paulbartrum
Copy link
Owner

It's probably not too difficult to convert the core C# language to JavaScript. (Harder than C# to VB.NET mind you.) But converting the .NET base class libraries (BCL) to the equivalent JavaScript standard library functions is basically an impossible task, because a) the BCL is huge, and b) there's lots of BCL functionality that simply doesn't exist in JavaScript. It might be possible if you restrict yourself to a subset of the BCL though.

@immitev
Copy link
Author

immitev commented Sep 25, 2023

Indeed, the BCL is huge. I guess something more manageable will be as a default to use the BCL types/classes directly in the generated Jurassic code, and try to convert to pure JavaScript only some basic stuff.

Probably the code translator should be able to generate working JS code in plenty of scenarios, assuming there is available a helper function getClrType that can be used like this:

var File = getClrType('System.IO.File');
File.WriteAllText('C:\temp\test.txt', 'test');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants