Announcement

Collapse
No announcement yet.

include Bridge.NET generated code in VS Code Plugin

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • include Bridge.NET generated code in VS Code Plugin

    Hi,
    many thanks for creating such a powerful tool.
    I created a SQL Formatter (SQLinForm) plugin in Java and C# (e.g. plugin for Notepad++) and now want to create a plugin for the VS Code editor and later also for the Atom editor.
    The 1st step I did was to translate the C# written code from C# into JS using Bridge.Net and it worked very well.
    The 2nd step I want to do now is to include the generated JS code into the VS Code plugin template. I have already read a lot of docs but did not find the information I was looking for. I am sorry but I am new to JS and new to VS Code plugin development. The thing is struggle most is how to call my JS module from within the extension.js module. Any idea where I could find more info how to include th Bridge.NET generated code into a VS Code plugin? Or is there an example in the docs and I just missed it? I am not asking you to to the coding, but maybe you know a good place to start reading. Thx!

  • Andrey
    replied
    Hi guidomarcel

    By saying "Bridge ecosystem" I meant loading Bridge modules from within other Bridge-generated functions. That should work well. However, loading a Bridge module by 3rd party functions wouldn't always work. Consider the following sample with a simple module:

    C#
    [Module]
    public class Program
    {
        public static void Main()
        {
        }
    }
    JavaScript
    Bridge.assembly("Demo", function ($asm, globals) {
        "use strict";
    
        define("$module2", function () {
            var _module2 = { };
            Bridge.define("Demo.Program", {
                $scope: _module2,
                main: function Main () { }
            });
            return _module2;
        });
    
    });
    You can notice that the define function initializing a module is located under Bridge.assembly statement.That means bridge.js needs to be already loaded before you'd like to load this demo module. That should be done explicitly in your scenario when VS Code loads your Bridge module.

    Of course, you can copy Bridge output and make it working with VS code, just a little bit of adjustment would be required.

    Leave a comment:


  • guidomarcel
    replied
    Hi Andrey,
    thanks for your answer.
    Suppose I copy the bridge.js and the output from Bridge to the VS Code extension folder. Would you say that I am outside or inside the Bridge ecosystem?
    Regards
    Guido

    Leave a comment:


  • Andrey
    replied
    Hi guidomarcel

    Working with Bridge modules outside Bridge ecosystem could be challenging.The following sample project could be helpful. It demonstrates usage of Bridge output in a TypeScript project for a NodeJS app.
    https://github.com/bridgedotnet/Demo...ter/TSProjDemo

    Although the project doesn't really use JS modules, it just loads Bridge output as a script. More details on scripts vs. modules can be found here.

    If you really need to have a Bridge module loaded, it could be tricky since Bridge does not generate proper d.ts files for that purpose. Anyways, it's doable with some edits. I created the js-module branch with a JS project (project/folder names were not changed to avoid many edits).
    https://github.com/bridgedotnet/Demo...ule/TSProjDemo

    See the following changeset to learn what edits were required:
    https://github.com/bridgedotnet/Demo...366c5f07c9beea

    Hope that helps.

    Leave a comment:

Working...
X