Skip to content

Support launching app with file for win and linux #648

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

schaveyt
Copy link

@schaveyt schaveyt commented Dec 29, 2021

Status: Review Approved

Summary

Addresses #647 and remains compatible with existing behavior of passing arguments via /args commandline option.

This has been built and integration tested locally by invoking via electronize start as well as the compiled executable as described in the issue #647.

Change Summary

  1. Added the new Process class and singleton, this required:
    1. Updating ElectronNET.API/Electron.cs to add access to the Process singleton
    2. Updating ElectronNET.API/ServiceCollectionExtensions.cs to register Process singleton to the DI container
    3. Updating ElectronNET.CLI/Commands/Actions/DeployEmbeddedElectronFiles.cs to deploy the new embed the new .js file
    4. Updating ElectronNET.CLI/ElectronNET.CLI.csproj to embed the new process.js file to the CLI.
    5. Creating ElectronNET.Host/api/process.ts to interact with Electron's process object from the node side
    6. Creating ElectronNET.API/Process.cs to bridge with the electron api
    7. Updating ElectronNET.Host/main.js to initialize the processApi object.
  2. Updated ElectronNET.API/BridgeConnector.cs to add reusable methods to obtaining values over the Socket interface.
  3. Updated ElectronNET.API/Entities/ProcessVersion.cs as corresponding type to the electron.process.versions type.

Verification Summary

I was not able to get the WebApp project running however I was able to get my target project running with the update API & CLI changes. I created a simple test method as follows:

    public async void VerifyProcessApi()
    {      
        Console.WriteLine($"VerifyProcessApi START------------");
        Console.WriteLine($"Electron.Procsss.ExecPath='{await Electron.Process.ExecPathAsync}'");
        Console.WriteLine($"Electron.Procsss.TypeAsync='{await Electron.Process.TypeAsync}'");

        var argv = await Electron.Process.ArgvAsync;
        var argvLength = argv != null ? argv.Length.ToString() : "null";
        Console.WriteLine($"Electron.Procsss.ArgvAsync.Length='{argvLength}'");
        if (argv != null)
        {
            var msg = "\n";
            for (var i = 0; i < argv.Length; i++)
            {
                msg += $"argv[{i}]='{argv[i]}'\n";
            }

            Console.WriteLine(msg);
        }

        var versions = await Electron.Process.VersionsAsync;
        Console.WriteLine($"Electron.Procsss.VersionsAsync='[Chrome={versions.Chrome}, Electron={versions.Electron}']");

        Console.WriteLine($"Electron.Procsss.DefaultAppAsync='{await Electron.Process.DefaultAppAsync}'");
        Console.WriteLine($"Electron.Procsss.IsMainFrameAsync='{await Electron.Process.IsMainFrameAsync}'");
        Console.WriteLine($"Electron.Procsss.ResourcesPathAsync='{await Electron.Process.ResourcesPathAsync}'");
        Console.WriteLine($"Electron.Procsss.UpTimeAsync='{await Electron.Process.UpTimeAsync}'");
        Console.WriteLine($"Electron.Procsss.PidAsync='{await Electron.Process.PidAsync}'");
        Console.WriteLine($"Electron.Procsss.ArchAsync='{await Electron.Process.ArchAsync}'");
        Console.WriteLine($"Electron.Procsss.PlatformAsync='{await Electron.Process.PlatformAsync}'");
        Console.WriteLine($"VerifyProcessApi END------------");
    }

The generated the following results with no issues.

Results:

image

Copy link
Contributor

@danatcofo danatcofo left a comment

Choose a reason for hiding this comment

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

Very nice. There's an open PR that converts all the singletons into interfaces that will need updating after this one as it will conflict but that isn't this PRs problem.

/// <summary>
/// Gets or sets a value representing Chrome's version string.
/// </summary>
public string Chrome { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are read only values you might make the set internal for these two props.

Copy link
Author

@schaveyt schaveyt Jan 4, 2022

Choose a reason for hiding this comment

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

Alternatively, i figured this would be a perfect use case for using a record type to achieve the desired read-only behavior. See my latest commit.

I have re-run all my tests and encountered no issue with this change. 👍

…ly access to props

This is to address a PR ElectronNET#648 review comment to ensure that only the external
users are not able to modify the instance values.
@GregorBiswanger GregorBiswanger self-assigned this Apr 6, 2022
@GregorBiswanger GregorBiswanger added this to the 18.6.1 milestone Apr 6, 2022
@GregorBiswanger GregorBiswanger merged commit 1a1bd61 into ElectronNET:master Apr 6, 2022
hillin pushed a commit to hillin/Electron.NET that referenced this pull request Jun 18, 2025
…adonly access to props

This is to address a PR ElectronNET#648 review comment to ensure that only the external
users are not able to modify the instance values.
@hillin hillin mentioned this pull request Jun 18, 2025
FlorianRappl added a commit that referenced this pull request Jun 22, 2025
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.

3 participants