Index: Core/Common/test/Core.Common.TestUtil/DirectoryPermissionsRevoker.cs =================================================================== diff -u -r28abea0fa843f62a5c0835cba5831cf2206abc5d -r78150a523f1464cd3a834c03c301e802a17d52fc --- Core/Common/test/Core.Common.TestUtil/DirectoryPermissionsRevoker.cs (.../DirectoryPermissionsRevoker.cs) (revision 28abea0fa843f62a5c0835cba5831cf2206abc5d) +++ Core/Common/test/Core.Common.TestUtil/DirectoryPermissionsRevoker.cs (.../DirectoryPermissionsRevoker.cs) (revision 78150a523f1464cd3a834c03c301e802a17d52fc) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security; using System.Security.AccessControl; using System.Security.Principal; @@ -51,6 +52,9 @@ /// does not exist. /// Thrown when the is /// not supported to set on the folder. + /// Thrown when exceed the + /// system-defined maximum length. + /// Thrown when the caller does not have the required permissions. public DirectoryPermissionsRevoker(string folderPath, FileSystemRights rights) { if (string.IsNullOrWhiteSpace(folderPath)) @@ -68,7 +72,7 @@ if ((rights ^ FileSystemRights.Synchronize) == 0) { // The FileSystemRights Synchronize by itself cannot be set. - throw new NotSupportedException(string.Format("Setting the right {0} is not supported.", rights)); + throw new NotSupportedException($"Setting the right {rights} is not supported."); } AddDenyDirectoryInfoRight(GetSupportedFileSystemRights(rights)); } @@ -90,7 +94,7 @@ { foreach (FileSystemAccessRule appliedFileSystemAccessRule in appliedFileSystemAccessRules) { - RevertDenyDirectoryInfoRight(appliedFileSystemAccessRule); + TryRevertDenyDirectoryInfoRight(appliedFileSystemAccessRule); } } @@ -126,13 +130,20 @@ return rights & ~FileSystemRights.Synchronize; } - private void RevertDenyDirectoryInfoRight(FileSystemAccessRule rule) + private void TryRevertDenyDirectoryInfoRight(FileSystemAccessRule rule) { - DirectorySecurity directorySecurity = directoryInfo.GetAccessControl(); + try + { + DirectorySecurity directorySecurity = directoryInfo.GetAccessControl(); - directorySecurity.RemoveAccessRule(rule); + directorySecurity.RemoveAccessRule(rule); - directoryInfo.SetAccessControl(directorySecurity); + directoryInfo.SetAccessControl(directorySecurity); + } + catch (SystemException) + { + // Ignored + } } private static SecurityIdentifier GetSecurityIdentifier() Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsConnectionDialog.cs =================================================================== diff -u -r8ed20afbbecb8d353372e6623e7bbf68cdee543c -r78150a523f1464cd3a834c03c301e802a17d52fc --- Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsConnectionDialog.cs (.../WmtsConnectionDialog.cs) (revision 8ed20afbbecb8d353372e6623e7bbf68cdee543c) +++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsConnectionDialog.cs (.../WmtsConnectionDialog.cs) (revision 78150a523f1464cd3a834c03c301e802a17d52fc) @@ -33,36 +33,24 @@ public partial class WmtsConnectionDialog : DialogBase { /// - /// Creates a new instance of . + /// Creates a new instance of in edit mode. /// /// The parent of the dialog. + /// The information to set in the input boxes. /// Thrown when is null. - public WmtsConnectionDialog(IWin32Window dialogParent) : base(dialogParent, Resources.MapsIcon, 400, 150) + public WmtsConnectionDialog(IWin32Window dialogParent, WmtsConnectionInfo wmtsConnectionInfo = null) + : base(dialogParent, Resources.MapsIcon, 400, 150) { InitializeComponent(); - UpdateActionButton(); - InitializeEventHandlers(); - InitializeErrorProvider(); - } - - /// - /// Creates a new instance of in edit mode. - /// - /// The parent of the dialog. - /// The information to set in the input boxes. - /// Thrown when any of the input parameters is null. - public WmtsConnectionDialog(IWin32Window dialogParent, WmtsConnectionInfo wmtsConnectionInfo) : this(dialogParent) - { - if (wmtsConnectionInfo == null) + if (wmtsConnectionInfo != null) { - throw new ArgumentNullException(nameof(wmtsConnectionInfo)); + SetWmtsConnectionInfo(wmtsConnectionInfo); } - nameTextBox.Text = wmtsConnectionInfo.Name; - urlTextBox.Text = wmtsConnectionInfo.Url; - actionButton.Text = Resources.WmtsConnectionDialog_ActionButton_Edit; - Text = Resources.WmtsConnectionDialog_Text_Edit; + UpdateActionButton(); + InitializeEventHandlers(); + InitializeErrorProvider(); } /// @@ -89,6 +77,14 @@ return cancelButton; } + private void SetWmtsConnectionInfo(WmtsConnectionInfo wmtsConnectionInfo) + { + nameTextBox.Text = wmtsConnectionInfo.Name; + urlTextBox.Text = wmtsConnectionInfo.Url; + actionButton.Text = Resources.WmtsConnectionDialog_ActionButton_Edit; + Text = Resources.WmtsConnectionDialog_Text_Edit; + } + private void InitializeErrorProvider() { urlTooltipErrorProvider.SetError(urlLabel, Resources.WmtsConnectionDialog_UrlErrorProvider_HelpText); Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsConnectionDialogTest.cs =================================================================== diff -u -r2650526158a18c2ac5bf518957e5fa260d882538 -r78150a523f1464cd3a834c03c301e802a17d52fc --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsConnectionDialogTest.cs (.../WmtsConnectionDialogTest.cs) (revision 2650526158a18c2ac5bf518957e5fa260d882538) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsConnectionDialogTest.cs (.../WmtsConnectionDialogTest.cs) (revision 78150a523f1464cd3a834c03c301e802a17d52fc) @@ -59,23 +59,6 @@ } [Test] - public void WmtsConnectionInfoConstructor_WithoutWmtsConnectionInfo_ThrowsArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var dialogParent = mocks.StrictMock(); - mocks.ReplayAll(); - - // Call - TestDelegate test = () => new WmtsConnectionDialog(dialogParent, null); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("wmtsConnectionInfo", paramName); - mocks.VerifyAll(); - } - - [Test] public void Constructor_WithDialogParent_ExpectedProperties() { // Setup