Skip to content

Change Target from a CodeProperty to be an AliasProperty that points to FileSystemInfo.LinkTarget - #16165

Merged
Rob Holt (rjmholt) merged 7 commits into
PowerShell:masterfrom
daxian-dbw:target
Oct 5, 2021
Merged

Change Target from a CodeProperty to be an AliasProperty that points to FileSystemInfo.LinkTarget#16165
Rob Holt (rjmholt) merged 7 commits into
PowerShell:masterfrom
daxian-dbw:target

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Sep 28, 2021

Copy link
Copy Markdown
Member

PR Summary

Fix #15958
Fix #13365

Change Target from a CodeProperty to be an AliasProperty that points to FileSystemInfo.LinkTarget.
Also, keep the public API InternalSymbolicLinkLinkCodeMethods.GetTarget(PSObject instance), but use FileSystemInfo.LinkTarget inside.

I have reviewed the .NET implementation of LinkTarget, and can confirm that the functionality is in parity.
The only difference is that LinkTarget doesn't throw error when the file doesn't exist, but our GetTarget(...) throws exception in that case. So, I add the file-existence check at some places, and other places doesn't need the check.

It would be easier to review by ignoring the white-space changes:
https://github.com/PowerShell/PowerShell/pull/16165/files?w=1

PR Context

PR Checklist

Comment thread src/System.Management.Automation/engine/NativeCommandProcessor.cs Outdated
Comment thread src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs
Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs
Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dongbo Wang (@daxian-dbw) Since you refactor the code why not remove Platform.IsWindows() and put code under #if?

Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs
Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs
Comment thread src/System.Management.Automation/engine/NativeCommandProcessor.cs Outdated
@daxian-dbw

Copy link
Copy Markdown
Member Author

Since you refactor the code why not remove Platform.IsWindows() and put code under #if?

Ilya (@iSazonov) That's not a goal of this PR :)

@daxian-dbw

Copy link
Copy Markdown
Member Author

Ilya (@iSazonov) I made some updates based on your comments. Please take another look when you have time, thanks!

Comment thread src/System.Management.Automation/engine/NativeCommandProcessor.cs Outdated
Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs
Comment thread test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 Outdated
@rjmholt
Rob Holt (rjmholt) merged commit 2f57bf8 into PowerShell:master Oct 5, 2021
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Oct 5, 2021
Dongbo Wang (daxian-dbw) added a commit to daxian-dbw/PowerShell that referenced this pull request Oct 21, 2021
@ghost

Copy link
Copy Markdown

🎉v7.2.0-rc.1 has been released which incorporates this pull request.:tada:

Handy links:

@ghost

Copy link
Copy Markdown

🎉v7.3.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

TrapGodBrim pushed a commit to TrapGodBrim/PowerShell that referenced this pull request Jan 19, 2022
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.2.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

4 participants