Repository: dotnet/runtime
File: src/libraries/System.Private.Uri/src/System/UriExt.cs (C#)

Code before:
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Buffers;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;

namespace System
{
    public partial class Uri
    {
        /// <summary>Helper called by all constructos to construct the Uri.</summary>
        [MemberNotNull(nameof(_string))]
        private void CreateThis(string? uri, bool dontEscape, UriKind uriKind, in UriCreationOptions creationOptions = default)
        {
            UriFormatException? e = TryCreateThis(uri, dontEscape, uriKind, in creationOptions);

            if (e is not null)
            {
                throw e;
            }
        }

        /// <summary>Core helper called by all constructors and TryCreate factories to construct the Uri.</summary>
        [MemberNotNull(nameof(_string))]
        private UriFormatException? TryCreateThis(string? uri, bool dontEscape, UriKind uriKind, in UriCreationOptions creationOptions = default)
        {
            DebugAssertInCtor();

            if (uriKind is < UriKind.RelativeOrAbsolute or > UriKind.Relative)
            {
                throw new ArgumentException(SR.Format(SR.net_uri_InvalidUriKind, uriKind));
            }

            _string = uri ?? string.Empty;

            Debug.Assert(_originalUnicodeString is null && _info is null && _syntax is null && _flags == Flags.Zero);

Review comment (refactor):
```suggestion
        /// <summary>Helper called by all constructors to construct the Uri.</summary>
```


Code after:
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Buffers;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;

namespace System
{
    public partial class Uri
    {
        /// <summary>Helper called by all constructors to construct the Uri.</summary>
        [MemberNotNull(nameof(_string))]
        private void CreateThis(string? uri, bool dontEscape, UriKind uriKind, in UriCreationOptions creationOptions = default)
        {
            UriFormatException? e = TryCreateThis(uri, dontEscape, uriKind, in creationOptions);

            if (e is not null)
            {
                throw e;
            }
        }

        /// <summary>Core helper called by all constructors and TryCreate factories to construct the Uri.</summary>
        [MemberNotNull(nameof(_string))]
        private UriFormatException? TryCreateThis(string? uri, bool dontEscape, UriKind uriKind, in UriCreationOptions creationOptions = default)
        {
            DebugAssertInCtor();

            if (uriKind is < UriKind.RelativeOrAbsolute or > UriKind.Relative)
            {
                throw new ArgumentException(SR.Format(SR.net_uri_InvalidUriKind, uriKind));
            }

            _string = uri ?? string.Empty;

            Debug.Assert(_originalUnicodeString is null && _info is null && _syntax is null && _flags == Flags.Zero);