Browse Source

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 <ai@example.com>
pull/103/head
Raimund Andree 7 days ago
parent
commit
5832fb0f2f
  1. 1
      NTFSSecurity/ItemCmdlets/RemoveItem2.cs
  2. 3
      NTFSSecurity/OtherCmdlets.cs
  3. 15
      Tests/OutputTypes.Tests.ps1

1
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)]

3
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()
{

15
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
}
}
Loading…
Cancel
Save