Skip to content

Commit f70357e

Browse files
Updated to .NET 8 (#33)
* Updated to .NET 8 * Updated GitHub Actions configuration to use .NET 8.0.x
1 parent b374c45 commit f70357e

File tree

13 files changed

+79
-37
lines changed

13 files changed

+79
-37
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v1
2121
with:
22-
dotnet-version: 7.0.x
22+
dotnet-version: 8.0.x
2323
- name: Restore dependencies
2424
run: dotnet restore
2525
- name: Build

OnixLabs.Core.UnitTests.Data/OnixLabs.Core.UnitTests.Data.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

88
<IsPackable>false</IsPackable>
9+
10+
<LangVersion>12</LangVersion>
911
</PropertyGroup>
1012

1113
<ItemGroup>

OnixLabs.Core.UnitTests/OnixLabs.Core.UnitTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net7.0</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<IsPackable>false</IsPackable>
5-
<LangVersion>11</LangVersion>
5+
<LangVersion>12</LangVersion>
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>

OnixLabs.Core/Collections/Collection.Empty.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Collections.Generic;
1717
using System.Collections.Immutable;
1818
using System.Linq;
19+
using System.Runtime.CompilerServices;
1920

2021
namespace OnixLabs.Core.Collections;
2122

@@ -29,6 +30,7 @@ public static partial class Collection
2930
/// </summary>
3031
/// <typeparam name="T">The underlying type of the enumerable.</typeparam>
3132
/// <returns>Returns an empty enumerable.</returns>
33+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
3234
public static IEnumerable<T> EmptyEnumerable<T>()
3335
{
3436
return Enumerable.Empty<T>();
@@ -39,6 +41,7 @@ public static IEnumerable<T> EmptyEnumerable<T>()
3941
/// </summary>
4042
/// <typeparam name="T">The underlying type of the array.</typeparam>
4143
/// <returns>Returns an empty array.</returns>
44+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
4245
public static T[] EmptyArray<T>()
4346
{
4447
return Array.Empty<T>();
@@ -49,6 +52,7 @@ public static T[] EmptyArray<T>()
4952
/// </summary>
5053
/// <typeparam name="T">The underlying type of the immutable array.</typeparam>
5154
/// <returns>Returns an empty immutable array.</returns>
55+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
5256
public static ImmutableArray<T> EmptyImmutableArray<T>()
5357
{
5458
return ImmutableArray<T>.Empty;
@@ -59,16 +63,18 @@ public static ImmutableArray<T> EmptyImmutableArray<T>()
5963
/// </summary>
6064
/// <typeparam name="T">The underlying type of the list.</typeparam>
6165
/// <returns>Returns an empty list.</returns>
66+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
6267
public static List<T> EmptyList<T>()
6368
{
64-
return new List<T>();
69+
return [];
6570
}
6671

6772
/// <summary>
6873
/// Creates an empty immutable list.
6974
/// </summary>
7075
/// <typeparam name="T">The underlying type of the immutable list.</typeparam>
7176
/// <returns>Returns an empty immutable list.</returns>
77+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
7278
public static ImmutableList<T> EmptyImmutableList<T>()
7379
{
7480
return ImmutableList<T>.Empty;
@@ -80,9 +86,10 @@ public static ImmutableList<T> EmptyImmutableList<T>()
8086
/// <typeparam name="TKey">The underlying type of the dictionary key.</typeparam>
8187
/// <typeparam name="TValue">The underlying type of the dictionary value.</typeparam>
8288
/// <returns>Returns an empty dictionary.</returns>
89+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
8390
public static Dictionary<TKey, TValue> EmptyDictionary<TKey, TValue>() where TKey : notnull
8491
{
85-
return new Dictionary<TKey, TValue>();
92+
return [];
8693
}
8794

8895
/// <summary>
@@ -91,6 +98,7 @@ public static Dictionary<TKey, TValue> EmptyDictionary<TKey, TValue>() where TKe
9198
/// <typeparam name="TKey">The underlying type of the immutable dictionary key.</typeparam>
9299
/// <typeparam name="TValue">The underlying type of the immutable dictionary value.</typeparam>
93100
/// <returns>Returns an empty immutable dictionary.</returns>
101+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
94102
public static ImmutableDictionary<TKey, TValue> EmptyImmutableDictionary<TKey, TValue>() where TKey : notnull
95103
{
96104
return ImmutableDictionary<TKey, TValue>.Empty;
@@ -102,9 +110,10 @@ public static ImmutableDictionary<TKey, TValue> EmptyImmutableDictionary<TKey, T
102110
/// <typeparam name="TKey">The underlying type of the sorted dictionary key.</typeparam>
103111
/// <typeparam name="TValue">The underlying type of the sorted dictionary value.</typeparam>
104112
/// <returns>Returns an empty sorted dictionary.</returns>
113+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
105114
public static SortedDictionary<TKey, TValue> EmptySortedDictionary<TKey, TValue>() where TKey : notnull
106115
{
107-
return new SortedDictionary<TKey, TValue>();
116+
return [];
108117
}
109118

110119
/// <summary>
@@ -113,6 +122,7 @@ public static SortedDictionary<TKey, TValue> EmptySortedDictionary<TKey, TValue>
113122
/// <typeparam name="TKey">The underlying type of the immutable sorted dictionary key.</typeparam>
114123
/// <typeparam name="TValue">The underlying type of the immutable sorted dictionary value.</typeparam>
115124
/// <returns>Returns an empty immutable sorted dictionary.</returns>
125+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
116126
public static ImmutableSortedDictionary<TKey, TValue> EmptyImmutableSortedDictionary<TKey, TValue>() where TKey : notnull
117127
{
118128
return ImmutableSortedDictionary<TKey, TValue>.Empty;
@@ -123,16 +133,18 @@ public static ImmutableSortedDictionary<TKey, TValue> EmptyImmutableSortedDictio
123133
/// </summary>
124134
/// <typeparam name="T">The underlying type of the hash set.</typeparam>
125135
/// <returns>Returns an empty hash set.</returns>
136+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
126137
public static HashSet<T> EmptyHashSet<T>()
127138
{
128-
return new HashSet<T>();
139+
return [];
129140
}
130141

131142
/// <summary>
132143
/// Creates an empty immutable hash set.
133144
/// </summary>
134145
/// <typeparam name="T">The underlying type of the immutable hash set.</typeparam>
135146
/// <returns>Returns an empty immutable hash set.</returns>
147+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
136148
public static ImmutableHashSet<T> EmptyImmutableHashSet<T>()
137149
{
138150
return ImmutableHashSet<T>.Empty;
@@ -143,16 +155,18 @@ public static ImmutableHashSet<T> EmptyImmutableHashSet<T>()
143155
/// </summary>
144156
/// <typeparam name="T">The underlying type of the sorted set.</typeparam>
145157
/// <returns>Returns an empty sorted set.</returns>
158+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
146159
public static SortedSet<T> EmptySortedSet<T>()
147160
{
148-
return new SortedSet<T>();
161+
return [];
149162
}
150163

151164
/// <summary>
152165
/// Creates an empty immutable sorted set.
153166
/// </summary>
154167
/// <typeparam name="T">The underlying type of the immutable sorted set.</typeparam>
155168
/// <returns>Returns an empty immutable sorted set.</returns>
169+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
156170
public static ImmutableSortedSet<T> EmptyImmutableSortedSet<T>()
157171
{
158172
return ImmutableSortedSet<T>.Empty;
@@ -163,16 +177,18 @@ public static ImmutableSortedSet<T> EmptyImmutableSortedSet<T>()
163177
/// </summary>
164178
/// <typeparam name="T">The underlying type of the stack.</typeparam>
165179
/// <returns>Returns an empty stack.</returns>
180+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
166181
public static Stack<T> EmptyStack<T>()
167182
{
168-
return new Stack<T>();
183+
return [];
169184
}
170185

171186
/// <summary>
172187
/// Creates an empty immutable stack.
173188
/// </summary>
174189
/// <typeparam name="T">The underlying type of the immutable stack.</typeparam>
175190
/// <returns>Returns an empty immutable stack.</returns>
191+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
176192
public static ImmutableStack<T> EmptyImmutableStack<T>()
177193
{
178194
return ImmutableStack<T>.Empty;
@@ -183,16 +199,18 @@ public static ImmutableStack<T> EmptyImmutableStack<T>()
183199
/// </summary>
184200
/// <typeparam name="T">The underlying type of the queue.</typeparam>
185201
/// <returns>Returns an empty queue.</returns>
202+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
186203
public static Queue<T> EmptyQueue<T>()
187204
{
188-
return new Queue<T>();
205+
return [];
189206
}
190207

191208
/// <summary>
192209
/// Creates an empty immutable queue.
193210
/// </summary>
194211
/// <typeparam name="T">The underlying type of the immutable queue.</typeparam>
195212
/// <returns>Returns an empty immutable queue.</returns>
213+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
196214
public static ImmutableQueue<T> EmptyImmutableQueue<T>()
197215
{
198216
return ImmutableQueue<T>.Empty;

0 commit comments

Comments
 (0)