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

Update Range<T> XML docs #63

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Changes from 24 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8497b8d
Update constructors XML Docs
FreePhoenix888 Jul 27, 2021
5401b08
Update fields XML Docs
FreePhoenix888 Jul 27, 2021
3a8b556
Update articles
FreePhoenix888 Jul 27, 2021
054913f
Use see tag in constructor docs
FreePhoenix888 Jul 27, 2021
bbeb2a4
Format
FreePhoenix888 Jul 27, 2021
9224186
Update Contains() XML Docs
FreePhoenix888 Jul 27, 2021
759f82c
Format XML Docs
FreePhoenix888 Jul 27, 2021
804be38
Update XML Docs - Use <see/>
FreePhoenix888 Jul 27, 2021
15f9fdd
Update XML Docs
FreePhoenix888 Jul 27, 2021
36544b4
Update Equals() XML Docs
FreePhoenix888 Jul 27, 2021
16b5e53
Update GetHashCode() XML Docs
FreePhoenix888 Jul 27, 2021
4642105
Update == XML Docs
FreePhoenix888 Jul 27, 2021
b054a25
Update != XML Docs
FreePhoenix888 Jul 27, 2021
6aa7824
Update contructors XML DOcs
FreePhoenix888 Jul 27, 2021
7f1067f
Update see cref Range to Range<T>
FreePhoenix888 Jul 27, 2021
d8fdd27
Update contructors XML Docs
FreePhoenix888 Jul 27, 2021
87a41c8
Remove redundant summary tag
FreePhoenix888 Jul 27, 2021
732489f
Update ToString() XML Docs
FreePhoenix888 Jul 27, 2021
2418a04
Update XML Docs
FreePhoenix888 Jul 27, 2021
05549d9
Format XML Docs
FreePhoenix888 Jul 27, 2021
404cf94
Update XML Docs
FreePhoenix888 Jul 27, 2021
020005c
Format XML Docs
FreePhoenix888 Jul 27, 2021
72f5d90
Update XML Docs
FreePhoenix888 Jul 27, 2021
2aac032
Format XML Docs
FreePhoenix888 Jul 27, 2021
860e5ae
Update XML Docs
FreePhoenix888 Jul 29, 2021
dfa8f88
Update XML Docs - operators
FreePhoenix888 Jul 29, 2021
06e5167
Update XML Docs - Remove redundant articles
FreePhoenix888 Jul 29, 2021
c690353
Update XML Docs
FreePhoenix888 Aug 6, 2021
e14d5f1
Update XML Docs
FreePhoenix888 Aug 8, 2021
254b42b
Update docs
FreePhoenix888 Sep 8, 2021
29082f4
Update XML Documentation
FreePhoenix888 Nov 7, 2021
d55bc6b
Remove word допустимое from XML documentation
FreePhoenix888 Nov 10, 2021
6e4f156
Remove space at the line end
FreePhoenix888 Nov 10, 2021
fb6b70b
Update XML Documentation
FreePhoenix888 Nov 10, 2021
efba57b
Update XML DocumentationNN
FreePhoenix888 Nov 10, 2021
88402d0
Update `constructors` `summary`
FreePhoenix888 Jan 5, 2022
82ced6c
Update XML Docs
FreePhoenix888 Jan 5, 2022
f3494be
Remove `with the` double
FreePhoenix888 Jan 5, 2022
bcc6009
`объекта` -> `из`
FreePhoenix888 Jan 5, 2022
5984e26
`c` -> `со`
FreePhoenix888 Jan 5, 2022
17d4b9b
равны ли -> равны ли диапазоны
FreePhoenix888 Jan 5, 2022
a0acbcf
`left and right` -> `left and rigth ranges`
FreePhoenix888 Jan 5, 2022
97c1ac5
`не равны ли left и right` -> `не равны ли диапазоны left и right`
FreePhoenix888 Jan 5, 2022
462115b
Use `(struct|структура)` instead of `(object|instance)` everywhere bu…
FreePhoenix888 Jan 5, 2022
267be45
Update XML Docs: `Provides` for `fields`
FreePhoenix888 Jan 5, 2022
616f186
Update XML Docs: `текущего диапазона` -> `текущей структуры <see cref…
FreePhoenix888 Jan 5, 2022
363d1ae
Update XML Docs: `(value|значением)` -> `(values|значениями)` for `mi…
FreePhoenix888 Jan 5, 2022
da464ac
Update XML Docs: `for both` -> `for the both`
FreePhoenix888 Jan 5, 2022
d76da06
Update XML Docs: add `(ranges|диапазоны)` before left and rigth in `r…
FreePhoenix888 Jan 5, 2022
d40319f
Update Minimum and Maximum docs
FreePhoenix888 Mar 30, 2022
b79e91d
Update Range constructor docs
FreePhoenix888 Mar 30, 2022
0b79544
Update docs
FreePhoenix888 May 4, 2022
070f055
Update docs
FreePhoenix888 May 4, 2022
050241c
Two more spaces.
Konard May 6, 2022
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
169 changes: 118 additions & 51 deletions csharp/Platform.Ranges/Range[T].cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,48 @@ public struct Range<T> : IEquatable<Range<T>>
private static readonly EqualityComparer<T> _equalityComparer = EqualityComparer<T>.Default;

/// <summary>
/// <para>Returns minimum value of the range.</para>
/// <para>Возвращает минимальное значение диапазона.</para>
/// <para>Gets the minimum value of the <see cref="Range{T}"/>.</para>
/// <para>Возвращает минимальное значение <see cref="Range{T}"/>.</para>
/// </summary>
public readonly T Minimum;

/// <summary>
/// <para>Returns maximum value of the range.</para>
/// <para>Возвращает максимальное значение диапазона.</para>
/// <para>Gets the maximum value of the <see cref="Range{T}"/>.</para>
/// <para>Возвращает максимальное значение <see cref="Range{T}"/>.</para>
/// </summary>
public readonly T Maximum;

/// <summary>
/// <para>Initializes a new instance of the Range class.</para>
/// <para>Инициализирует новый экземпляр класса Range.</para>
/// <para>Initializes a new <see cref="Range{T}"/> instance.</para>
/// <para>Инициализирует новый экземпляр <see cref="Range{T}"/>.</para>
/// </summary>
/// <param name="minimumAndMaximum"><para>Single value for both Minimum and Maximum fields.</para><para>Одно значение для полей Minimum и Maximum.</para></param>
/// <param name="minimumAndMaximum">
/// <para>Single value for both <see cref="Minimum"/> and <see cref="Maximum"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para>Одно значение для обоих полей <see cref="Minimum"/> и <see cref="Maximum"/>.</para>
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Range(T minimumAndMaximum)
{
Minimum = minimumAndMaximum;
Maximum = minimumAndMaximum;
}

/// <summary>
/// <para>Initializes a new instance of the Range class.</para>
/// <para>Инициализирует новый экземпляр класса Range.</para>
/// </summary>
/// <param name="minimum"><para>The minimum value of the range.</para><para>Минимальное значение диапазона.</para></param>
/// <param name="maximum"><para>The maximum value of the range.</para><para>Максимальное значение диапазона.</para></param>
/// <exception cref="ArgumentException"><para>Thrown when the maximum is less than the minimum.</para><para>Выбрасывается, когда максимум меньше минимума.</para></exception>
/// <summary>
/// <para>Initializes a new <see cref="Range{T}"/> instance.</para>
/// <para>Инициализирует новый экземпляр <see cref="Range{T}"/>.</para>
/// </summary>
/// <param name="minimum">
/// <para>A minimum value of the <see cref="Range{T}"/>.</para>
/// <para>Минимальное значение <see cref="Range{T}"/>.</para>
/// </param>
/// <param name="maximum">
/// <para>A maximum value of the <see cref="Range{T}"/>.</para>
/// <para>Максимальное значение <see cref="Range{T}"/>.</para>
/// </param>
/// <exception cref="ArgumentException">
/// <para>The <paramref name="maximum"/> is less than the <paramref name="minumum"/>.</para>
/// <para><paramref name="maximum"/> меньше <paramref name="minumum"/>.</para>
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Range(T minimum, T maximum)
{
Expand All @@ -58,89 +70,144 @@ public Range(T minimum, T maximum)
}

/// <summary>
/// <para>Presents the Range in readable format.</para>
/// <para>Представляет диапазон в удобном для чтения формате.</para>
/// <para>Presents the <see cref="Range{T}"/> in readable format.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para>Представляет <see cref="Range{T}"/> в удобном для чтения формате.</para>
/// </summary>
/// <returns><para>String representation of the Range.</para><para>Строковое представление диапазона.</para></returns>
/// <returns>
/// <para>String representation of the <see cref="Range{T}"/>.</para>
/// <para>Строковое представление <see cref="Range{T}"/>.</para>
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString() => $"[{Minimum}..{Maximum}]";

/// <summary>
/// <para>Determines if the provided value is inside the range.</para>
/// <para>Определяет, находится ли указанное значение внутри диапазона.</para>
/// <para>Determines if the <see cref="Range{T}"/> contains the <paramref name="value"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para>Определяет, содержит ли <see cref="Range{T}"/> <paramref name="value"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <param name="value"><para>The value to test.</para><para>Значение для проверки.</para></param>
/// <returns><para>True if the value is inside Range, else false.</para><para>True, если значение находится внутри диапазона, иначе false.</para></returns>
/// <param name="value">
/// <para>A value to find in the <see cref="Range{T}"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para>Значение, которое нужно найти в <see cref="Range{T}"/>.</para>
/// </param>
/// <returns>
/// <para>A <see cref="Boolean"/> value that determines whether the <see cref="Range{T}"/> contains the <paramref name="value"/>.</para>
/// <para>Значение типа <see cref="Boolean"/>, определяющее содержит ли <see cref="Range{T}"/> <paramref name="value"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(T value) => _comparer.Compare(Minimum, value) <= 0 && _comparer.Compare(Maximum, value) >= 0;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public bool Contains(T value) => _comparer.Compare(Minimum, value) <= 0 && _comparer.Compare(Maximum, value) >= 0;
public bool Includes(T value) => _comparer.Compare(Minimum, value) <= 0 && _comparer.Compare(Maximum, value) >= 0;

Note: this a breaking change. We should also ensure to use include instead of contain for Ranges everywhere. This is because word include is used with Range much more frequently.


/// <summary>
/// <para>Determines if another range is inside the bounds of this range.</para>
/// <para>Определяет, находится ли другой диапазон внутри границ этого диапазона.</para>
/// <para>Determines if the current <see cref="Range{T}"/> contains the <paramref name="range"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para>Определяет, содержит ли текущий <see cref="Range{T}"/> <paramref name="range"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <param name="range"><para>The child range to test.</para><para>Дочерний диапазон для проверки.</para></param>
/// <returns><para>True if range is inside, else false.</para><para>True, если диапазон находится внутри, иначе false.</para></returns>
/// <param name="range">
/// <para>A <see cref="Range{T}"/> to find in the current <see cref="Range{T}"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para><see cref="Range{T}"/>, который нужно найти в текущем <see cref="Range{T}"/>.</para>
/// </param>
/// <returns>
/// <para>A <see cref="Boolean"/> value that determines whether the current <see cref="Range{T}"/> contains the <paramref name="range"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// <para>Значение типа <see cref="Boolean"/>, определяющее, содержит ли текущий <see cref="Range{T}"/> <paramref name="range"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(Range<T> range) => Contains(range.Minimum) && Contains(range.Maximum);

/// <summary>
/// <para>Determines whether the current range is equal to another range.</para>
/// <para>Определяет, равен ли текущий диапазон другому диапазону.</para>
/// <para>Determines whether the current <see cref="Range{T}"/> and the <paramref name="other"/> are equal.</para>
/// <para>Определяет, равны ли текущий <see cref="Range{T}"/> и <paramref name="other"/>.</para>
/// </summary>
/// <param name="other"><para>A range to compare with this range.</para><para>Диапазон для сравнения с этим диапазоном.</para></param>
/// <returns><para>True if the current range is equal to the other range; otherwise, false.</para><para>True, если текущий диапазон равен другому диапазону; иначе false.</para></returns>
/// <param name="other">
/// <para>A <see cref="Range{T}"/> to compare with the current <see cref="Range{T}"/>.</para>
/// <para><see cref="Range{T}"/> для сравнения с текущим <see cref="Range{T}"/>.</para>
/// </param>
/// <returns>
/// <para>A <see cref="Boolean"/> value that determines whether the current <see cref="Range{T}"/> and the <paramref name="other"/> are equal.</para>
/// <para>Значение типа <see cref="Boolean"/>, определяющее, равны ли <paramref name="other"/> и текущий <see cref="Range{T}"/>.</para>
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Range<T> other) => _equalityComparer.Equals(Minimum, other.Minimum) && _equalityComparer.Equals(Maximum, other.Maximum);

/// <summary>
/// <para>Creates a new <see cref="ValueTuple{T,T}"/> struct initialized with <see cref="Range{T}.Minimum"/> as <see cref="ValueTuple{T,T}.Item1"/> and <see cref="Range{T}.Maximum"/> as <see cref="ValueTuple{T,T}.Item2"/>.</para>
/// <para>Создает новую структуру <see cref="ValueTuple{T,T}"/>, инициализированную с помощью <see cref="Range{T}.Minimum"/> как <see cref="ValueTuple{T,T}.Item1"/> и <see cref="Range{T}.Maximum"/> как <see cref="ValueTuple{T,T}.Item2"/>.</para>
/// <para>Creates a new <see cref="ValueTuple{T,T}"/> struct initialized with <see cref="Minimum"/> as <see cref="ValueTuple{T,T}.Item1"/> and <see cref="Maximum"/> as <see cref="ValueTuple{T,T}.Item2"/>.</para>
/// <para>Создает новую структуру <see cref="ValueTuple{T,T}"/>, инициализированную с помощью <see cref="Minimum"/> как <see cref="ValueTuple{T,T}.Item1"/> и <see cref="Maximum"/> как <see cref="ValueTuple{T,T}.Item2"/>.</para>
/// </summary>
/// <param name="range"><para>The range of <typeparamref name="T"/>.</para><para>Диапазон значений <typeparamref name="T"/>.</para></param>
/// <param name="range">
/// <para>The range of <typeparamref name="T"/>.</para>
/// <para>Диапазон значений <typeparamref name="T"/>.</para>
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ValueTuple<T, T>(Range<T> range) => (range.Minimum, range.Maximum);

/// <summary>
/// <para>Creates a new <see cref="Range{T}"/> struct initialized with <see cref="ValueTuple{T,T}.Item1"/> as <see cref="Range{T}.Minimum"/> and <see cref="ValueTuple{T,T}.Item2"/> as <see cref="Range{T}.Maximum"/>.</para>
/// <para>Создает новую структуру <see cref="Range{T}"/>, инициализированную с помощью <see cref="ValueTuple{T,T}.Item1"/> как <see cref="Range{T}.Minimum"/> и <see cref="ValueTuple{T,T}.Item2"/> как <see cref="Range{T}.Maximum"/>.</para>
/// <para>Creates a new <see cref="Range{T}"/> struct initialized with <see cref="ValueTuple{T,T}.Item1"/> as the <see cref="Minimum"/> and <see cref="ValueTuple{T,T}.Item2"/> as the <see cref="Maximum"/>.</para>
/// <para>Создает новую структуру <see cref="Range{T}"/>, инициализированную с помощью <see cref="ValueTuple{T,T}.Item1"/> как <see cref="Minimum"/> и <see cref="ValueTuple{T,T}.Item2"/> как <see cref="Maximum"/>.</para>
/// </summary>
/// <param name="tuple"><para>The tuple.</para><para>Кортеж.</para></param>
/// <param name="tuple">
/// <para>The tuple of values for the <see cref="Minimum"/> and <see cref="Maximum"/>.</para>
/// <para>Кортеж значений для <see cref="Minimum"/> и <see cref="Maximum"/>.</para>
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Range<T>(ValueTuple<T, T> tuple) => new Range<T>(tuple.Item1, tuple.Item2);

/// <summary>
/// <para>Determines whether the current range is equal to another object.</para>
/// <para>Определяет, равен ли текущий диапазон другому объекту.</para>
/// <para>Determines whether the current <see cref="Range{T}"/> and the <paramref name="obj"/> are equal.</para>
/// <para>Определяет, равны ли текущий <see cref="Range{T}"/> и <paramref name="obj"/>.</para>
/// </summary>
/// <param name="obj"><para>An object to compare with this range.</para><para>Объект для сравнения с этим диапазоном.</para></param>
/// <returns><para>True if the current range is equal to the other object; otherwise, false.</para><para>True, если текущий диапазон равен другому объекту; иначе false.</para></returns>
/// <param name="obj">
/// <para>An object to compare with the current <see cref="Range{T}"/>.</para>
/// <para>Объект для сравнения с текущим <see cref="Range{T}"/>.</para>
/// </param>
/// <returns>
/// <para>A <see cref="Boolean"/> value that determines whether the current <see cref="Range{T}"/> and the <paramref name="obj"/> are equal.</para>
/// <para>Значение типа <see cref="Boolean"/> определяющее, равны ли текущий <see cref="Range{T}"/> и <paramref name="obj"/>.</para>
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj) => obj is Range<T> range ? Equals(range) : false;

/// <summary>
/// Calculates the hash code for the current <see cref="Range{T}"/> instance.
/// <para>Calculates a hash code for the current <see cref="Range{T}"/>.</para>
/// <para>Вычисляет хеш код для текущего <see cref="Range{T}"/>.</para>
/// </summary>
/// <returns>The hash code for the current <see cref="Range{T}"/> instance.</returns>
/// <returns>
/// <para>A hash code for the current <see cref="Range{T}"/>.</para>
/// <para>Хеш код для текущего <see cref="Range{T}"/>.</para>
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode() => (Minimum, Maximum).GetHashCode();

/// <summary>
/// <para>Determines if the specified range is equal to the current range.</para>
/// <para>Определяет, равен ли указанный диапазон текущему диапазону.</para>
/// <para>Determines if the <paramref name="left"/> and the <paramref name="right"/> are equal.</para>
/// <para>Определяет, равны ли <paramref name="left"/> и <paramref name="right"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <param name="left"><para>The current range.</para><para>Текущий диапазон.</para></param>
/// <param name="right"><para>A range to compare with this range.</para><para>Диапазон для сравнения с этим диапазоном.</para></param>
/// <returns><para>True if the current range is equal to the other range; otherwise, false.</para><para>True, если текущий диапазон равен другому диапазону; иначе false.</para></returns>
/// <param name="left">
/// <para>The current <see cref="Range{T}"/> to compare with the <paramref name="right"/>.</para>
/// <para>Текущий <see cref="Range{T}"/> для сравнения с <paramref name="right"/>.</para>
/// </param>
/// <param name="right">
/// <para>A <see cref="Range{T}"/> to compare with the <paramref name="left"/>.</para>
/// <para><see cref="Range{T}"/> для сравнения с <paramref name="left"/>.</para>
/// </param>
/// <returns>
/// <para>A <see cref="Boolean"/> value that determines whether the <paramref name="left"/> and the <paramref name="right"/> are equal.</para>
/// <para>Значение типа <see cref="Boolean"/>, определяющее, равны ли <paramref name="left"/> и <paramref name="right"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Range<T> left, Range<T> right) => left.Equals(right);

/// <summary>
/// <para>Determines if the specified range is not equal to the current range.</para>
/// <para>Определяет, не равен ли указанный диапазон текущему диапазону.</para>
/// <para>Determines if the <paramref name="left"/> and the <paramref name="right"/> are not equal.</para>
/// <para>Определяет, не равны ли <paramref name="left"/> и <paramref name="right"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <param name="left"><para>The current range.</para><para>Текущий диапазон.</para></param>
/// <param name="right"><para>A range to compare with this range.</para><para>Диапазон для сравнения с этим диапазоном.</para></param>
/// <returns><para>True if the current range is not equal to the other range; otherwise, false.</para><para>True, если текущий диапазон не равен другому диапазону; иначе false.</para></returns>
/// <param name="left">
/// <para>The current <see cref="Range{T}"/>.</para>
/// <para>Текущий <see cref="Range{T}"/>.</para>
/// </param>
/// <param name="right">
/// <para>A <see cref="Range{T}"/> to compare with this <see cref="Range{T}"/>.</para>
/// <para><see cref="Range{T}"/> для сравнения с этим <see cref="Range{T}"/>.</para>
/// </param>
/// <returns>
/// <para>A <see cref="Boolean"/> value that determines whether the <paramref name="left"/> and the <paramref name="right"/> are not equal.</para>
/// <para>Значение типа <see cref="Boolean"/>, определяющее, не равны ли <paramref name="left"/> и <paramref name="right"/>.</para>
FreePhoenix888 marked this conversation as resolved.
Show resolved Hide resolved
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Range<T> left, Range<T> right) => !(left == right);
}
Expand Down