Skip to content

LinkType property on IO.DirectoryInfo and IO.FileInfo objects has incorrect value when instantiating instances to non-existing directories and files #15278

@devblackops

Description

@devblackops

With pwsh on macOS and Linux, the LinkType property on IO.DirectoryInfo IO.FileInfo objects have a value of SymbolicLink when creating objects to non-existent directories or files. In Windows PowerShell and pwsh on Windows 10, LinkType is null. I would expect pwsh on macOS/Linux to behave the same.

Steps to reproduce

pwsh 7.1.3 on macOS and Linux

[IO.DirectoryInfo]::new('doesnotexist') | Format-List
[IO.FileInfo]::new('doesnotexist') | Format-List

Expected behavior

pwsh 7.1.3 on Windows 10

> [IO.DirectoryInfo]::new('doesnotexist') | Format-List

Name           : doesnotexist
CreationTime   : 12/31/1600 4:00:00 PM
LastWriteTime  : 12/31/1600 4:00:00 PM
LastAccessTime : 12/31/1600 4:00:00 PM
Mode           : larhs
LinkType       :
Target         : doesnotexist

> [IO.FileInfo]::new('doesnotexist') | Format-List

Name           : doesnotexist
Length         :
CreationTime   : 12/31/1600 4:00:00 PM
LastWriteTime  : 12/31/1600 4:00:00 PM
LastAccessTime : 12/31/1600 4:00:00 PM
Mode           : larhs
LinkType       :
Target         : doesnotexist

Actual behavior

On macOS and Linux, the LinkType property has a value of SymbolicLink, even though the directory/file does not exist.

> [IO.DirectoryInfo]::new('doesnotexist') | Format-List

Name           : doesnotexist
CreationTime   : 12/31/1600 16:07:00
LastWriteTime  : 12/31/1600 16:07:00
LastAccessTime : 12/31/1600 16:07:00
Mode           : larhs
LinkType       : SymbolicLink
Target         : doesnotexist

> [IO.FileInfo]::new('doesnotexist') | Format-List

Name           : doesnotexist
Length         :
CreationTime   : 12/31/1600 16:07:00
LastWriteTime  : 12/31/1600 16:07:00
LastAccessTime : 12/31/1600 16:07:00
Mode           : larhs
LinkType       : SymbolicLink
Target         : doesnotexist

Environment data

WSL

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Windows 10

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productOS-LinuxOS-macOSResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions