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

feat: Update to C# 12.0 #101

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<LangVersion>10.0</LangVersion>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions IntelliTect.Multitool.Tests/ClaimsPrincipalExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace IntelliTect.Multitool.Security.Tests;

public class ClaimsPrincipalExtensionsTests
{
static readonly string[] roles = new[] { "Foo", "Bar" };
static readonly string[] singleRole = new[] { "Bar" };
static readonly string[] roles = ["Foo", "Bar"];
static readonly string[] singleRole = ["Bar"];

[Fact]
public void GetRoles_WhenClaimsPrincipalNull_Should_Throw()
Expand Down
2 changes: 1 addition & 1 deletion IntelliTect.Multitool/Extensions/HttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public static async Task<bool> ValidateUri(this HttpClient client, Uri uri, Prod
/// <returns>The result of the call</returns>
public static async Task<bool> ValidateUri(this HttpClient client, Uri uri, ProductInfoHeaderValue? headerValue, HttpCompletionOption completionOption = HttpCompletionOption.ResponseHeadersRead)
{
return await ValidateUri(client, uri, headerValue is null ? null : new ProductInfoHeaderValue[] { headerValue }, completionOption);
return await ValidateUri(client, uri, headerValue is null ? null : [headerValue], completionOption);
}
}
18 changes: 5 additions & 13 deletions IntelliTect.Multitool/ReleaseDateAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@
namespace IntelliTect.Multitool;

/// <summary>
/// The release date assembly attribute
/// The release date assembly attribute with a constructor that takes in a DateTime string
/// </summary>
/// <param name="utcDateString">A DateTime 'O' (round-trip date/time) format string</param>
[AttributeUsage(AttributeTargets.Assembly)]
public class ReleaseDateAttribute : Attribute
public class ReleaseDateAttribute(string utcDateString) : Attribute
{
/// <summary>
/// Constructor that takes in a DateTime string
/// </summary>
/// <param name="utcDateString">A DateTime 'O' (round-trip date/time) format string</param>
public ReleaseDateAttribute(string utcDateString)
{
ReleaseDate = DateTime.ParseExact(utcDateString, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
}

/// <summary>
/// The date the assembly was built
/// </summary>
public DateTime ReleaseDate { get; }
public DateTime ReleaseDate { get; } = DateTime.ParseExact(utcDateString, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);

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

}
}
Loading