Skip to content

Feature: Firewall app#3378

Closed
BornToBeRoot wants to merge 110 commits intomainfrom
feature/firewall
Closed

Feature: Firewall app#3378
BornToBeRoot wants to merge 110 commits intomainfrom
feature/firewall

Conversation

@BornToBeRoot
Copy link
Copy Markdown
Owner

Changes proposed in this pull request

  • Firewall feature

Related issue(s)

To-Do

Manuel Ullmann and others added 30 commits March 2, 2026 12:58
…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>
Copilot AI review requested due to automatic review settings April 10, 2026 19:49
@github-actions github-actions bot added this to the next-release milestone Apr 10, 2026
Copy link
Copy Markdown
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

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 value to string unconditionally (will throw if value is null/non-string), and FileRegex().IsMatch(filename) will throw if filename is null. If the intent is to make validation null-safe, update the code to handle value being null and avoid calling IsMatch with null.
using System.Globalization;

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

Comment on lines +8 to +13
private static Int32Validator Int32Validator
{
get
{
field ??= new Int32Validator();
return field;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
private static Int32Validator Int32Validator
{
get
{
field ??= new Int32Validator();
return field;
private static Int32Validator _int32Validator;
private static Int32Validator Int32Validator
{
get
{
_int32Validator ??= new Int32Validator();
return _int32Validator;

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +28
if (bindingExpression.DataItem is true)
return ValidationResult.ValidResult;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
if (bindingExpression.DataItem is true)
return ValidationResult.ValidResult;

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +20
/// 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.
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
/// 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.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +44
if (viewModel.UserDefinedName.Length <= viewModel.MaxLengthName)
{
viewModel.NameHasError = false;
return ValidationResult.ValidResult;
}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +45
if (value is not Enum enumValue)
{
string fallback = Enum.ToObject(targetType, 255) as string;
if (value is not string strVal)
return fallback;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
{
try
{
var ruleSb = new StringBuilder($"New-NetFirewallRule -DisplayName '{SanitizeStringArguments(rule.Name)}'");
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +126 to +137
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_*'";
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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}*'";

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +157
public async Task ApplyRulesAsync(List<FirewallRule> rules)
{
await Task.Run(() => ApplyRules(rules));
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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));

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +33
#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()
{

}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
#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()
{
}

Copilot uses AI. Check for mistakes.
namespace NETworkManager.Controls;

/// <summary>
/// Static class to profile strings for Enum translations.
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Correct the summary text: 'profile' appears to be a typo in this context.

Suggested change
/// Static class to profile strings for Enum translations.
/// Static class to provide strings for Enum translations.

Copilot uses AI. Check for mistakes.
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.

2 participants