Skip to content

Commit 8215577

Browse files
feat: Update to C# 12.0 (#101)
1 parent c763ad5 commit 8215577

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
1717
</PropertyGroup>
1818
<PropertyGroup>
19-
<LangVersion>10.0</LangVersion>
19+
<LangVersion>12.0</LangVersion>
2020
<ImplicitUsings>true</ImplicitUsings>
2121
<Nullable>enable</Nullable>
2222
</PropertyGroup>

IntelliTect.Multitool.Tests/ClaimsPrincipalExtensionsTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace IntelliTect.Multitool.Security.Tests;
66

77
public class ClaimsPrincipalExtensionsTests
88
{
9-
static readonly string[] roles = new[] { "Foo", "Bar" };
10-
static readonly string[] singleRole = new[] { "Bar" };
9+
static readonly string[] roles = ["Foo", "Bar"];
10+
static readonly string[] singleRole = ["Bar"];
1111

1212
[Fact]
1313
public void GetRoles_WhenClaimsPrincipalNull_Should_Throw()

IntelliTect.Multitool/Extensions/HttpExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public static async Task<bool> ValidateUri(this HttpClient client, Uri uri, Prod
5050
/// <returns>The result of the call</returns>
5151
public static async Task<bool> ValidateUri(this HttpClient client, Uri uri, ProductInfoHeaderValue? headerValue, HttpCompletionOption completionOption = HttpCompletionOption.ResponseHeadersRead)
5252
{
53-
return await ValidateUri(client, uri, headerValue is null ? null : new ProductInfoHeaderValue[] { headerValue }, completionOption);
53+
return await ValidateUri(client, uri, headerValue is null ? null : [headerValue], completionOption);
5454
}
5555
}

IntelliTect.Multitool/ReleaseDateAttribute.cs

+5-13
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@
44
namespace IntelliTect.Multitool;
55

66
/// <summary>
7-
/// The release date assembly attribute
7+
/// The release date assembly attribute with a constructor that takes in a DateTime string
88
/// </summary>
9+
/// <param name="utcDateString">A DateTime 'O' (round-trip date/time) format string</param>
910
[AttributeUsage(AttributeTargets.Assembly)]
10-
public class ReleaseDateAttribute : Attribute
11+
public class ReleaseDateAttribute(string utcDateString) : Attribute
1112
{
12-
/// <summary>
13-
/// Constructor that takes in a DateTime string
14-
/// </summary>
15-
/// <param name="utcDateString">A DateTime 'O' (round-trip date/time) format string</param>
16-
public ReleaseDateAttribute(string utcDateString)
17-
{
18-
ReleaseDate = DateTime.ParseExact(utcDateString, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
19-
}
20-
2113
/// <summary>
2214
/// The date the assembly was built
2315
/// </summary>
24-
public DateTime ReleaseDate { get; }
16+
public DateTime ReleaseDate { get; } = DateTime.ParseExact(utcDateString, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
2517

2618
/// <summary>
2719
/// Method to obtain the release date from the assembly attribute
@@ -34,4 +26,4 @@ public ReleaseDateAttribute(string utcDateString)
3426
return attribute?.Length >= 1 ? ((ReleaseDateAttribute)attribute[0]).ReleaseDate : null;
3527
}
3628

37-
}
29+
}

0 commit comments

Comments
 (0)