Skip to content

Commit c405c9b

Browse files
Lots of improvements to the codebase, including XMLDocs, extension blocks, and code reductions due to implicit span conversion, and CallerArgumentExpressions.
1 parent fad807c commit c405c9b

30 files changed

+1145
-1257
lines changed

OnixLabs.Core.UnitTests/Linq/IEnumerableExtensionTests.cs

Lines changed: 82 additions & 79 deletions
Large diffs are not rendered by default.

OnixLabs.Core/Collections/Collection.Empty.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,123 +23,123 @@ namespace OnixLabs.Core.Collections;
2323
public static partial class Collection
2424
{
2525
/// <summary>
26-
/// Creates an empty enumerable.
26+
/// Creates an empty <see cref="IEnumerable{T}"/>.
2727
/// </summary>
2828
/// <typeparam name="T">The underlying type of the enumerable.</typeparam>
2929
/// <returns>Returns an empty enumerable.</returns>
3030
public static IEnumerable<T> EmptyEnumerable<T>() => [];
3131

3232
/// <summary>
33-
/// Creates an empty array.
33+
/// Creates an empty <typeparamref name="T"/> array.
3434
/// </summary>
3535
/// <typeparam name="T">The underlying type of the array.</typeparam>
3636
/// <returns>Returns an empty array.</returns>
3737
public static T[] EmptyArray<T>() => [];
3838

3939
/// <summary>
40-
/// Creates an empty immutable array.
40+
/// Creates an empty <see cref="ImmutableArray{T}"/>.
4141
/// </summary>
4242
/// <typeparam name="T">The underlying type of the immutable array.</typeparam>
4343
/// <returns>Returns an empty immutable array.</returns>
4444
public static ImmutableArray<T> EmptyImmutableArray<T>() => [];
4545

4646
/// <summary>
47-
/// Creates an empty list.
47+
/// Creates an empty <see cref="List{T}"/>.
4848
/// </summary>
4949
/// <typeparam name="T">The underlying type of the list.</typeparam>
5050
/// <returns>Returns an empty list.</returns>
5151
public static List<T> EmptyList<T>() => [];
5252

5353
/// <summary>
54-
/// Creates an empty immutable list.
54+
/// Creates an empty <see cref="ImmutableList{T}"/>.
5555
/// </summary>
5656
/// <typeparam name="T">The underlying type of the immutable list.</typeparam>
5757
/// <returns>Returns an empty immutable list.</returns>
5858
public static ImmutableList<T> EmptyImmutableList<T>() => [];
5959

6060
/// <summary>
61-
/// Creates an empty dictionary.
61+
/// Creates an empty <see cref="Dictionary{TKey,TValue}"/>.
6262
/// </summary>
6363
/// <typeparam name="TKey">The underlying type of the dictionary key.</typeparam>
6464
/// <typeparam name="TValue">The underlying type of the dictionary value.</typeparam>
6565
/// <returns>Returns an empty dictionary.</returns>
6666
public static Dictionary<TKey, TValue> EmptyDictionary<TKey, TValue>() where TKey : notnull => [];
6767

6868
/// <summary>
69-
/// Creates an empty immutable dictionary.
69+
/// Creates an empty <see cref="ImmutableDictionary{TKey,TValue}"/>.
7070
/// </summary>
7171
/// <typeparam name="TKey">The underlying type of the immutable dictionary key.</typeparam>
7272
/// <typeparam name="TValue">The underlying type of the immutable dictionary value.</typeparam>
7373
/// <returns>Returns an empty immutable dictionary.</returns>
7474
public static ImmutableDictionary<TKey, TValue> EmptyImmutableDictionary<TKey, TValue>() where TKey : notnull => ImmutableDictionary<TKey, TValue>.Empty;
7575

7676
/// <summary>
77-
/// Creates an empty sorted dictionary.
77+
/// Creates an empty <see cref="SortedDictionary{TKey,TValue}"/>.
7878
/// </summary>
7979
/// <typeparam name="TKey">The underlying type of the sorted dictionary key.</typeparam>
8080
/// <typeparam name="TValue">The underlying type of the sorted dictionary value.</typeparam>
8181
/// <returns>Returns an empty sorted dictionary.</returns>
8282
public static SortedDictionary<TKey, TValue> EmptySortedDictionary<TKey, TValue>() where TKey : notnull => [];
8383

8484
/// <summary>
85-
/// Creates an empty immutable sorted dictionary.
85+
/// Creates an empty <see cref="ImmutableSortedDictionary{TKey,TValue}"/>.
8686
/// </summary>
8787
/// <typeparam name="TKey">The underlying type of the immutable sorted dictionary key.</typeparam>
8888
/// <typeparam name="TValue">The underlying type of the immutable sorted dictionary value.</typeparam>
8989
/// <returns>Returns an empty immutable sorted dictionary.</returns>
9090
public static ImmutableSortedDictionary<TKey, TValue> EmptyImmutableSortedDictionary<TKey, TValue>() where TKey : notnull => ImmutableSortedDictionary<TKey, TValue>.Empty;
9191

9292
/// <summary>
93-
/// Creates an empty hash set.
93+
/// Creates an empty <see cref="HashSet{T}"/>.
9494
/// </summary>
9595
/// <typeparam name="T">The underlying type of the hash set.</typeparam>
9696
/// <returns>Returns an empty hash set.</returns>
9797
public static HashSet<T> EmptyHashSet<T>() => [];
9898

9999
/// <summary>
100-
/// Creates an empty immutable hash set.
100+
/// Creates an empty <see cref="ImmutableHashSet{T}"/>.
101101
/// </summary>
102102
/// <typeparam name="T">The underlying type of the immutable hash set.</typeparam>
103103
/// <returns>Returns an empty immutable hash set.</returns>
104104
public static ImmutableHashSet<T> EmptyImmutableHashSet<T>() => [];
105105

106106
/// <summary>
107-
/// Creates an empty sorted set.
107+
/// Creates an empty <see cref="SortedSet{T}"/>.
108108
/// </summary>
109109
/// <typeparam name="T">The underlying type of the sorted set.</typeparam>
110110
/// <returns>Returns an empty sorted set.</returns>
111111
public static SortedSet<T> EmptySortedSet<T>() => [];
112112

113113
/// <summary>
114-
/// Creates an empty immutable sorted set.
114+
/// Creates an empty <see cref="ImmutableSortedSet{T}"/>.
115115
/// </summary>
116116
/// <typeparam name="T">The underlying type of the immutable sorted set.</typeparam>
117117
/// <returns>Returns an empty immutable sorted set.</returns>
118118
public static ImmutableSortedSet<T> EmptyImmutableSortedSet<T>() => [];
119119

120120
/// <summary>
121-
/// Creates an empty stack.
121+
/// Creates an empty <see cref="Stack{T}"/>.
122122
/// </summary>
123123
/// <typeparam name="T">The underlying type of the stack.</typeparam>
124124
/// <returns>Returns an empty stack.</returns>
125125
public static Stack<T> EmptyStack<T>() => [];
126126

127127
/// <summary>
128-
/// Creates an empty immutable stack.
128+
/// Creates an empty <see cref="ImmutableStack{T}"/>.
129129
/// </summary>
130130
/// <typeparam name="T">The underlying type of the immutable stack.</typeparam>
131131
/// <returns>Returns an empty immutable stack.</returns>
132132
public static ImmutableStack<T> EmptyImmutableStack<T>() => [];
133133

134134
/// <summary>
135-
/// Creates an empty queue.
135+
/// Creates an empty <see cref="Queue{T}"/>.
136136
/// </summary>
137137
/// <typeparam name="T">The underlying type of the queue.</typeparam>
138138
/// <returns>Returns an empty queue.</returns>
139139
public static Queue<T> EmptyQueue<T>() => [];
140140

141141
/// <summary>
142-
/// Creates an empty immutable queue.
142+
/// Creates an empty <see cref="ImmutableQueue{T}"/>.
143143
/// </summary>
144144
/// <typeparam name="T">The underlying type of the immutable queue.</typeparam>
145145
/// <returns>Returns an empty immutable queue.</returns>

OnixLabs.Core/Collections/Collection.Of.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,114 +18,115 @@
1818

1919
namespace OnixLabs.Core.Collections;
2020

21+
// ReSharper disable MemberCanBePrivate.Global
2122
public static partial class Collection
2223
{
2324
/// <summary>
24-
/// Creates an enumerable of the specified items.
25+
/// Creates an <see cref="IEnumerable{T}"/> of the specified items.
2526
/// </summary>
2627
/// <param name="items">The items which will populate the enumerable.</param>
2728
/// <typeparam name="T">The underlying type of the enumerable.</typeparam>
2829
/// <returns>Returns an enumerable populated with the specified items.</returns>
2930
public static IEnumerable<T> EnumerableOf<T>(params IEnumerable<T> items) => items;
3031

3132
/// <summary>
32-
/// Creates an array of the specified items.
33+
/// Creates a <typeparamref name="T"/> array of the specified items.
3334
/// </summary>
3435
/// <param name="items">The items which will populate the array.</param>
3536
/// <typeparam name="T">The underlying type of the array.</typeparam>
3637
/// <returns>Returns an array populated with the specified items.</returns>
3738
public static T[] ArrayOf<T>(params T[] items) => items;
3839

3940
/// <summary>
40-
/// Creates an immutable array of the specified items.
41+
/// Creates an <see cref="ImmutableArray{T}"/> of the specified items.
4142
/// </summary>
4243
/// <param name="items">The items which will populate the immutable array.</param>
4344
/// <typeparam name="T">The underlying type of the immutable array.</typeparam>
4445
/// <returns>Returns an immutable array populated with the specified items.</returns>
4546
public static ImmutableArray<T> ImmutableArrayOf<T>(params ImmutableArray<T> items) => items;
4647

4748
/// <summary>
48-
/// Creates a list of the specified items.
49+
/// Creates a <see cref="List{T}"/> of the specified items.
4950
/// </summary>
5051
/// <param name="items">The items which will populate the list.</param>
5152
/// <typeparam name="T">The underlying type of the list.</typeparam>
5253
/// <returns>Returns a list populated with the specified items.</returns>
5354
public static List<T> ListOf<T>(params List<T> items) => items;
5455

5556
/// <summary>
56-
/// Creates an immutable list of the specified items.
57+
/// Creates an <see cref="ImmutableList{T}"/> of the specified items.
5758
/// </summary>
5859
/// <param name="items">The items which will populate the immutable list.</param>
5960
/// <typeparam name="T">The underlying type of the immutable list.</typeparam>
6061
/// <returns>Returns an immutable list populated with the specified items.</returns>
6162
public static ImmutableList<T> ImmutableListOf<T>(params ImmutableList<T> items) => items;
6263

6364
/// <summary>
64-
/// Creates a hash set of the specified items.
65+
/// Creates a <see cref="HashSet{T}"/> of the specified items.
6566
/// </summary>
6667
/// <param name="items">The items which will populate the hash set.</param>
6768
/// <typeparam name="T">The underlying type of the hash set.</typeparam>
6869
/// <returns>Returns a hash set populated with the specified items.</returns>
6970
public static HashSet<T> HashSetOf<T>(params HashSet<T> items) => items;
7071

7172
/// <summary>
72-
/// Creates an immutable hash set of the specified items.
73+
/// Creates an <see cref="ImmutableHashSet{T}"/> of the specified items.
7374
/// </summary>
7475
/// <param name="items">The items which will populate the immutable hash set.</param>
7576
/// <typeparam name="T">The underlying type of the immutable hash set.</typeparam>
7677
/// <returns>Returns an immutable hash set populated with the specified items.</returns>
7778
public static ImmutableHashSet<T> ImmutableHashSetOf<T>(params ImmutableHashSet<T> items) => items;
7879

7980
/// <summary>
80-
/// Creates a sorted set of the specified items.
81+
/// Creates a <see cref="SortedSet{T}"/> of the specified items.
8182
/// </summary>
8283
/// <param name="items">The items which will populate the sorted set.</param>
8384
/// <typeparam name="T">The underlying type of the sorted set.</typeparam>
8485
/// <returns>Returns a sorted set populated with the specified items.</returns>
8586
public static SortedSet<T> SortedSetOf<T>(params SortedSet<T> items) => items;
8687

8788
/// <summary>
88-
/// Creates an immutable sorted set of the specified items.
89+
/// Creates an <see cref="ImmutableSortedSet{T}"/> of the specified items.
8990
/// </summary>
9091
/// <param name="items">The items which will populate the immutable sorted set.</param>
9192
/// <typeparam name="T">The underlying type of the immutable sorted set.</typeparam>
9293
/// <returns>Returns an immutable sorted set populated with the specified items.</returns>
9394
public static ImmutableSortedSet<T> ImmutableSortedSetOf<T>(params ImmutableSortedSet<T> items) => items;
9495

9596
/// <summary>
96-
/// Creates a stack of the specified items.
97+
/// Creates a <see cref="Stack{T}"/> of the specified items.
9798
/// </summary>
9899
/// <param name="items">The items which will populate the stack.</param>
99100
/// <typeparam name="T">The underlying type of the stack.</typeparam>
100101
/// <returns>Returns a stack populated with the specified items.</returns>
101102
public static Stack<T> StackOf<T>(params IEnumerable<T> items) => new(items);
102103

103104
/// <summary>
104-
/// Creates an immutable stack of the specified items.
105+
/// Creates an <see cref="ImmutableStack{T}"/> of the specified items.
105106
/// </summary>
106107
/// <param name="items">The items which will populate the immutable stack.</param>
107108
/// <typeparam name="T">The underlying type of the immutable stack.</typeparam>
108109
/// <returns>Returns an immutable stack populated with the specified items.</returns>
109110
public static ImmutableStack<T> ImmutableStackOf<T>(params ImmutableStack<T> items) => items;
110111

111112
/// <summary>
112-
/// Creates a queue of the specified items.
113+
/// Creates a <see cref="Queue{T}"/> of the specified items.
113114
/// </summary>
114115
/// <param name="items">The items which will populate the queue.</param>
115116
/// <typeparam name="T">The underlying type of the queue.</typeparam>
116117
/// <returns>Returns a queue populated with the specified items.</returns>
117118
public static Queue<T> QueueOf<T>(params IEnumerable<T> items) => new(items);
118119

119120
/// <summary>
120-
/// Creates an immutable queue of the specified items.
121+
/// Creates an <see cref="ImmutableQueue{T}"/> of the specified items.
121122
/// </summary>
122123
/// <param name="items">The items which will populate the immutable queue.</param>
123124
/// <typeparam name="T">The underlying type of the immutable queue.</typeparam>
124125
/// <returns>Returns an immutable queue populated with the specified items.</returns>
125126
public static ImmutableQueue<T> ImmutableQueueOf<T>(params ImmutableQueue<T> items) => items;
126127

127128
/// <summary>
128-
/// Create a dictionary of the specified items.
129+
/// Create a <see cref="Dictionary{TKey,TValue}"/> of the specified items.
129130
/// </summary>
130131
/// <param name="items">The items which wil populate the dictionary.</param>
131132
/// <typeparam name="TKey">The underlying type of the dictionary key.</typeparam>
@@ -135,7 +136,7 @@ public static Dictionary<TKey, TValue> DictionaryOf<TKey, TValue>
135136
(params IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull => new(items);
136137

137138
/// <summary>
138-
/// Create a dictionary of the specified items.
139+
/// Create a <see cref="Dictionary{TKey,TValue}"/> of the specified items.
139140
/// </summary>
140141
/// <param name="items">The items which wil populate the dictionary.</param>
141142
/// <typeparam name="TKey">The underlying type of the dictionary key.</typeparam>
@@ -146,7 +147,7 @@ public static Dictionary<TKey, TValue> DictionaryOf<TKey, TValue>
146147
DictionaryOf(items.Select(item => new KeyValuePair<TKey, TValue>(item.key, item.value)));
147148

148149
/// <summary>
149-
/// Create an immutable dictionary of the specified items.
150+
/// Create an <see cref="ImmutableDictionary{TKey,TValue}"/> of the specified items.
150151
/// </summary>
151152
/// <param name="items">The items which wil populate the immutable dictionary.</param>
152153
/// <typeparam name="TKey">The underlying type of the immutable dictionary key.</typeparam>
@@ -156,7 +157,7 @@ public static ImmutableDictionary<TKey, TValue> ImmutableDictionaryOf<TKey, TVal
156157
(params IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull => ImmutableDictionary.CreateRange(items);
157158

158159
/// <summary>
159-
/// Create an immutable dictionary of the specified items.
160+
/// Create an <see cref="ImmutableDictionary{TKey,TValue}"/> of the specified items.
160161
/// </summary>
161162
/// <param name="items">The items which wil populate the immutable dictionary.</param>
162163
/// <typeparam name="TKey">The underlying type of the immutable dictionary key.</typeparam>
@@ -167,7 +168,7 @@ public static ImmutableDictionary<TKey, TValue> ImmutableDictionaryOf<TKey, TVal
167168
ImmutableDictionary.CreateRange(items.Select(item => new KeyValuePair<TKey, TValue>(item.key, item.value)));
168169

169170
/// <summary>
170-
/// Create a sorted dictionary of the specified items.
171+
/// Create a <see cref="SortedDictionary{TKey,TValue}"/> of the specified items.
171172
/// </summary>
172173
/// <param name="items">The items which wil populate the sorted dictionary.</param>
173174
/// <typeparam name="TKey">The underlying type of the sorted dictionary key.</typeparam>
@@ -177,7 +178,7 @@ public static SortedDictionary<TKey, TValue> SortedDictionaryOf<TKey, TValue>
177178
(params IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull => new(DictionaryOf(items));
178179

179180
/// <summary>
180-
/// Create a sorted dictionary of the specified items.
181+
/// Create a <see cref="SortedDictionary{TKey,TValue}"/> of the specified items.
181182
/// </summary>
182183
/// <param name="items">The items which wil populate the sorted dictionary.</param>
183184
/// <typeparam name="TKey">The underlying type of the sorted dictionary key.</typeparam>
@@ -187,7 +188,7 @@ public static SortedDictionary<TKey, TValue> SortedDictionaryOf<TKey, TValue>
187188
(params IEnumerable<(TKey key, TValue value)> items) where TKey : notnull => new(DictionaryOf(items));
188189

189190
/// <summary>
190-
/// Create an immutable sorted dictionary of the specified items.
191+
/// Create an <see cref="ImmutableSortedDictionary{TKey,TValue}"/> of the specified items.
191192
/// </summary>
192193
/// <param name="items">The items which wil populate the immutable sorted dictionary.</param>
193194
/// <typeparam name="TKey">The underlying type of the immutable sorted dictionary key.</typeparam>
@@ -197,7 +198,7 @@ public static ImmutableSortedDictionary<TKey, TValue> ImmutableSortedDictionaryO
197198
(params IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull => ImmutableSortedDictionary.CreateRange(items);
198199

199200
/// <summary>
200-
/// Create an immutable sorted dictionary of the specified items.
201+
/// Create an <see cref="ImmutableSortedDictionary{TKey,TValue}"/> of the specified items.
201202
/// </summary>
202203
/// <param name="items">The items which wil populate the immutable sorted dictionary.</param>
203204
/// <typeparam name="TKey">The underlying type of the immutable sorted dictionary key.</typeparam>

OnixLabs.Core/Enumeration.Get.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ namespace OnixLabs.Core;
2222
public abstract partial class Enumeration<T>
2323
{
2424
/// <summary>
25-
/// Gets all of the enumeration entries for the current type.
25+
/// Gets all the enumeration entries for the current type.
2626
/// </summary>
27-
/// <returns>Returns all of the enumeration entries for the current type.</returns>
27+
/// <returns>Returns all the enumeration entries for the current type.</returns>
2828
public static IReadOnlySet<T> GetAll() => typeof(T)
2929
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)
3030
.Select(field => field.GetValue(null))
3131
.OfType<T>()
3232
.ToFrozenSet();
3333

3434
/// <summary>
35-
/// Gets all of the enumeration entries for the current type.
35+
/// Gets all the enumeration entries for the current type.
3636
/// </summary>
37-
/// <returns>Returns all of the enumeration entries for the current type.</returns>
37+
/// <returns>Returns all the enumeration entries for the current type.</returns>
3838
public static IReadOnlySet<(int Value, string Name)> GetEntries() => GetAll().Select(entry => entry.ToEntry()).ToFrozenSet();
3939

4040
/// <summary>
41-
/// Gets all of the enumeration names for the current type.
41+
/// Gets all the enumeration names for the current type.
4242
/// </summary>
43-
/// <returns>Returns all of the enumeration names for the current type.</returns>
43+
/// <returns>Returns all the enumeration names for the current type.</returns>
4444
public static IReadOnlySet<string> GetNames() => GetAll().Select(entry => entry.Name).ToFrozenSet();
4545

4646
/// <summary>
47-
/// Gets all of the enumeration values for the current type.
47+
/// Gets all the enumeration values for the current type.
4848
/// </summary>
49-
/// <returns>Returns all of the enumeration values for the current type.</returns>
49+
/// <returns>Returns all the enumeration values for the current type.</returns>
5050
public static IReadOnlySet<int> GetValues() => GetAll().Select(entry => entry.Value).ToFrozenSet();
5151
}

0 commit comments

Comments
 (0)