Skip to content

Consider Uri .ctor to allow for paths starting with \\?\ #58712

Closed

Description

@krwq

See #58627 (comment) for context.

Would be nice if URI allowed for UNC paths such as i.e. those starting with \\?\ - that would make it easier to make long paths scenarios to work.

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Sep 6, 2021
  2. karelz commented on Sep 7, 2021

    @karelz
    Member

    Triage: @krwq is there any reason, why Uri was used in these situation vs. Path?
    We already regret we support path in Uri, extending it even more is not something we are thrilled about ...

  3. karelz commented on Sep 14, 2021

    @karelz
    Member

    @krwq ping?

  4. karelz commented on Sep 21, 2021

    @karelz
    Member

    Triage: Unclear what's customer demand, no info. Closing for now, we can reopen if there are customers asking for it.

  5. added this to the 7.0.0 milestone on Sep 21, 2021
  6. krwq commented on Sep 23, 2021

    @krwq
    MemberAuthor

    @karelz legacy reasons, that's what full framework did in at least configuration manager and xml and there is still lots of legacy code relying on that

  7. karelz commented on Sep 23, 2021

    @karelz
    Member

    @krwq thanks for info. Given the arguments above and the fact we didn't hear from end customers about it yet since .NET Core 1.0, I am inclined to leave it closed for now and wait for feedback. If there is indeed strong demand from customers, we can change our mind in future.

  8. ghost locked as resolved and limited conversation to collaborators on Nov 3, 2021
  9. buyaa-n commented on Jun 15, 2022

    @buyaa-n
    Contributor

    Another case reported Reading application settings in NET WinForms OOP designer fails with exception 'Invalid URI: The hostname could not be parsed" with similar root cause, but in this case we need to create Uri as it is used for subsequent calls:

    Uri codeBase = new Uri(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assembly.ManifestModule.Name));
    try
    {
    // Certain platforms may not have support for crypto
    hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName);
    }
    catch (PlatformNotSupportedException) { }
    if (hash != null)
    {
    typeName = StrongNameDesc;
    }
    else
    {
    try
    {
    // Certain platforms may not have support for crypto
    hash = IdentityHelper.GetNormalizedUriHash(codeBase);

    @karelz could we reopen the issue and investigate?

  10. karelz commented on Jun 20, 2022

    @karelz
    Member

    We could consider it post-7.0 (as it is risky change), if there are scenarios where it is highly inconvenient to not use Uri -- is there more info on how it is being used and why Path might not work?

  11. buyaa-n commented on Jun 20, 2022

    @buyaa-n
    Contributor

    In case if the hash was not populated from hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName) above, the Uri created here used for populating the hash by calling:

    internal static string GetNormalizedUriHash(Uri uri)
    {
    // On .NET Framework System.Security.Url is used as evidence, it has an internal Normalize() method.
    // Uri.ToString() appears to be functionally equivalent.
    return GetStrongHashSuitableForObjectName(uri.ToString());
    }

    the Uri is not looks essential in here and I could work around the bug but removing the \\?\ or something like that but I am not familiar with the code so not that sure what should be correct fix.

    Anyway by seeing this kind of error reported again it feels like better to fix it at the root cause

  12. RussKie commented on Jun 21, 2022

    @RussKie
    Contributor

    @karelz this bug affects Windows Forms out-of-process designer experience.

    /cc: @merriemcgaw

  13. karelz commented on Jun 21, 2022

    @karelz
    Member

    @buyaa-n thanks for the info above. Can you please provide more details about how/where does the \\?\ path originates? Is there option to change that part to Path?

    @RussKie understood from the context. Key questions I have: How does it work on .NET Framework? Is it a breaking change between .NET Core and .NET Framework?
    Are there workaround options?

    The key reason I am asking is that Uri is highly sensitive area. It is tricky code base with long history of MSRCs, and bad bugs. There were couple of design decisions in the past which lead to current state where paths are being treated as Uri, while behaving differently on Windows and Linux (often as a nasty surprise to users).
    From that perspective, support for \\?\ is a feature, not a bug fix. And it would work only on Windows. It has non-trivial impact on the rest of the Uri and needs to be thought through very carefully.

    Due to dev availability reasons, we won't be able to implement it before Platform complete, which also increases risk significantly. That's why I am looking strongly into alternatives in 7.0 time frame. And if we decide to do it, we need all the information we can get about the scenario.
    Hope it helps to explain the context.

  14. buyaa-n commented on Jun 21, 2022

    @buyaa-n
    Contributor

    Can you please provide more details about how/where does the \?\ path originates?

    According to https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd \\?\ is added for long paths (260+plust characters)

    The key reason I am asking is that Uri is highly sensitive area. It is tricky code base with long history of MSRCs, and bad bugs. There were couple of design decisions in the past which lead to current state where paths are being treated as Uri, while behaving differently on Windows and Linux (often as a nasty surprise to users).
    From that perspective, support for \?\ is a feature, not a bug fix. And it would work only on Windows. It has non-trivial impact on the rest of the Uri and needs to be thought through very carefully.

    Thanks for explanation, it seems Uri doesn't support \\?\ in .Net framework too, so seems its better to fix it in AppDomain.CurrentDomain.BaseDirectory there is open issue Consider stripping \?\ from AppDomain.CurrentDomain.BaseDirectory

  15. removed
    untriagedNew issue has not been triaged by the area owner
    on Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions