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

Resolve missing triple-slash in Microsoft.Extensions.Primitives #76098

Merged
merged 5 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics;
using System.Threading;

namespace Microsoft.Extensions.Primitives
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Microsoft.Extensions.Primitives
{
/// <summary>
/// Provides extensions methods for the <see cref="Primitives"/> namespace.
/// </summary>
public static class Extensions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@

namespace Microsoft.Extensions.Primitives
{
/// <summary>
/// Compares two <see cref="StringSegment"/> instances.
Nick-Stanton marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public class StringSegmentComparer : IComparer<StringSegment>, IEqualityComparer<StringSegment>
{
/// <summary>
/// Gets a <see cref="StringSegmentComparer"/> object that performs a case-sensitive ordinal <see cref="StringSegment"/> comparison.
/// </summary>
public static StringSegmentComparer Ordinal { get; }
= new StringSegmentComparer(StringComparison.Ordinal, StringComparer.Ordinal);

/// <summary>
/// Gets a <see cref="StringSegmentComparer"/> object that performs a case-insensitive ordinal <see cref="StringSegment"/> comparison.
/// </summary>
public static StringSegmentComparer OrdinalIgnoreCase { get; }
= new StringSegmentComparer(StringComparison.OrdinalIgnoreCase, StringComparer.OrdinalIgnoreCase);

Expand All @@ -33,6 +42,12 @@ public bool Equals(StringSegment x, StringSegment y)
return StringSegment.Equals(x, y, Comparison);
}

/// <summary>
Nick-Stanton marked this conversation as resolved.
Show resolved Hide resolved
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public int GetHashCode(StringSegment obj)
{
#if NETCOREAPP || NETSTANDARD2_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Extensions.Primitives
/// <summary>
/// Tokenizes a <see cref="string"/> into <see cref="StringSegment"/>s.
/// </summary>
public readonly struct StringTokenizer : IEnumerable<StringSegment>
public readonly struct StringTokenizer : IEnumerable<StringSegment>
{
private readonly StringSegment _value;
private readonly char[] _separators;
Expand Down Expand Up @@ -57,12 +57,19 @@ public StringTokenizer(StringSegment value, char[] separators)
_separators = separators;
}

/// <summary>
/// Initializes a new instance of <see cref="Enumerator"/>.
/// </summary>
/// <returns>An <see cref="Enumerator"/> based on the <see cref="StringTokenizer"/>'s value and separators.</returns>
public Enumerator GetEnumerator() => new Enumerator(in _value, _separators);

IEnumerator<StringSegment> IEnumerable<StringSegment>.GetEnumerator() => GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

/// <summary>
/// Enumerates the <see cref="string"/> tokens represented by <see cref="StringSegment"/>.
/// </summary>
public struct Enumerator : IEnumerator<StringSegment>
{
private readonly StringSegment _value;
Expand All @@ -77,6 +84,10 @@ internal Enumerator(in StringSegment value, char[] separators)
_index = 0;
}

/// <summary>
/// Initializes an <see cref="Enumerator"/> using a <see cref="StringTokenizer"/>.
/// </summary>
/// <param name="tokenizer"><see cref="StringTokenizer"/> containing value and separators for enumeration.</param>
public Enumerator(ref StringTokenizer tokenizer)
{
_value = tokenizer._value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,12 @@ public override bool Equals(object? obj)
return false;
}

/// <inheritdoc />
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
object? value = _values;
Expand Down Expand Up @@ -774,6 +779,10 @@ internal Enumerator(object? value)
_index = 0;
}

/// <summary>
/// Instantiates an <see cref="Enumerator"/> using a <see cref="StringValues"/>.
/// </summary>
/// <param name="values">The <see cref="StringValues"/> to enumerate.</param>
public Enumerator(ref StringValues values) : this(values._values)
{ }

Expand Down