Some remaining TODOs include integrating the constants from the view managers, and further investigation on how to include other features available in Android.
In addition to some minor cosmetic changes, this changeset also fixes up the IReactPackage interface and more closely mimics the way IReactPackage is used in the ReactInstanceManagerImpl in ReactAndroid to support loading multiple packages into one NativeModuleRegistry and one JavaScriptModulesConfig.
Additionally, includes unit tests for the current set of core JavaScript modules.
Also refactors the way that implementations of JavaScript modules trigger the invocation, using the CallerMemberNameAttribute to capture the name of the method, rather than passing it in explicitly.
Adds support for IPromise arguments in the last argument of native module methods.
Additionally, adds checks during module initialization to ensure native module methods abide by the expected contract (i.e., void or Task return type, positioning of ICallback and IPromise arguments, etc.).
Added two unit tests to verify if using compiled delegates instead of reflection was actually giving us any performance gains and it was not. Reflection is actually quite fast. Replaced the NativeModuleBase implementation with reflection as the default invocation option.
Also, disabled .NET Native compilation for the unit tests project as it was causing issues with the Chakra runtime. Opened #12 to investigate.
Decided to pursue an IJavaScriptExecutor after all. The reason is because the IJavaScriptExecutor can be pre-initialized the with React Native JavaScript library, without having any of that logic leak into the bridge or catalyst instance.
The IJavaScriptExecutor implementation uses Chakra, and we included some simple mapping visitors from JToken to JavaScriptValue and visa versa.
The current ReactBridge is a trivial wrapper around the IJavaScriptExecutor, that has some knowledge of the React Native protocols.
This changelist also includes some minor fixes to the DllImports for Chakra, which should eventually be refactored into a library (along with the JToken -> JavaScriptValue converters).
One limitation of the .NET framework is that there is no equivalent of the Proxy class in Java that is capable of instantiating interfaces and specifying an invocation handler.
Instead of using interfaces in the way they were used in the Android React implementation, this implementation just uses a base class and a settable property for an invocation handler.
The configuration writer is straight-forward, it just uses the JsonWriter from Newtonsoft.Json.
Adds argument null checks, argument count checks, and wraps the argument extraction in a try/catch to to bubble as a NativeArgumentsParseException.
Adds additional unit tests for exception handling.