Browse Source

feat!: remove the Size alias that blocked the import next to other modules

The types file added the alias Size of LengthOnDisk to System.IO.FileInfo.
Type data can't replace an existing member, so in Windows PowerShell the
import failed when another module had added a Size member first (#82).

BREAKING CHANGE: use LengthOnDisk instead of Size.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: AI Assistant <ai@example.com>
pull/105/head
Raimund Andree 7 days ago
parent
commit
5b8ae9f19a
  1. 8
      .memory-bank/progress.md
  2. 4
      CHANGELOG.md
  3. 2
      Docs/Concepts.md
  4. 4
      NTFSSecurity/NTFSSecurity.types.ps1xml
  5. 16
      Tests/Manifest.Tests.ps1

8
.memory-bank/progress.md

@ -188,6 +188,8 @@ Numbered as agreed with the maintainer; each is documented on its page.
recurring questions.
- Review of #17: generic rights are removed the way .NET removes other
rights, an exact match as it is, otherwise without `Synchronize`.
- Open bugs: #5 (`-Attributes` matches all, `Get-ChildItem` any; needs a
decision), #34 and #67 (writes owner and group), #41 (drive root), #82
(`Size` type data), #90 (trailing space).
- Maintainer decisions of 2026-10-05: #5 (`Get-ChildItem2 -Attributes`
matches any listed attribute) and #82 (no `Size` alias) ship in 5.0.0 as
breaking changes.
- Open bugs: #34 and #67 (writes owner and group, rc3 if a file server is
available), #41 (drive root) and #90 (trailing space), both after 5.0.0.

4
CHANGELOG.md

@ -54,6 +54,10 @@ The format is based on
that had all of them. To get the old result, filter with `Where-Object`,
as the cmdlet page shows
([#5](https://github.com/raandree/NTFSSecurity/issues/5))
- **Breaking:** remove the alias `Size` of `LengthOnDisk` from the files of
`Get-ChildItem`, which made the import fail in Windows PowerShell when
another module had added a `Size` member; use `LengthOnDisk`
([#82](https://github.com/raandree/NTFSSecurity/issues/82))
### Deprecated

2
Docs/Concepts.md

@ -234,7 +234,7 @@ the AlphaFS objects that the `*-Item2` cmdlets return.
| --- | --- | --- | --- |
| `Owner` | Property | Files and folders | The owner of the item. |
| `IsInheritanceBlocked` | Property | Files and folders | `$true` if the item does not inherit access entries. |
| `LengthOnDisk` | Property | Files | The file size rounded up to whole clusters of the volume. `Size` is an alias. |
| `LengthOnDisk` | Property | Files | The file size rounded up to whole clusters of the volume. Before 5.0.0, `Size` was an alias. |
| `EnableInheritance()` | Method | Files and folders | Turns on access inheritance. |
| `DisableInheritance()` | Method | Files and folders | Turns off access inheritance. Pass `$false` to drop the inherited entries instead of copying them. |
| `GetHash()` | Method | Files | Returns the SHA1 hash of the file as a hexadecimal string. |

4
NTFSSecurity/NTFSSecurity.types.ps1xml

@ -23,10 +23,6 @@
[Math]::Ceiling($this.Length / ($driveInfo.BytesPerSector * $driveInfo.SectorsPerCluster)) * ($driveInfo.BytesPerSector * $driveInfo.SectorsPerCluster)
</GetScriptBlock>
</ScriptProperty>
<AliasProperty>
<Name>Size</Name>
<ReferencedMemberName>LengthOnDisk</ReferencedMemberName>
</AliasProperty>
<ScriptMethod>
<Name>EnableInheritance</Name>
<Script>

16
Tests/Manifest.Tests.ps1

@ -65,3 +65,19 @@ Describe 'Module manifest of NTFSSecurity' {
}
}
}
Describe 'Type data of NTFSSecurity' {
# Before 5.0.0, the types file added the alias Size to System.IO.FileInfo, so the import failed when another module
# had added a member with that name (#82). The module is imported in a child process, because type data stays in a
# session.
It 'Should import after another module added a Size member to System.IO.FileInfo' {
$manifestPath = Join-Path -Path $PSScriptRoot -ChildPath '..\NTFSSecurity\bin\Release\NTFSSecurity.psd1'
$executable = (Get-Process -Id $PID).Path
$command = 'Update-TypeData -TypeName System.IO.FileInfo -MemberType AliasProperty -MemberName Size -Value Length -Force; ' +
("Import-Module -Name '{0}' -ErrorAction Stop; 'IMPORTED'" -f $manifestPath.Replace("'", "''"))
$output = & $executable -NoProfile -NonInteractive -Command $command 2>&1
$output | Select-Object -Last 1 | Should -Be 'IMPORTED'
}
}
Loading…
Cancel
Save