0

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.

Praneet Nadkar
  • 823
  • 7
  • 16
  • it looks like something is lost in translation, what exactly word "map/mapped" mean in this question? – Iłya Bursov Sep 30 '22 at 03:53
  • apologies. I meant that if the js method name is lets say, getFullName(), then in C#, we create a method and then this is mapped engine.SetValue("getFullName()", Func GetFulName()). – Praneet Nadkar Sep 30 '22 at 04:35

1 Answers1

0

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.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132