Skip to content

Conversation

@adityashirsatrao007
Copy link
Contributor

Closes #967

Changes

  • Added new sample project \ElectronNET.Samples.ElectronHostHook\ demonstrating bidirectional communication using \ElectronHostHook\ logic.
  • Implemented \ElectronHostHook/index.ts\ to handle 'ping' event and return 'pong'.
  • Implemented HomeController to call the hook from C#.
  • Added the new sample to \ElectronNET.sln.

Details

This addresses the request for a focused 'ElectronHostHook Sample' in the linked issue. The sample is minimal and self-contained, showing only the hook mechanism.

Copilot AI review requested due to automatic review settings December 7, 2025 17:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new sample application demonstrating the ElectronHostHook functionality, which enables bidirectional communication between C# and the Electron host process via TypeScript/JavaScript.

Key Changes

  • New sample project showcasing ping/pong communication between C# (HomeController) and TypeScript (ElectronHostHook/index.ts)
  • Implementation of custom Connector class to handle socket-based communication
  • Integration into the solution under "Test Apps" folder alongside existing samples

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/ElectronNET.sln Adds new sample project with proper dependencies and solution folder nesting
src/ElectronNET.Samples.ElectronHostHook/ElectronNET.Samples.ElectronHostHook.csproj Project configuration with TypeScript compilation and ElectronNET references
src/ElectronNET.Samples.ElectronHostHook/Program.cs ASP.NET Core application setup with Electron integration
src/ElectronNET.Samples.ElectronHostHook/Controllers/HomeController.cs Controller demonstrating HostHook.CallAsync usage
src/ElectronNET.Samples.ElectronHostHook/Views/Home/Index.cshtml Simple UI displaying communication results
src/ElectronNET.Samples.ElectronHostHook/ElectronHostHook/connector.ts Base connector class for socket communication (has critical bug)
src/ElectronNET.Samples.ElectronHostHook/ElectronHostHook/index.ts HookService implementation with ping event handler
src/ElectronNET.Samples.ElectronHostHook/ElectronHostHook/tsconfig.json TypeScript compiler configuration
src/ElectronNET.Samples.ElectronHostHook/Properties/launchSettings.json Development launch configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@softworkz
Copy link
Collaborator

@adityashirsatrao007 - Wow, cool! That was fast (after I posted the issue at least)..

I think we need to determine a number of conventions for how to include the samples in the repo.

The existing test apps are meant for development. They have project files that allow them to consume all of Electron.NET directly, bypassing nuget packages (unless modified).
The actual samples should not be like that. They should be minimal und use the nuget packages just like everybody is using them. As such, they also shouldn't be part of the development solution and they shouldn't be in the src folder but rather in their own folder - obviously ./samples - I'd say.

The folder name should be the subject without prefix, i.e. in this case ElectronHostHook.

As a 3-part root namespace is a bit ugly, I'd suggest that all samples should have two parts

  1. ElectronNETSample or ElectronNetSample
  2. The subject - e.g. ElectronHostHook

So, the full paths would be:

samples/ElectronHostHook/ElectronNetSample.ElectronHostHook.sln
samples/ElectronHostHook/ElectronNetSample.ElectronHostHook.csproj

But please don't take my word for it and don't make any changes yet.
We want to see what @FlorianRappl is thinking about it first.

@softworkz
Copy link
Collaborator

@adityashirsatrao007 - Thanks for implementing all the Copilot suggestions I've marked them as resolved.

We're just waiting for input from @FlorianRappl now.

@FlorianRappl
Copy link
Collaborator

I think we can stay with the 3-part solution (yes it's ugly, but it has the arguably "correct" hierarchy).

Let's merge it in like that. Thanks a lot for the effort! 🚀

@FlorianRappl FlorianRappl merged commit e854451 into ElectronNET:main Dec 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ideas for Sample Applications

3 participants