No announcement yet.

invoke compiler at runtime

  • Filter
  • Time
  • Show
Clear All
new posts

    invoke compiler at runtime

    I am designing an application that will need to create some C# classes at runtime. I would like to be able to convert those classes into javascript equivalents. For example I might have a C# class that looks like
    public class Person
    {public int Score { get; set; } public bool IsScoreValid() {//code in real implementation would be more complex and make use of various properties return Score > 0 && Score <= 100;}
    The trick here is that the Person class here will be created at runtime based on some configuration. I do not have control over the code in the IsScoreValid method and it could change while the application is running. I only know that it is valid C# code. I need a robust way to convert this class into a javascript equivalent, and I need to be able to perform this conversion at runtime. Would be a good way to convert this javascript? Can compiler be invoked at runtime?

    Hello MiguelCorazao, and welcome to Bridge.NET forums!

    Bridge compiler can, yes, be called from run time, as long as you referenced Bridge.Translator from your project. In fact, we do use it to test some Bridge compile scenarios in our test projects. Here's the code where the test calls Bridge to compile a code:

    We also have (which is not public/open source -- at least as of yet) that does build at runtime -- and runs the resulting javascript.

    Hope this helps!