Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement UriCreationOptions #59173

Merged
merged 2 commits into from
Sep 16, 2021
Merged

Conversation

MihaZupan
Copy link
Member

@MihaZupan MihaZupan commented Sep 15, 2021

Fixes #52628
Fixes #58057

Implements a minimal subset of #59099:
The Uri constructor overloads and the DangerousDisablePathAndQueryCanonicalization property of UriCreationOptions.

Not yet implemented:

public struct UriCreationOptions
{
    public UriKind UriKind { readonly get; set; }
    public bool AllowImplicitFilePaths { readonly get; set; }
}

Includes DangerousDisablePathAndQueryCanonicalization
@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Sep 15, 2021

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

Issue Details

Implements a minimal subset of #59099:
The Uri constructor overloads and the DangerousDisablePathAndQueryCanonicalization property of UriCreationOptions.

Not yet implemented:

public struct UriCreationOptions
{
    public UriKind UriKind { readonly get; set; }
    public bool AllowImplicitFilePaths { readonly get; set; }
}
Author: MihaZupan
Assignees: -
Labels:

area-System.Net

Milestone: 7.0.0

Comment on lines +336 to +339
if (DisablePathAndQueryCanonicalization && (components & (UriComponents.Path | UriComponents.Query)) != 0)
{
throw new InvalidOperationException(SR.net_uri_GetComponentsCalledWhenCanonicalizationDisabled);
}
Copy link
Member

Choose a reason for hiding this comment

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

Offline discussion: I'm concerned that there's no way for the consumer to know if DisablePathAndQueryCanonicalization is set and avoid this exception. This method can also throw IOE for relative Uris, but there you can check IsAbsoluteUri first.

Copy link
Member Author

Choose a reason for hiding this comment

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

This method can also throw IOE for relative Uris, but there you can check IsAbsoluteUri first.

In the current version this is unreachable for relative Uris (since UriKind hasn't been exposed yet), but I will keep it in mind when adding the rest of the API. It's not critical as it would always throw anyway, but the change wasn't intentional.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should consider adding a way to expose this, something like IsPathAndQueryCanonicalizationDisabled.

Copy link
Member

Choose a reason for hiding this comment

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

Just to be super-clear: We can track that for 7.0, we do not consider it blocking attempt for 6.0 backport.
@geoffkizer please let us know if you disagree.

@MihaZupan
Copy link
Member Author

Test failure unrelated: #58356

@MihaZupan MihaZupan merged commit fe50d91 into dotnet:main Sep 16, 2021
Comment on lines +22 to +26
public bool DangerousDisablePathAndQueryCanonicalization
{
readonly get => _disablePathAndQueryCanonicalization;
set => _disablePathAndQueryCanonicalization = value;
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain what readonly get does, and link me to associated docs? Thank you

Copy link
Member

Choose a reason for hiding this comment

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

@karelz
Copy link
Member

karelz commented Sep 17, 2021

/backport to release/6.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/6.0-rc2: https://github.com/dotnet/runtime/actions/runs/1246572044

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants