-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for creating a C# addon to create-addon command #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Oh, this does NOT use WinAppSDK yet, I'll try that next. |
Fixed now. |
|
We need to make sure the generated .node file is actually self-contained. |
I tested out the sample on a VM that doesn't have .net installed and I see it works fine. Also, I tested in the debugger to make sure it doesn't load any CLR/dotnet DLLs. |
chiaramooney
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Once this gets merged, it would be great to add a page to Electron Gallery with a CS addon sample
Sure, sounds good! |
nmetulev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Hi @nmetulev thanks for testing! Sorry I guess I'm still a node noob -- can you help me understand how you got that error? I've been running
It does has that, it should look like the below. Does yours not have this? ===== Using the Addon in JavaScriptAfter building, you can use the addon in your JavaScript code: // Load the C# module
const csAddon = require('./csAddon/build/Release/csAddon');
// Call exported methods (note: C# method names are converted to camelCase in JavaScript)
console.log(csAddon.Addon.hello('World'));
// Output: Hello from C#, World!
console.log(csAddon.Addon.add(5, 3));
// Output: 8
console.log(csAddon.Addon.getCurrentTime());
// Output: (current time) |
That's what I'm doing to, I'm doing this in my new app: Are you doing something else? (I'm sure your suggestion is correct, I just want to make sure I know how to repro to make sure it's fixed) |
Agh, no, I'm installing the generated package, not the folder. Do this |
@nmetulev great catch, thanks! Should be fixed now to point at the .node file. Interesting, I think the location you found is pulling in the IL .dll file, not the AOT'd .node file. I'd love to know if it works for you when pointing to the .node file. |
|
@JesseCol, could you look at the conflict here? |
|
Thanks @nmetulev , looks like it needs reapproval (when you have a sec):
|




create-addon --template=cscommand that creates a C# add-on and installs the node-api-dotnet package.The command and output looks like this:
Here's how to use it from Javascript:
Here's what the output looks like: