Repository: dotnet/roslyn
File: src/Compilers/Core/Portable/Text/SourceText.cs (C#)

Code before:
                remove
                {
                    // do nothing
                }
            }
        }

        /// <summary>
        /// Get maximum char count needed to decode the entire stream.
        /// </summary>
        /// <exception cref="IOException">Stream is so big that max char count can't fit in <see cref="int"/>.</exception> 
        internal static int GetMaxCharCountOrThrowIfHuge(Encoding encoding, Stream stream)
        {
            Debug.Assert(stream.CanSeek);

            if (encoding.TryGetMaxCharCount(stream.Length, out int maxCharCount))
            {
                return maxCharCount;
            }

            throw new IOException(CodeAnalysisResources.StreamIsTooLong);
        }

        /// <returns>
        /// If <paramref name="checksumAlgorithm"/> is <see cref="SourceHashAlgorithm.None"/>, returns this instance without modification.
        /// Otherwise, returns a SourceText with the same <see cref="ChecksumAlgorithm"/> as <paramref name="checksumAlgorithm"/>, potentially by wrapping this instance.
        /// </returns>
        internal SourceText WithChecksumAlgorithmIfAny(SourceHashAlgorithm checksumAlgorithm)
        {
            if (checksumAlgorithm == SourceHashAlgorithm.None || checksumAlgorithm == ChecksumAlgorithm)
                return this;

            return new SourceTextWithAlgorithm(this, checksumAlgorithm);
        }

        private sealed class SourceTextWithAlgorithm : SourceText
        {
            private readonly SourceText _underlying;

            public SourceTextWithAlgorithm(SourceText underlying, SourceHashAlgorithm checksumAlgorithm) : base(checksumAlgorithm: checksumAlgorithm)
            {
                Debug.Assert(checksumAlgorithm != SourceHashAlgorithm.None);
                Debug.Assert(checksumAlgorithm != underlying.ChecksumAlgorithm);
                _underlying = underlying;
            }

            public override char this[int position] => _underlying[position];

            public override Encoding? Encoding => _underlying.Encoding;

            public override int Length => _underlying.Length;

Review comment (suggestion):
```suggestion
        /// Otherwise, returns a <see cref="SourceText"/> with the same <see cref="ChecksumAlgorithm"/> as <paramref name="checksumAlgorithm"/>, potentially by wrapping this instance.
```

Code after:
                remove
                {
                    // do nothing
                }
            }
        }

        /// <summary>
        /// Get maximum char count needed to decode the entire stream.
        /// </summary>
        /// <exception cref="IOException">Stream is so big that max char count can't fit in <see cref="int"/>.</exception> 
        internal static int GetMaxCharCountOrThrowIfHuge(Encoding encoding, Stream stream)
        {
            Debug.Assert(stream.CanSeek);

            if (encoding.TryGetMaxCharCount(stream.Length, out int maxCharCount))
            {
                return maxCharCount;
            }

            throw new IOException(CodeAnalysisResources.StreamIsTooLong);
        }

        /// <returns>
        /// If <paramref name="checksumAlgorithm"/> is <see cref="SourceHashAlgorithm.None"/>, returns this instance without modification.
        /// Otherwise, returns a <see cref="SourceText"/> with the same <see cref="ChecksumAlgorithm"/> as <paramref name="checksumAlgorithm"/>, potentially by wrapping this instance.
        /// </returns>
        internal SourceText WithChecksumAlgorithmIfAny(SourceHashAlgorithm checksumAlgorithm)
        {
            if (checksumAlgorithm == SourceHashAlgorithm.None || checksumAlgorithm == ChecksumAlgorithm)
                return this;

            return new SourceTextWithAlgorithm(this, checksumAlgorithm);
        }

        private sealed class SourceTextWithAlgorithm : SourceText
        {
            private readonly SourceText _underlying;

            public SourceTextWithAlgorithm(SourceText underlying, SourceHashAlgorithm checksumAlgorithm) : base(checksumAlgorithm: checksumAlgorithm)
            {
                Debug.Assert(checksumAlgorithm != SourceHashAlgorithm.None);
                Debug.Assert(checksumAlgorithm != underlying.ChecksumAlgorithm);
                _underlying = underlying;
            }

            public override char this[int position] => _underlying[position];

            public override Encoding? Encoding => _underlying.Encoding;

            public override int Length => _underlying.Length;