First of all let me tell you that it's a great project.
I'm playing now with the Chromium Embedded Framework to create an application that contains both C# and HTML+JS code. I want to implement some kind of dependency injection, so that I could replace JS code with C#.
I want to get inspired by going trough and understanding your code, how you have implemented the seamless binding you provide, e.g. host objets, ... (it'd be a great starting point for me because Chromium uses V8 under the hood just like you do)
If you could give me advice where to look at in the code, where can I find detailed documentation, that'd be appreciated.
Thanks in advance
Oct 16, 2014 at 12:03 PM
Thanks for your kind words! Unfortunately there's no detailed documentation beyond the code itself.
ClearScript's V8 binding consists of several layers. The best way to understand it is to follow a code path from V8 to a target host object. Some tools you might find helpful are ClearScriptConsole, which provides a script command line with access to the core
.NET class library, and the Visual Studio debugger, which lets you step through both native and managed code in the same process.
Here are some notes to get you started.
V8ContextImpl class; e.g.,
If you set a breakpoint there, you can step through the code as it makes its way to the managed side and eventually ends up in
HostItem, the managed wrapper for all exposed host resources.
HostItem then fulfills the request using a variety of APIs such as reflection, the C# Runtime Binder, the .NET dynamic infrastructure, COM interop, etc. It has a lot of plumbing to handle a variety of binding scenarios.
Good luck, and please let us know if you have more questions!