Skip to content

Feature: Add {{host}} variable to profile#3511

Merged
mergify[bot] merged 5 commits into
mainfrom
feature/437
Jul 5, 2026
Merged

Feature: Add {{host}} variable to profile#3511
mergify[bot] merged 5 commits into
mainfrom
feature/437

Conversation

@BornToBeRoot

Copy link
Copy Markdown
Owner

Changes proposed in this pull request

  • Add {{host}} variable to profile

Related issue(s)

Copilot generated summary

Provide a Copilot generated summary of the changes in this pull request.

Copilot summary

This pull request introduces a new, unified placeholder syntax ({{Name}}) for profile and custom command fields throughout the application, replacing the old $var$ format. It also adds a reusable helper for resolving these placeholders, updates the migration logic to convert existing user settings, and improves validation and localization for user-facing fields.

Placeholder System Modernization

  • Introduced the PlaceholderHelper utility class to resolve case-insensitive {{Name}} placeholders in strings, replacing the previous ad-hoc regex usage.
  • Updated all relevant code paths (PowerShell, PuTTY, WebConsole, and IP Scanner custom commands) to use PlaceholderHelper.Resolve for consistent placeholder substitution. [1] [2] [3] [4] [5]
  • Changed the default placeholder usage in IPScannerCustomCommand and related resources to use {{IPAddress}} and {{Hostname}} instead of $ipaddress$ and $hostname$. [1] [2]

Migration and Backward Compatibility

  • Added migration logic in SettingsManager to automatically convert existing custom commands from the old $var$ syntax to the new {{Var}} format on upgrade.

Validation and Defaults

  • Added a new WebConsoleProfileUrlValidator to allow the {{Host}} placeholder in the WebConsole URL field while ensuring valid URL structure.
  • Set the default value for WebConsole_Url to "https://{{Host}}" for new profiles.
  • Updated import logic to enable the WebConsole tool by default when importing relevant profiles. [1] [2]

Localization and Resource Updates

  • Added and updated localization strings and resources to reflect the new placeholder syntax and provide improved help messages for custom commands. [1] [2] [3] [4]

Other

  • Bumped assembly version numbers to reflect the new release.
  • Added missing project references for the new utility class.
  • Minor code cleanups and namespace imports for consistency. [1] [2] [3] [4] [5]

These changes ensure a more flexible, maintainable, and user-friendly approach to handling dynamic values in commands and profile fields.

To-Do

Contributing

By submitting this pull request, I confirm the following:

Copilot AI review requested due to automatic review settings July 5, 2026 01:05
@github-actions github-actions Bot added this to the next-release milestone Jul 5, 2026
@mergify

mergify Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 implements issue #437 by introducing a {{Host}} profile placeholder (and modernizing the IP Scanner custom-command placeholder syntax from $$var$$ to {{Var}}). It adds a shared PlaceholderHelper utility that resolves case-insensitive {{name}} tokens, wires it into the WebConsole/PowerShell/PuTTY session builders and the IP Scanner runtime, adds a profile-specific URL validator that tolerates the placeholder, migrates existing user settings, and updates localization and documentation accordingly.

Changes:

  • New PlaceholderHelper centralizes {{name}} resolution; WebConsole URL, PowerShell/PuTTY additional command lines (profile + ad-hoc), and IP Scanner custom commands now resolve placeholders through it.
  • New profile defaults (WebConsole_Url = "https://{{Host}}"), a WebConsoleProfileUrlValidator, WebConsole added to profile-import defaults, and a settings migration converting old $$ipaddress$$/$$hostname$$ custom commands.
  • Localization keys, in-app help tooltips, docs, changelog, and the assembly version were updated.

Reviewed changes

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

Show a summary per file
File Description
Source/NETworkManager.Utilities/PlaceholderHelper.cs New helper resolving case-insensitive {{name}} placeholders (null-safe).
Source/NETworkManager.Validators/WebConsoleProfileUrlValidator.cs New validator that swaps {{host}} for a dummy host before URL validation.
Source/NETworkManager.Profiles/Application/WebConsole.cs Resolves {{Host}} in profile WebConsole URL.
Source/NETworkManager.Profiles/Application/PowerShell.cs Resolves {{Host}} in additional command line.
Source/NETworkManager.Profiles/Application/PuTTY.cs Resolves {{Host}} in additional command line.
Source/NETworkManager.Profiles/ProfileInfo.cs Default WebConsole_Url set to https://{{Host}}.
Source/NETworkManager.Profiles/NETworkManager.Profiles.csproj Adds reference to NETworkManager.Utilities.
Source/NETworkManager.Models/Network/IPScannerCustomCommand.cs Default commands switched to {{IPAddress}}.
Source/NETworkManager.Settings/SettingsManager.cs Migrates existing IP Scanner custom commands to new syntax.
Source/NETworkManager/ViewModels/IPScannerViewModel.cs Uses PlaceholderHelper for runtime substitution; drops unused Regex import.
Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs Ad-hoc connect resolves {{Host}}.
Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs Ad-hoc connect resolves {{Host}} (null for serial mode).
Source/NETworkManager/ViewModels/ImportProfilesResultViewModel.cs Enables WebConsole by default on import.
Source/NETworkManager/Views/ProfileChildWindow.xaml Adds host-placeholder help tooltips; switches URL validator.
Source/NETworkManager/Views/GroupChildWindow.xaml Adds help tooltips (and trims trailing whitespace).
Source/NETworkManager/Views/CustomCommandChildWindow.xaml Replaces variables help with placeholder table tooltips.
Source/NETworkManager/Views/PowerShellSettingsView.xaml Adds placeholder help tooltip.
Source/NETworkManager/Views/PowerShellConnectChildWindow.xaml Adds a 4th grid column + placeholder help tooltip.
Source/NETworkManager/Views/PuTTYSettingsView.xaml Adds placeholder help tooltip.
Source/NETworkManager/Views/PuTTYConnectChildWindow.xaml Adds placeholder help tooltip.
Source/NETworkManager.Localization/Resources/Strings.resx Adds placeholder/help keys; removes old variables help key.
Source/NETworkManager.Localization/Resources/Strings.Designer.cs Regenerated accessors for the new/removed keys.
Source/NETworkManager.Localization/Resources/StaticStrings.resx Example updated to {{Hostname}}.
Source/GlobalAssemblyInfo.cs Version bump to 2026.7.4.0.
Website/docs/application/web-console.md Documents {{Host}} in URL.
Website/docs/application/powershell.md Documents {{Host}} in command line fields.
Website/docs/application/putty.md Documents {{Host}}, incl. serial caveat.
Website/docs/application/ip-scanner.md Updates placeholder examples to {{...}}.
Website/docs/changelog/next-release.md Adds migration + profile placeholder notes.
Files not reviewed (1)
  • Source/NETworkManager.Localization/Resources/Strings.Designer.cs: Generated file

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

Comment on lines +18 to +19
var input = Regex.Replace(value as string ?? "", "\\{\\{host\\}\\}", "placeholder-host",
RegexOptions.IgnoreCase);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in the latest commit — replaced the inline Regex.Replace with PlaceholderHelper.Replace(…, PlaceholderHelper.Host, "placeholder-host") and dropped the now-unused System.Text.RegularExpressions import.

@mergify mergify Bot merged commit 6fcaebd into main Jul 5, 2026
4 checks passed
@mergify mergify Bot deleted the feature/437 branch July 5, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile - Add variable for Host/IP

3 participants