Feature: Add {{host}} variable to profile#3511
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
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
PlaceholderHelpercentralizes{{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}}"), aWebConsoleProfileUrlValidator, 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.
| var input = Regex.Replace(value as string ?? "", "\\{\\{host\\}\\}", "placeholder-host", | ||
| RegexOptions.IgnoreCase); |
There was a problem hiding this comment.
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.
Changes proposed in this pull request
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
PlaceholderHelperutility class to resolve case-insensitive{{Name}}placeholders in strings, replacing the previous ad-hoc regex usage.PlaceholderHelper.Resolvefor consistent placeholder substitution. [1] [2] [3] [4] [5]IPScannerCustomCommandand related resources to use{{IPAddress}}and{{Hostname}}instead of$ipaddress$and$hostname$. [1] [2]Migration and Backward Compatibility
SettingsManagerto automatically convert existing custom commands from the old$var$syntax to the new{{Var}}format on upgrade.Validation and Defaults
WebConsoleProfileUrlValidatorto allow the{{Host}}placeholder in the WebConsole URL field while ensuring valid URL structure.WebConsole_Urlto"https://{{Host}}"for new profiles.Localization and Resource Updates
Other
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: