Conversation
…ratedRegex. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…o 500. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…Remove duplicates. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…f Int16.MaxValue by creating temporary scripts when necessary. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…ace. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…ences and for typed binding proxies. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…ties passed as parameter for null, empty strings or empty enumerables. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…anges. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
… simplify merge conflicts. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…ratedRegex. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…by refactoring. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
…ion mapping in ProfileChildWindow. Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
Signed-off-by: Manuel Ullmann <manuel.ullmann@rediecon.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Implements an initial “Firewall” application feature and associated UI/validation infrastructure, while also refactoring many ViewModels to use auto-properties with the field backing keyword.
Changes:
- Adds Firewall domain models, view-model interfaces, converters, validators, and wiring into profiles/settings/documentation.
- Updates WPF validation templates/styles and introduces binding/validation helper utilities.
- Large refactor across many ViewModels/controls to replace explicit backing fields with auto-properties using
field.
Reviewed changes
Copilot reviewed 145 out of 217 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/NETworkManager/ViewModels/ProfileFileViewModel.cs | Refactors properties to auto-properties using field. |
| Source/NETworkManager/ViewModels/PowerShellSettingsViewModel.cs | Refactors properties; keeps settings persistence behavior. |
| Source/NETworkManager/ViewModels/PowerShellConnectViewModel.cs | Refactors properties and initializes collections inline. |
| Source/NETworkManager/ViewModels/PortScannerViewModel.cs | Refactors properties and collection initializers. |
| Source/NETworkManager/ViewModels/PortScannerSettingsViewModel.cs | Refactors settings-backed properties. |
| Source/NETworkManager/ViewModels/PortProfilesViewModel.cs | Refactors properties and search selection formatting. |
| Source/NETworkManager/ViewModels/PortProfileViewModel.cs | Refactors properties; preserves validation flow. |
| Source/NETworkManager/ViewModels/PingMonitorViewModel.cs | Refactors properties to auto-properties using field. |
| Source/NETworkManager/ViewModels/PingMonitorSettingsViewModel.cs | Refactors settings-backed properties. |
| Source/NETworkManager/ViewModels/MessageViewModel.cs | Refactors init-only properties to use field. |
| Source/NETworkManager/ViewModels/MessageConfirmationViewModel.cs | Refactors init-only properties to use field. |
| Source/NETworkManager/ViewModels/LookupPortViewModel.cs | Refactors properties and collection initializers. |
| Source/NETworkManager/ViewModels/LookupOUILookupViewModel.cs | Refactors properties and collection initializers. |
| Source/NETworkManager/ViewModels/ListenersViewModel.cs | Refactors properties; keeps auto-refresh logic. |
| Source/NETworkManager/ViewModels/IPScannerViewModel.cs | Refactors properties and collection initializers. |
| Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs | Refactors properties and result/status fields. |
| Source/NETworkManager/ViewModels/IPApiIPGeolocationWidgetViewModel.cs | Refactors properties to auto-properties using field. |
| Source/NETworkManager/ViewModels/IPApiDNSResolverWidgetViewModel.cs | Refactors properties to auto-properties using field. |
| Source/NETworkManager/ViewModels/IPAddressViewModel.cs | Refactors shared IPAddress input property. |
| Source/NETworkManager/ViewModels/IPAddressAndSubnetmaskViewModel.cs | Refactors IP/subnet properties. |
| Source/NETworkManager/ViewModels/HostsFileEditorViewModel.cs | Refactors properties and collection initializers. |
| Source/NETworkManager/ViewModels/HostsFileEditorEntryViewModel.cs | Refactors entry editor properties. |
| Source/NETworkManager/ViewModels/FirewallSettingsViewModel.cs | Adds placeholder settings ViewModel for Firewall. |
| Source/NETworkManager/ViewModels/ExportViewModel.cs | Refactors many option properties; preserves format toggling behavior. |
| Source/NETworkManager/ViewModels/DropdownViewModel.cs | Refactors selection properties. |
| Source/NETworkManager/ViewModels/DiscoveryProtocolViewModel.cs | Refactors properties and initializes lists inline. |
| Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs | Refactors settings-backed dashboard properties. |
| Source/NETworkManager/ViewModels/CustomCommandViewModel.cs | Refactors properties using field; keeps change tracking. |
| Source/NETworkManager/ViewModels/CredentialsSetPasswordViewModel.cs | Refactors secure string properties; preserves validation flags defaults. |
| Source/NETworkManager/ViewModels/CredentialsPasswordViewModel.cs | Refactors secure string properties; preserves validation flags defaults. |
| Source/NETworkManager/ViewModels/CredentialsPasswordProfileFileViewModel.cs | Refactors properties; keeps repeated validation. |
| Source/NETworkManager/ViewModels/CredentialsChangePasswordViewModel.cs | Refactors properties; preserves defaults and validation flags. |
| Source/NETworkManager/ViewModels/ConnectionsViewModel.cs | Refactors properties; keeps auto-refresh logic. |
| Source/NETworkManager/ViewModels/CommandLineViewModel.cs | Refactors command-line parameter message properties. |
| Source/NETworkManager/ViewModels/BitCalculatorViewModel.cs | Refactors calculator properties and initializes defaults inline. |
| Source/NETworkManager/ViewModels/BitCalculatorSettingsViewModel.cs | Refactors notation selection property. |
| Source/NETworkManager/ViewModels/AboutViewModel.cs | Refactors update-related and selection properties. |
| Source/NETworkManager/ViewModels/ARPTableViewModel.cs | Refactors properties; keeps auto-refresh logic. |
| Source/NETworkManager/ViewModels/ARPTableAddEntryViewModel.cs | Refactors IP/MAC input properties. |
| Source/NETworkManager/StatusWindow.xaml.cs | Refactors DP-like properties to auto-properties using field. |
| Source/NETworkManager/Resources/Templates/ValidationErrorTemplates.xaml | Adds new popup-close behavior and introduces OuterOffsetErrorTemplate. |
| Source/NETworkManager/Resources/Styles/ChildWindowStyles.xaml | Changes child window sizing setter. |
| Source/NETworkManager/Resources/Styles/CheckBoxStyles.xaml | Applies new validation error template to CheckBox. |
| Source/NETworkManager/ProfileDialogManager.cs | Persists Firewall_Enabled into ProfileInfo serialization. |
| Source/NETworkManager/NETworkManager.csproj | Wires new firewall controls and adds Interfaces project reference. |
| Source/NETworkManager/Controls/WebConsoleControl.xaml.cs | Refactors loading/url properties; preserves default FirstLoad. |
| Source/NETworkManager/Controls/TigerVNCControl.xaml.cs | Refactors connection state properties. |
| Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs | Refactors size/connection properties. |
| Source/NETworkManager/Controls/PuTTYControl.xaml.cs | Refactors connection state properties. |
| Source/NETworkManager/Controls/PowerShellControl.xaml.cs | Refactors connection state properties. |
| Source/NETworkManager/Controls/LvlChartsWiFiChannelTooltip.xaml.cs | Refactors tooltip Data property. |
| Source/NETworkManager/Controls/LvlChartsPingTimeTooltip.xaml.cs | Refactors tooltip Data property. |
| Source/NETworkManager/Controls/LvlChartsBandwidthTooltip.xaml.cs | Refactors tooltip Data property. |
| Source/NETworkManager/Controls/FirewallRuleEnumTranslations.cs | Adds enum-to-localized-string helpers for firewall rule UI. |
| Source/NETworkManager/Controls/DragablzTabItem.cs | Refactors Header property to auto-property using field. |
| Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs | Refactors properties and improves error message formatting. |
| Source/NETworkManager.sln | Adds new NETworkManager.Interfaces project to solution. |
| Source/NETworkManager.Validators/ProgramNameLengthValidator.cs | Adds max-length validation for program name inputs. |
| Source/NETworkManager.Validators/NETworkManager.Validators.csproj | Adds Interfaces project reference. |
| Source/NETworkManager.Validators/FirewallRuleNoPipeValidator.cs | Adds validation preventing ` |
| Source/NETworkManager.Validators/FirewallRuleNameValidator.cs | Adds validation for firewall rule user-defined name length. |
| Source/NETworkManager.Validators/FileNameValidator.cs | Switches to GeneratedRegex-based filename validation. |
| Source/NETworkManager.Validators/EmptyOrInt32Validator.cs | Adds “empty or int” validation wrapper. |
| Source/NETworkManager.Validators/EmptyOrFirewallPortRangeValidator.cs | Adds firewall port-range validator (empty allowed). |
| Source/NETworkManager.Validators/EmptyOrFilePathValidator.cs | Adds “empty or filepath” validation wrapper. |
| Source/NETworkManager.Validators/EmptyOrFileIsExeValidator.cs | Adds “empty or .exe” validation rule. |
| Source/NETworkManager.Validators/EmptyOrFileExistsValidator.cs | Refactors to delegate to shared FileExistsValidator. |
| Source/NETworkManager.Validators/AnyNetworkProfileValidator.cs | Adds validation ensuring at least one network profile is selected. |
| Source/NETworkManager.Utilities/PowerShellHelper.cs | Adds temp-script fallback for long PowerShell commands and UAC cancel handling. |
| Source/NETworkManager.Utilities/ListHelper.cs | Generalizes list history helper to generic method and documents behavior. |
| Source/NETworkManager.Utilities/ExternalProcessStarter.cs | Adds docs and overload documentation for process launching. |
| Source/NETworkManager.Utilities.WPF/ValidationHelper.cs | Adds attached properties to propagate validation error state to VM. |
| Source/NETworkManager.Utilities.WPF/TypedBindingProxies/ProfileViewModelProxy.cs | Adds strongly-typed binding proxy for IProfileViewModel. |
| Source/NETworkManager.Utilities.WPF/TypedBindingProxies/FrameworkElementProxy.cs | Adds strongly-typed binding proxy for FrameworkElement. |
| Source/NETworkManager.Utilities.WPF/TypedBindingProxies/FirewallViewModelProxy.cs | Adds strongly-typed binding proxy for IFirewallViewModel. |
| Source/NETworkManager.Utilities.WPF/NETworkManager.Utilities.WPF.csproj | Adds Interfaces project reference. |
| Source/NETworkManager.Utilities.WPF/BindingProxy.cs | Documents and modernizes DP registration. |
| Source/NETworkManager.Settings/SettingsViewManager.cs | Adds Firewall settings view entry and modernizes list initialization. |
| Source/NETworkManager.Settings/SettingsViewInfo.cs | Adds documentation for settings view info. |
| Source/NETworkManager.Settings/SettingsName.cs | Adds Firewall settings enum entry. |
| Source/NETworkManager.Settings/SettingsManager.cs | Inserts Firewall app into application list during upgrade. |
| Source/NETworkManager.Settings/LocalSettingsInfo.cs | Refactors Settings_FolderLocation property. |
| Source/NETworkManager.Profiles/ProfileViewManager.cs | Adds Firewall profile view entry and documents list behavior. |
| Source/NETworkManager.Profiles/ProfileViewInfo.cs | Adds documentation for profile view info. |
| Source/NETworkManager.Profiles/ProfileName.cs | Adds Firewall profile enum entry. |
| Source/NETworkManager.Profiles/ProfileManager.cs | Refactors loaded profile properties to auto-properties and initializes data inline. |
| Source/NETworkManager.Profiles/ProfileInfo.cs | Adds Firewall_Enabled and Firewall_Rules to stored profile. |
| Source/NETworkManager.Profiles/ProfileFilterTagsInfo.cs | Refactors IsSelected property. |
| Source/NETworkManager.Profiles/ProfileFileInfo.cs | Refactors properties to auto-properties using field. |
| Source/NETworkManager.Profiles/ProfileFileData.cs | Refactors Version/LastBackup properties and default initialization. |
| Source/NETworkManager.Profiles/IProfileManagerMinimal.cs | Updates comments and keeps default interface methods. |
| Source/NETworkManager.Profiles/IProfileManager.cs | Documents profile manager interface members. |
| Source/NETworkManager.Models/Network/NetworkProfiles.cs | Adds enum representing Windows network profile category. |
| Source/NETworkManager.Models/Network/NetworkInterfaceInfo.cs | Adds placeholder/comment for future profile/category integration. |
| Source/NETworkManager.Models/Network/BandwidthMeter.cs | Refactors UpdateInterval to auto-property with default. |
| Source/NETworkManager.Models/Firewall/FirewallRuleProgram.cs | Adds model for rule program target and serialization behavior. |
| Source/NETworkManager.Models/Firewall/FirewallRuleDirection.cs | Adds direction enum for rules. |
| Source/NETworkManager.Models/Firewall/FirewallRuleAction.cs | Adds action enum for rules. |
| Source/NETworkManager.Models/Firewall/FirewallRule.cs | Adds core firewall rule model and port serialization helper. |
| Source/NETworkManager.Models/Firewall/FirewallProtocol.cs | Adds protocol enum (IANA numbers). |
| Source/NETworkManager.Models/Firewall/FirewallPortSpecification.cs | Adds port range specification model. |
| Source/NETworkManager.Models/Firewall/FirewallPortLocation.cs | Adds enum distinguishing local vs remote ports. |
| Source/NETworkManager.Models/Firewall/FirewallInterfaceType.cs | Adds interface type enum for firewall rules. |
| Source/NETworkManager.Models/Firewall/Firewall.cs | Adds rule application logic using PowerShell commands. |
| Source/NETworkManager.Models/ApplicationName.cs | Adds Firewall application enum entry. |
| Source/NETworkManager.Models/ApplicationManager.cs | Adds Firewall icon selection. |
| Source/NETworkManager.Models/ApplicationInfo.cs | Refactors visibility/default properties to auto-properties using field. |
| Source/NETworkManager.Interfaces/ViewModels/IProfileViewModel.cs | Adds interface for profile-VM access used by validators/bindings. |
| Source/NETworkManager.Interfaces/ViewModels/IFirewallViewModel.cs | Adds interface for firewall-VM access. |
| Source/NETworkManager.Interfaces/ViewModels/IFirewallRuleViewModel.cs | Adds interface for firewall rule-VM access for validators/converters. |
| Source/NETworkManager.Interfaces/NETworkManager.Interfaces.csproj | Introduces new Interfaces project. |
| Source/NETworkManager.Documentation/DocumentationManager.cs | Adds docs identifiers/paths for Hosts File Editor and Firewall. |
| Source/NETworkManager.Documentation/DocumentationIdentifier.cs | Adds documentation identifiers for Hosts File Editor and Firewall. |
| Source/NETworkManager.Converters/SizeFactorConverter.cs | Adds size scaling converter for XAML sizing. |
| Source/NETworkManager.Converters/PortRangeToPortSpecificationConverter.cs | Adds converter between string port ranges and port spec list. |
| Source/NETworkManager.Converters/NETworkManager.Converters.csproj | Adds Interfaces project reference. |
| Source/NETworkManager.Converters/IntZeroToFalseConverter.cs | Adds converter between int(0/1) and bool. |
| Source/NETworkManager.Converters/FirewallRuleProgramConverter.cs | Adds converter between program path and FirewallRuleProgram. |
| Source/NETworkManager.Converters/EnumToStringConverter.cs | Adds localized enum-to-string converter (two-way). |
| Source/NETworkManager.Converters/EnumToIntConverter.cs | Adds enum-to-index converter (two-way). |
| Source/NETworkManager.Converters/EmptyToIntMaxValueConverter.cs | Adds converter mapping empty to int.MaxValue and back. |
| Source/NETworkManager.Converters/CollectionPropertyVisibilityConverter.cs | Adds reflection-based “any item has content” visibility converter. |
| Source/NETworkManager.Converters/CollectionPropertyBooleanOrConverter.cs | Adds reflection-based “any item property true” boolean-or converter. |
| Source/NETworkManager.Converters/BooleansOrConverter.cs | Makes boolean OR converter null/type safe. |
| Source/NETworkManager.Converters/BoolArrayToFwRuleCategoriesConverter.cs | Adds converter to display network profiles based on bool array. |
| Source/GlobalAssemblyInfo.cs | Bumps assembly version. |
| Source/CLAUDE.md | Adds pointer to AGENTS.md (repo root guidelines). |
| CLAUDE.md | Adds pointer to AGENTS.md (repo root guidelines). |
Files not reviewed (1)
- Source/NETworkManager/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)
Source/NETworkManager.Validators/FileNameValidator.cs:1
- This still casts
valueto string unconditionally (will throw ifvalueis null/non-string), andFileRegex().IsMatch(filename)will throw iffilenameis null. If the intent is to make validation null-safe, update the code to handlevaluebeing null and avoid callingIsMatchwith null.
using System.Globalization;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private static Int32Validator Int32Validator | ||
| { | ||
| get | ||
| { | ||
| field ??= new Int32Validator(); | ||
| return field; |
There was a problem hiding this comment.
This uses the field keyword inside a property that does not have an auto-generated backing field (it has only a getter with a body). That will not compile. Replace this with an explicit private static backing field (e.g., _int32Validator) and reference that instead. The same pattern appears in other new validators (e.g., EmptyOrFilePathValidator / EmptyOrFileExistsValidator) and should be corrected there too.
| private static Int32Validator Int32Validator | |
| { | |
| get | |
| { | |
| field ??= new Int32Validator(); | |
| return field; | |
| private static Int32Validator _int32Validator; | |
| private static Int32Validator Int32Validator | |
| { | |
| get | |
| { | |
| _int32Validator ??= new Int32Validator(); | |
| return _int32Validator; |
| if (bindingExpression.DataItem is true) | ||
| return ValidationResult.ValidResult; |
There was a problem hiding this comment.
The condition if (bindingExpression.DataItem is true) is effectively unreachable because DataItem is the VM (or null), not a boolean. This makes the logic misleading and may hide the intended early-exit condition. If you meant to short-circuit based on the changed checkbox value, check bindingExpression.Value/bindingExpression.ResolvedSourcePropertyName or validate based on viewModel state only. Also consider moving the hard-coded error string to a localized resource (same message is duplicated in other validators).
| if (bindingExpression.DataItem is true) | |
| return ValidationResult.ValidResult; |
| /// Ensures the value meets specific criteria for validity: | ||
| /// - The character '|' is not allowed. | ||
| /// - The string length does not exceed 9999 characters. | ||
| /// </summary> | ||
| public class FirewallRuleNameValidator : ValidationRule | ||
| { | ||
| /// <summary> | ||
| /// Validates a string based on the following two conditions: | ||
| /// - The string must not contain the '|' character. | ||
| /// - The string must not exceed a length of 9999 characters. |
There was a problem hiding this comment.
The XML documentation states that the validator also rejects the | character, but the implementation only checks length. Either implement the | validation (and set NameHasError accordingly) or update the docstring to match the actual behavior.
| /// Ensures the value meets specific criteria for validity: | |
| /// - The character '|' is not allowed. | |
| /// - The string length does not exceed 9999 characters. | |
| /// </summary> | |
| public class FirewallRuleNameValidator : ValidationRule | |
| { | |
| /// <summary> | |
| /// Validates a string based on the following two conditions: | |
| /// - The string must not contain the '|' character. | |
| /// - The string must not exceed a length of 9999 characters. | |
| /// Ensures the value does not exceed the configured maximum length. | |
| /// </summary> | |
| public class FirewallRuleNameValidator : ValidationRule | |
| { | |
| /// <summary> | |
| /// Validates that the user-defined name does not exceed the configured maximum length. |
| if (viewModel.UserDefinedName.Length <= viewModel.MaxLengthName) | ||
| { | ||
| viewModel.NameHasError = false; | ||
| return ValidationResult.ValidResult; | ||
| } |
There was a problem hiding this comment.
The XML documentation states that the validator also rejects the | character, but the implementation only checks length. Either implement the | validation (and set NameHasError accordingly) or update the docstring to match the actual behavior.
| if (value is not Enum enumValue) | ||
| { | ||
| string fallback = Enum.ToObject(targetType, 255) as string; | ||
| if (value is not string strVal) | ||
| return fallback; |
There was a problem hiding this comment.
This converter mixes return types in a way that will break two-way bindings: when converting back from string to enum, failures return the input string (fallback = strVal) instead of an enum value, causing binding type mismatch. Additionally, Enum.ToObject(targetType, 255) as string will always be null (the result is an enum, not a string). Consider splitting logic based on targetType.IsEnum / value and always returning an enum instance for ConvertBack, with a safe default enum value when parsing fails.
| { | ||
| try | ||
| { | ||
| var ruleSb = new StringBuilder($"New-NetFirewallRule -DisplayName '{SanitizeStringArguments(rule.Name)}'"); |
There was a problem hiding this comment.
The cleanup command removes rules with a display name matching NwM_*, but newly created rules use -DisplayName '{rule.Name}' without enforcing that prefix. This means ApplyRules will not actually clear previously created rules unless the UI guarantees the NwM_ prefix. To make this robust, either prefix all created rule display names (e.g., NwM_{rule.Name}) or adjust the delete filter to match the actual naming scheme.
| public static void ClearAllRules() | ||
| { | ||
| PowerShellHelper.ExecuteCommand(GetClearAllRulesCommand(), true); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Generates a command string that removes all Windows Firewall rules with a display name starting with 'NwM_'. | ||
| /// </summary> | ||
| /// <returns>A command string that can be executed in PowerShell to remove the specified firewall rules.</returns> | ||
| private static string GetClearAllRulesCommand() | ||
| { | ||
| return "Remove-NetFirewallRule -DisplayName 'NwM_*'"; |
There was a problem hiding this comment.
The cleanup command removes rules with a display name matching NwM_*, but newly created rules use -DisplayName '{rule.Name}' without enforcing that prefix. This means ApplyRules will not actually clear previously created rules unless the UI guarantees the NwM_ prefix. To make this robust, either prefix all created rule display names (e.g., NwM_{rule.Name}) or adjust the delete filter to match the actual naming scheme.
| public static void ClearAllRules() | |
| { | |
| PowerShellHelper.ExecuteCommand(GetClearAllRulesCommand(), true); | |
| } | |
| /// <summary> | |
| /// Generates a command string that removes all Windows Firewall rules with a display name starting with 'NwM_'. | |
| /// </summary> | |
| /// <returns>A command string that can be executed in PowerShell to remove the specified firewall rules.</returns> | |
| private static string GetClearAllRulesCommand() | |
| { | |
| return "Remove-NetFirewallRule -DisplayName 'NwM_*'"; | |
| private const string ManagedRuleDisplayNamePrefix = "NwM_"; | |
| public static void ClearAllRules() | |
| { | |
| PowerShellHelper.ExecuteCommand(GetClearAllRulesCommand(), true); | |
| } | |
| /// <summary> | |
| /// Generates the managed display name used for firewall rules created by NETworkManager. | |
| /// </summary> | |
| /// <param name="ruleName">The raw firewall rule name.</param> | |
| /// <returns>The managed display name with the NETworkManager prefix applied.</returns> | |
| private static string GetManagedRuleDisplayName(string ruleName) | |
| { | |
| return $"{ManagedRuleDisplayNamePrefix}{ruleName}"; | |
| } | |
| /// <summary> | |
| /// Generates a command string that removes all Windows Firewall rules with a display name starting with the NETworkManager prefix. | |
| /// </summary> | |
| /// <returns>A command string that can be executed in PowerShell to remove the specified firewall rules.</returns> | |
| private static string GetClearAllRulesCommand() | |
| { | |
| return $"Remove-NetFirewallRule -DisplayName '{ManagedRuleDisplayNamePrefix}*'"; |
| public async Task ApplyRulesAsync(List<FirewallRule> rules) | ||
| { | ||
| await Task.Run(() => ApplyRules(rules)); |
There was a problem hiding this comment.
ApplyRulesAsync drops the bool success value returned by ApplyRules, and the XML comment suggests the caller can know whether applying succeeded. Consider returning Task<bool> (or throwing on failure) so callers can react to errors; otherwise update the documentation and/or add logging/telemetry for failures.
| public async Task ApplyRulesAsync(List<FirewallRule> rules) | |
| { | |
| await Task.Run(() => ApplyRules(rules)); | |
| public async Task<bool> ApplyRulesAsync(List<FirewallRule> rules) | |
| { | |
| return await Task.Run(() => ApplyRules(rules)); |
| #region Variables | ||
| /// <summary> | ||
| /// Indicates whether the view model is loading. | ||
| /// </summary> | ||
| private readonly bool _isLoading; | ||
| #endregion | ||
|
|
||
| #region Constructor, load settings | ||
| /// <summary> | ||
| /// Construct the view model and load settings. | ||
| /// </summary> | ||
| public FirewallSettingsViewModel() | ||
| { | ||
| _isLoading = true; | ||
|
|
||
| LoadSettings(); | ||
|
|
||
| _isLoading = false; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Load the settings via <see cref="SettingsManager"/>. | ||
| /// </summary> | ||
| private void LoadSettings() | ||
| { | ||
|
|
||
| } |
There was a problem hiding this comment.
FirewallSettingsViewModel is currently a stub (LoadSettings is empty). If this is intended to ship with the Firewall feature, it should either be implemented (reading/writing SettingsManager values) or removed until the settings surface is ready to avoid dead/placeholder code in the main app.
| #region Variables | |
| /// <summary> | |
| /// Indicates whether the view model is loading. | |
| /// </summary> | |
| private readonly bool _isLoading; | |
| #endregion | |
| #region Constructor, load settings | |
| /// <summary> | |
| /// Construct the view model and load settings. | |
| /// </summary> | |
| public FirewallSettingsViewModel() | |
| { | |
| _isLoading = true; | |
| LoadSettings(); | |
| _isLoading = false; | |
| } | |
| /// <summary> | |
| /// Load the settings via <see cref="SettingsManager"/>. | |
| /// </summary> | |
| private void LoadSettings() | |
| { | |
| } | |
| #region Constructor | |
| /// <summary> | |
| /// Construct the view model. | |
| /// </summary> | |
| public FirewallSettingsViewModel() | |
| { | |
| } |
| namespace NETworkManager.Controls; | ||
|
|
||
| /// <summary> | ||
| /// Static class to profile strings for Enum translations. |
There was a problem hiding this comment.
Correct the summary text: 'profile' appears to be a typo in this context.
| /// Static class to profile strings for Enum translations. | |
| /// Static class to provide strings for Enum translations. |
Changes proposed in this pull request
Related issue(s)
To-Do