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

Uri constructors accepting dontEscape have misleading Obsolete attribute #56840

Open
jeffhandley opened this issue Aug 4, 2021 · 2 comments
Open

Comments

@jeffhandley
Copy link
Member

There are 2 Uri constructors that are marked as obsolete, indicating the the dontEscape argument is deprecated and always false. Upon reviewing the code though, it seems the dontEscape argument is indeed utilized with potentially-true values.

        //
        // Uri(string, bool)
        //
        //  Uri constructor. Assumes that input string is canonically escaped
        //
        [Obsolete("This constructor has been deprecated; the dontEscape parameter is always false. Use Uri(string) instead.")]
        public Uri(string uriString, bool dontEscape)
        {
            if (uriString == null)
                throw new ArgumentNullException(nameof(uriString));

            CreateThis(uriString, dontEscape, UriKind.Absolute);
            DebugSetLeftCtor();
        }

        //
        // Uri(Uri, string, bool)
        //
        //  Uri combinatorial constructor. Do not perform character escaping if
        //  DontEscape is true
        //
        [Obsolete("This constructor has been deprecated; the dontEscape parameter is always false. Use Uri(Uri, string) instead.")]
        public Uri(Uri baseUri, string? relativeUri, bool dontEscape)
        {
            if (baseUri is null)
                throw new ArgumentNullException(nameof(baseUri));

            if (!baseUri.IsAbsoluteUri)
                throw new ArgumentOutOfRangeException(nameof(baseUri));

            CreateUri(baseUri, relativeUri, dontEscape);
            DebugSetLeftCtor();
        }

Originally posted by @jkotas in #56690 (comment)

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Aug 4, 2021
@ghost
Copy link

ghost commented Aug 4, 2021

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

Issue Details

There are 2 Uri constructors that are marked as obsolete, indicating the the dontEscape argument is deprecated and always false. Upon reviewing the code though, it seems the dontEscape argument is indeed utilized with potentially-true values.

        //
        // Uri(string, bool)
        //
        //  Uri constructor. Assumes that input string is canonically escaped
        //
        [Obsolete("This constructor has been deprecated; the dontEscape parameter is always false. Use Uri(string) instead.")]
        public Uri(string uriString, bool dontEscape)
        {
            if (uriString == null)
                throw new ArgumentNullException(nameof(uriString));

            CreateThis(uriString, dontEscape, UriKind.Absolute);
            DebugSetLeftCtor();
        }

        //
        // Uri(Uri, string, bool)
        //
        //  Uri combinatorial constructor. Do not perform character escaping if
        //  DontEscape is true
        //
        [Obsolete("This constructor has been deprecated; the dontEscape parameter is always false. Use Uri(Uri, string) instead.")]
        public Uri(Uri baseUri, string? relativeUri, bool dontEscape)
        {
            if (baseUri is null)
                throw new ArgumentNullException(nameof(baseUri));

            if (!baseUri.IsAbsoluteUri)
                throw new ArgumentOutOfRangeException(nameof(baseUri));

            CreateUri(baseUri, relativeUri, dontEscape);
            DebugSetLeftCtor();
        }

Originally posted by @jkotas in #56690 (comment)

Author: jeffhandley
Assignees: -
Labels:

area-System.Net, untriaged

Milestone: -

@MihaZupan
Copy link
Member

Triage: We should update the deprecated message, but these APis should never be used regardless.

@MihaZupan MihaZupan removed the untriaged New issue has not been triaged by the area owner label Aug 10, 2021
@MihaZupan MihaZupan added this to the Future milestone Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants