Skip to content

Conversation

@softworkz
Copy link
Collaborator

Supersedes #994

Copilot AI review requested due to automatic review settings December 18, 2025 14:52
@softworkz softworkz changed the title Fix ElectronSingleInstance handline Fix ElectronSingleInstance handling Dec 18, 2025
@softworkz softworkz force-pushed the submit_singleinstance branch from c1fa662 to 30037fc Compare December 18, 2025 14:53
Copy link
Contributor

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 refactors the ElectronSingleInstance configuration from a string-based approach (using "yes"/"no" values) to a proper boolean type throughout the codebase. The change simplifies the logic and makes the configuration more type-safe.

Key changes:

  • Changed ElectronSingleInstance from string to bool type in the data model
  • Updated the JSON template to use boolean values instead of quoted strings
  • Simplified JavaScript condition checking from string comparison to boolean evaluation

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ElectronNET.API/Runtime/Data/BuildInfo.cs Changed ElectronSingleInstance property type from string to bool
src/ElectronNET.API/Runtime/StartupManager.cs Simplified parsing logic to directly assign boolean value instead of mapping to "yes"/"no" strings
src/ElectronNET/build/ElectronNET.LateImport.targets Added .ToLower() to convert boolean value to lowercase string representation for JSON template
src/ElectronNET/build/package.template.json Removed quotes around $(ElectronSingleInstance) to make it a JSON boolean instead of string
src/ElectronNET.Host/main.js Changed condition from string comparison (=== "yes") to direct boolean evaluation

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

{
buildInfo.ElectronSingleInstance = "no";
buildInfo.ElectronSingleInstance = parsedBool;
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

When ElectronSingleInstance is not set or is an empty string, the bool.TryParse will fail and ElectronSingleInstance will remain as its default value (false). However, the default in ElectronNET.LateImport.targets is "true" (line 110). This creates an inconsistency where an unset property would result in false in C# but true in the package.json. Consider adding an else clause to set a default value of true to match the MSBuild default, or ensure the property is always explicitly set.

Suggested change
}
}
else if (string.IsNullOrEmpty(isSingleInstance))
{
// Match MSBuild default in ElectronNET.LateImport.targets when the property is unset
buildInfo.ElectronSingleInstance = true;
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@softworkz softworkz Dec 18, 2025

Choose a reason for hiding this comment

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

No, this is not correct. The default is only in the props file, but what matters is the value at the targets level (after everything that is defined in the .csproj file has been applied).
The value at the targets level is what goes into the metadata attribute and that's the same value that is used during compilation.
So this suggestion is totally wrong.

@github-actions
Copy link

pr-comment: Run #16

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
1372 1210 0 0 0 162 0 15m 9s

🎉 All tests passed!

Github Test Reporter by CTRF 💚

@FlorianRappl FlorianRappl merged commit 44a010e into ElectronNET:develop Dec 18, 2025
33 of 34 checks passed
@FlorianRappl FlorianRappl added this to the 0.4.0 milestone Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants