Skip to content

Refactor repeated invalid character checks in Path.GetFullPath Unix and Windows - #56568

Merged
stephentoub merged 5 commits into
dotnet:mainfrom
steveberdy:sb-54993
Aug 6, 2021
Merged

Refactor repeated invalid character checks in Path.GetFullPath Unix and Windows#56568
stephentoub merged 5 commits into
dotnet:mainfrom
steveberdy:sb-54993

Conversation

@steveberdy

@steveberdysteveberdy commented Jul 29, 2021

Copy link
Copy Markdown
Contributor

Summary

There were repeated, expensive checks on paths in the Path.GetFullPath method. This has been refactored with a GetFullPathInternal method that contains the shared code between the methods. These repetitions were found on both the Windows and Unix sides, and thus implementations of the GetFullPathInternal method were written for both.

Intended to extend PR #55373

Fixes#54993

@ghostghost added area-System.IO community-contribution Indicates that the PR has been added by a community member labels Jul 29, 2021
@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Summary

Where paths were checked to not be null, empty, or otherwise invalid, calls to Path.GetFullPath() were replaced with Path.GetFullyQualifiedPath(). A Unix implementation of GetFullyQualifiedPath was included as well.

Fixes #54993

Author:steveberdy
Assignees:-
Labels:

area-System.IO

Milestone:-

Comment threadsrc/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs Outdated
Comment threadsrc/libraries/System.Private.CoreLib/src/System/IO/Directory.cs Outdated
@stephentoubstephentoub added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 30, 2021
@steveberdysteveberdy changed the title Replace qualified instances of Path.GetFullPath with Path.GetFullyQualifiedPathReplace non-empty path calls from Path.GetFullPath with Path.GetFullNonEmptyPathJul 31, 2021
Comment threadsrc/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs Outdated
Comment threadsrc/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs Outdated
@steveberdysteveberdy reopened this Aug 2, 2021
@steveberdysteveberdy changed the title Replace non-empty path calls from Path.GetFullPath with Path.GetFullNonEmptyPathRefactored repeated invalid character checks in Path.GetFullPathAug 2, 2021
@steveberdysteveberdy changed the title Refactored repeated invalid character checks in Path.GetFullPathRefactor repeated invalid character checks in Path.GetFullPath Unix and WindowsAug 2, 2021
@jeffhandley

Copy link
Copy Markdown
Member

/azp run runtime

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@steveberdy
steveberdy requested review from jkotas and stephentoub and removed request for jkotasAugust 3, 2021 13:25
Comment threadsrc/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs Outdated
Comment threadsrc/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs Outdated
Comment threadsrc/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs Outdated

@jkotasjkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thank you!

@jkotas

Copy link
Copy Markdown
Member

@stephentoub Looks good?

@stephentoubstephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks.

@stephentoub

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@stephentoub

Copy link
Copy Markdown
Member

/azp list

@steveberdy

Copy link
Copy Markdown
ContributorAuthor

Good to merge?

@stephentoub

Copy link
Copy Markdown
Member

System.Net.Security test failure is unrelated.

@stephentoub
stephentoub merged commit 58efa4b into dotnet:mainAug 6, 2021
@steveberdy
steveberdy deleted the sb-54993 branch August 6, 2021 16:59
@adamsitnikadamsitnik removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 11, 2021
@adamsitnikadamsitnik added this to the 6.0.0 milestone Aug 11, 2021
@ghostghost locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.IOcommunity-contributionIndicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicated path.Contains('\0') check

5 participants

@steveberdy@jeffhandley@jkotas@stephentoub@adamsitnik