falahati / WindowsFirewallHelper

A class library to manage the Windows Firewall as well as adding your program to the Windows Firewall Exception list.
MIT License
274 stars 72 forks source link

Add TryGetInstance and TryGetRegisteredProducts methods #45

Closed paulirwin closed 3 years ago

paulirwin commented 3 years ago

The static Instance and RegisteredProducts properties can throw in some cases. This adds safer Try versions that prevent having to add try/catch in the calling code. Added unit tests for these methods, although given the current implementation, these do not represent 100% coverage since the branch may vary depending on the machine on which it is run.

Updated test app to .NET Core 3.1 (previously was 2.2, which is no longer supported) and updated the NuGet dependencies for the test project so that it can be run on the latest VS2019.