Skip to content

Behavior changed about filesystemInfo.Attributes in .NET Core preview2/3 causes 2 tests to fail in Get-ChildItem.Tests.ps1 #4145

@daxian-dbw

Description

@daxian-dbw

In 2.0.0-preview1 .NET Core, filesystemInfo.Attributes raises an FileNotFoundException exception when the file is deleted or renamed during the enumration.
In 2.0.0-preview2/3 .NET Core, filesystemInfo.Attributes returns -1 without raising any exception.
This behavior change was by design -- to align with the current behavior on Full .NET. For detailed information, please see https://github.com/dotnet/corefx/issues/20456.

This behavior change causes the following tests to fail in test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 (they will be marked as pending for now):

  • "Should continue enumerating a directory when a contained item is deleted"
  • "Should continue enumerating a directory when a contained item is renamed"

These 2 tests were added in PR #3806, which assumes that the FileNotFoundException will be thrown in case the file is deleted or renamed during enumeration. Since the behavior has changed in .NET Core, the fix needs to be revisited.

/cc @jeffbi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedThe issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions