From 5832fb0f2fb8b29389ac917f920f9660826710f7 Mon Sep 17 00:00:00 2001 From: Raimund Andree Date: Mon, 5 Oct 2026 02:13:06 +0200 Subject: [PATCH] refactor: remove members that nothing uses The privilege cmdlets declared a public Path property that was never a parameter, and Remove-Item2 declared a filter field that nothing read. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant --- NTFSSecurity/ItemCmdlets/RemoveItem2.cs | 1 - NTFSSecurity/OtherCmdlets.cs | 3 --- Tests/OutputTypes.Tests.ps1 | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NTFSSecurity/ItemCmdlets/RemoveItem2.cs b/NTFSSecurity/ItemCmdlets/RemoveItem2.cs index 252d80b..7a20364 100644 --- a/NTFSSecurity/ItemCmdlets/RemoveItem2.cs +++ b/NTFSSecurity/ItemCmdlets/RemoveItem2.cs @@ -10,7 +10,6 @@ namespace NTFSSecurity { private SwitchParameter force; private SwitchParameter recurse; - private string filter; private bool passThru; [Parameter(Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] diff --git a/NTFSSecurity/OtherCmdlets.cs b/NTFSSecurity/OtherCmdlets.cs index 82bba44..6cd18d3 100644 --- a/NTFSSecurity/OtherCmdlets.cs +++ b/NTFSSecurity/OtherCmdlets.cs @@ -14,7 +14,6 @@ namespace NTFSSecurity { private bool enablePrivileges = false; private SwitchParameter passThru; - public string[] Path { get; set; } [Parameter] public SwitchParameter PassThru @@ -71,7 +70,6 @@ namespace NTFSSecurity public class DisablePrivileges : BaseCmdletWithPrivControl { private SwitchParameter passThru; - public string[] Path { get; set; } [Parameter] public SwitchParameter PassThru @@ -120,7 +118,6 @@ namespace NTFSSecurity [OutputType(typeof(ProcessPrivileges.PrivilegeAndAttributes))] public class GetPrivileges : BaseCmdlet { - public string[] Path { get; set; } protected override void BeginProcessing() { diff --git a/Tests/OutputTypes.Tests.ps1 b/Tests/OutputTypes.Tests.ps1 index 643f668..c767c41 100644 --- a/Tests/OutputTypes.Tests.ps1 +++ b/Tests/OutputTypes.Tests.ps1 @@ -85,3 +85,18 @@ Describe 'New-NTFSSymbolicLink with -PassThru' { $result | Should -BeOfType [Alphaleonis.Win32.Filesystem.DirectoryInfo] } } + +Describe 'Cmdlet classes' { + # Before 5.0.0, these classes declared members that nothing used. + It '<_> should declare no Path property, which was never a parameter' -ForEach @( + 'Enable-Privileges', 'Disable-Privileges', 'Get-Privileges' + ) { + (Get-Command -Name $_).ImplementingType.GetProperty('Path') | Should -BeNullOrEmpty + } + + It 'Remove-Item2 should declare no filter field' { + $flags = [System.Reflection.BindingFlags]'NonPublic, Instance' + + (Get-Command -Name 'Remove-Item2').ImplementingType.GetField('filter', $flags) | Should -BeNullOrEmpty + } +} \ No newline at end of file