edge-generator

1.0.0 • Public • Published

edge-generator

A node.js package that generates proxies which hold references to live .NET objects in JavaScript code.

While this package generates proxies, the related edge-reference package is used at runtime to bind the proxies to their .NET counterparts. Therefore, edge-reference should be installed as a runtime dependency of any module which uses proxies generated by this package.

Installation

$ npm i edge-generator -g

or to install in the current project only:

$ npm i edge-generator --save-dev

Usage

edge-generator -a <assembly-path> [-t <target-directory>] Namespace.Type1 Namespace.Type2

A proxy will be generated for each type specified in the arguments passed to the utility. These types must be contained in the assembly that is located at the path specified in . Besides each type, a proxy will be generated for its base type and any non-primitive types referenced in its public members.

Generation of a proxy will generate a JS file with a name corresponding to the fully-qualified type name. These files will be written to the target directory specified, or to the current directory if no target directory is given.

Example

The following example:

edge-generator -a ./bin/Debug/ExampleCo.Utils.dll -t ./proxies ExampleCo.Utils.Connector ExampleCo.Utils.Widget ExampleCo.Utils.Factory

will generate three JavaScript files in the ./proxies directory, assuming the DLL specified exists, and contains the three types named. The files generated will be named

ExampleCo-Utils-Connector.js

ExampleCo-Utils-Widget.js

ExampleCo-Utils-Factory.js

It is possible to rename generated files after generation.

When deploying proxy files, the .NET assemblies referenced by them must also be deployed, in the node project's root folder. It is also necessary to install and save the edge-reference node module.

Notable Limitations

Several features of the .NET framework and the C# language are not supported at this time. A non-exhaustive list is below:

  • Constructor parameters - At the moment, only parameterless constructors are supported.
  • Overloaded members - Due to limitations of the JavaScript language, overloading is not directly possible in these proxies. Solutions are being investigated.
  • Generics - generic parameters are not supported at this time, and generated proxies will generally not function correctly when calling generic methods.
  • out/ref parameters - There is currently no support for this feature. Since JavaScript does not support two-way arguments, there will never be full support without additional data structures.
  • optional arguments - Generated proxies receive a callback as the last argument. For this reason, default values should be explicitly supplied for optional arguments.
  • User-defined value types - currently, only reference types and primitives are supported.

Disclaimer

The author of this package is in no way affiliated with the edge.js package.

Dedication

Dedicated to Dorothy Gant (1925-2017)

License

Copyright (c) 2017 Steve Westbrook

MIT

Package Sidebar

Install

npm i edge-generator

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • stevewestbrook