Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@JeremyKuhne
Copy link
Member

Builds on #16311. This makes behavior much more consistent cross-plat and allows currently blocked scenarios (notably accessing Unix volumes from Windows).

  • Remove all path validity checks outside of
    • Null
    • Embedded null
    • Empty or all spaces (effectively empty)
  • Remove PathStartSkip helper
  • Use span overloads for StringBuffer usage
  • Clean up some comments

I've marked this as no merge until I get the test changes finished/checked-in for CoreFX. I'll link the PR when it is up.

Note that I'm going to investigate:

  1. Removing StringBuffer (and using ValueStringBuilder)
  2. Exposing Path directly from System.Runtime.Extensions again (as we now have a decent mirroring solution set up)

maryamariyan and others added 3 commits February 21, 2018 11:36
- Remove all path validity checks outside of
    - Null
    - Embedded null
    - Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
@JeremyKuhne JeremyKuhne added * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) area-System.IO labels Feb 21, 2018
@JeremyKuhne JeremyKuhne added this to the 2.1.0 milestone Feb 21, 2018
@JeremyKuhne JeremyKuhne self-assigned this Feb 21, 2018
int rootLength = PathInternal.GetRootLength(outputBuffer);
bool isDevice = PathInternal.IsDevice(outputBuffer);

StringBuffer inputBuffer = new StringBuffer(0);
Copy link
Member

Choose a reason for hiding this comment

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

BTW does it make sense for ValueStringBuilder to grow to absorb the function of STringBuffer ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I called out that I intend to look into that in the PR comments above. It is definitely worth investigating, I just didn't want to make this change too complicated.

if (fullPath.Length == path.Length && fullPath.StartsWith(path))
{
// If we have the exact same string we were passed in, don't bother to allocate another string from the StringBuilder.
// If we have the exact same string we were passed in, don't bother to allocate another string from the StringBuffer.
Copy link
Member

Choose a reason for hiding this comment

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

Nit, no need to fix, but if code always returns out of a conditional block

if (...)
{
    // ..
    return ...;
}
else
{
  . ...
}

I think it's easier to read if you avoid the indent/braces ie

if (...)
{
    // ..
    return ...;
}
  . ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I usually early out.

_length = 0;
}

public static implicit operator ReadOnlySpan<char>(StringBuffer stringBuffer)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to make the cast explicit via AsReadOnlySpan method. StringBuffer is not immutable, and so you have to be careful about for how long you are going to use the Span.

_length = 0;
}

public static explicit operator ReadOnlySpan<char>(StringBuffer stringBuffer)
Copy link
Member

Choose a reason for hiding this comment

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

JeremyKuhne added a commit to JeremyKuhne/corefx that referenced this pull request Feb 22, 2018
JeremyKuhne added a commit to JeremyKuhne/corefx that referenced this pull request Feb 22, 2018
@JeremyKuhne
Copy link
Member Author

Now have the test PR up. dotnet/corefx#27348.

JeremyKuhne added a commit to JeremyKuhne/corefx that referenced this pull request Feb 22, 2018
JeremyKuhne added a commit to dotnet/corefx that referenced this pull request Feb 22, 2018
* Update tests for Path changes

Updates for dotnet/coreclr#16478

* Add back Unix active issue (wishful thinking that this would get the same error on Unix)

* Address feedback
@JeremyKuhne JeremyKuhne removed the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 22, 2018
@JeremyKuhne JeremyKuhne merged commit a0cfda0 into dotnet:master Feb 22, 2018
@JeremyKuhne JeremyKuhne deleted the dialback2 branch February 22, 2018 20:14
@JeremyKuhne
Copy link
Member Author

Tests have been updated in CoreFX. (#27348)

dotnet-bot pushed a commit to dotnet/corert that referenced this pull request Feb 22, 2018
* Removing the colon block that tosses out paths that are not device path.

Fixes: #26359

* Striping 2nd and 3rd args of PathHelper.Normalize

* Build on Maryam's changes

- Remove all path validity checks outside of
    - Null
    - Embedded null
    - Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments

* Address feedback

* Tweak to match other AsSpan methods

Signed-off-by: dotnet-bot <[email protected]>
JeremyKuhne added a commit to dotnet/corert that referenced this pull request Feb 22, 2018
* Removing the colon block that tosses out paths that are not device path.

Fixes: #26359

* Striping 2nd and 3rd args of PathHelper.Normalize

* Build on Maryam's changes

- Remove all path validity checks outside of
    - Null
    - Embedded null
    - Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments

* Address feedback

* Tweak to match other AsSpan methods

Signed-off-by: dotnet-bot <[email protected]>
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request Feb 23, 2018
* Removing the colon block that tosses out paths that are not device path.

Fixes: #26359

* Striping 2nd and 3rd args of PathHelper.Normalize

* Build on Maryam's changes

- Remove all path validity checks outside of
    - Null
    - Embedded null
    - Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments

* Address feedback

* Tweak to match other AsSpan methods

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Feb 23, 2018
* Removing the colon block that tosses out paths that are not device path.

Fixes: #26359

* Striping 2nd and 3rd args of PathHelper.Normalize

* Build on Maryam's changes

- Remove all path validity checks outside of
    - Null
    - Embedded null
    - Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments

* Address feedback

* Tweak to match other AsSpan methods

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
kbaladurin pushed a commit to kbaladurin/corert that referenced this pull request Mar 15, 2018
* Removing the colon block that tosses out paths that are not device path.

Fixes: #26359

* Striping 2nd and 3rd args of PathHelper.Normalize

* Build on Maryam's changes

- Remove all path validity checks outside of
    - Null
    - Embedded null
    - Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments

* Address feedback

* Tweak to match other AsSpan methods

Signed-off-by: dotnet-bot <[email protected]>
filipnavara pushed a commit to emclient/sysdrawing-coregraphics that referenced this pull request May 20, 2019
* Update tests for Path changes

Updates for dotnet/coreclr#16478

* Add back Unix active issue (wishful thinking that this would get the same error on Unix)

* Address feedback
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Update tests for Path changes

Updates for dotnet/coreclr#16478

* Add back Unix active issue (wishful thinking that this would get the same error on Unix)

* Address feedback


Commit migrated from dotnet/corefx@92afa6e
ViktorHofer pushed a commit to dotnet/winforms that referenced this pull request Dec 5, 2022
* Update tests for Path changes

Updates for dotnet/coreclr#16478

* Add back Unix active issue (wishful thinking that this would get the same error on Unix)

* Address feedback


Commit migrated from https://github.com/dotnet/corefx/commit/dotnet/runtime@92afa6ec21817739ebf45cd66b4569a03b54d4c0


Commit migrated from dotnet/runtime@973cec3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants