We are exploring JINT and we were able to map a runtime custom javascript with C# methods. However, I was just being curious, can this same be achieved using a .net 6 source generators ? For instance, if there is a javascript method written, can that be used and mapped with a C# method?
Is my understanding of source generators incorrect here?
Any comments or help will be appreciated.
Jint, as said on their github page, is a Javascript interpreter for .NET, i.e. it allows to interpret and execute code written in js inside .NET process.
Source generators just allow to generate some source files (with C# code) during build time which will be processed later down the build pipeline. In theory you can try to write source generator which will translate some js source code files into C# but there is nothing build in. Or if you have js source files you try to analyze them and generate C# wrapper files which will expose the corresponding js methods (using Jint internally) to save you (in theory) some time of writing the same boilerplate code manually.
map a runtime custom javascript
Just to reiterate - source generators are build time tool.