From c3b4b83b17558183d060ba5c4e27716c3d8d602b Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 29 Feb 2024 13:38:42 +0000 Subject: [PATCH] Update to ASP.NET Core 9 preview 1 - Update to preview 1 of ASP.NET Core 9. - Use xunit's `TheoryData`. - Fix new code analysis warnings and suggestions. - Disable noisy new CA1515 warning. - Update various dependencies to their latest versions. --- Directory.Build.props | 6 ++++-- Directory.Packages.props | 10 +++++----- eng/Versions.props | 8 ++++---- global.json | 4 ++-- .../LinkedInAuthenticationOptions.cs | 2 +- .../SmartsheetAuthenticationOptions.cs | 2 +- .../Apple/AppleAuthenticationOptionsTests.cs | 16 ++++++++-------- .../JumpCloudAuthenticationOptionsTests.cs | 6 +++--- .../KeycloakAuthenticationOptionsTests.cs | 16 ++++++++-------- .../Moodle/MoodleAuthenticationOptionsTests.cs | 6 +++--- .../Okta/OktaAuthenticationOptionsTests.cs | 6 +++--- .../PackageMetadataTests.cs | 8 ++++++-- .../PingOne/PingOneAuthenticationOptionsTests.cs | 6 +++--- .../StackExchangeAuthenticationOptionsTests.cs | 4 ++-- .../StaticAnalysisTests.cs | 2 +- .../Zendesk/ZendeskAuthenticationOptionsTests.cs | 6 +++--- 16 files changed, 57 insertions(+), 51 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 505a83cc9..2f4a3363e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,9 +3,9 @@ - net8.0 + net9.0 latest - $(NoWarn);CS1591 + $(NoWarn);CA1515;CS1591 true true portable @@ -76,6 +76,8 @@ $(IsPackable) + + false diff --git a/Directory.Packages.props b/Directory.Packages.props index 8c2e40a4f..8bc0732dc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,15 +2,15 @@ - + - - - + + + - + diff --git a/eng/Versions.props b/eng/Versions.props index 4c829faac..1d80a6407 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,13 +1,13 @@ - 8 + 9 0 - 1 + 0 $(MajorVersion).$(MinorVersion).$(PatchVersion) - 8.0.0 + 9.0.0 preview - + 1 Preview $(PreReleaseVersionIteration) false release diff --git a/global.json b/global.json index e822854b0..c2718e857 100644 --- a/global.json +++ b/global.json @@ -1,12 +1,12 @@ { "sdk": { - "version": "8.0.100", + "version": "9.0.100-preview.1.24101.2", "allowPrerelease": true, "rollForward": "major" }, "tools": { - "dotnet": "8.0.100" + "dotnet": "9.0.100-preview.1.24101.2" }, "msbuild-sdks": { diff --git a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs index 01322c0f4..8b5217683 100644 --- a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs @@ -29,7 +29,7 @@ public LinkedInAuthenticationOptions() Scope.Add("r_emailaddress"); ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, ProfileFields.Id); - ClaimActions.MapCustomJson(ClaimTypes.Name, user => GetFullName(user)); + ClaimActions.MapCustomJson(ClaimTypes.Name, GetFullName); ClaimActions.MapCustomJson(ClaimTypes.GivenName, user => GetMultiLocaleString(user, ProfileFields.FirstName)); ClaimActions.MapCustomJson(ClaimTypes.Surname, user => GetMultiLocaleString(user, ProfileFields.LastName)); ClaimActions.MapCustomJson(Claims.PictureUrl, user => GetPictureUrls(user)?.LastOrDefault()); diff --git a/src/AspNet.Security.OAuth.Smartsheet/SmartsheetAuthenticationOptions.cs b/src/AspNet.Security.OAuth.Smartsheet/SmartsheetAuthenticationOptions.cs index 95085e38b..f11eb4223 100644 --- a/src/AspNet.Security.OAuth.Smartsheet/SmartsheetAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.Smartsheet/SmartsheetAuthenticationOptions.cs @@ -29,7 +29,7 @@ public SmartsheetAuthenticationOptions() ClaimActions.MapJsonKey(ClaimTypes.GivenName, "firstName"); ClaimActions.MapJsonKey(ClaimTypes.Surname, "lastName"); ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); - ClaimActions.MapCustomJson(Claims.ProfileImage, user => GetProfileImageUri(user)); + ClaimActions.MapCustomJson(Claims.ProfileImage, GetProfileImageUri); } private static string GetProfileImageUri(JsonElement user) diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Apple/AppleAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Apple/AppleAuthenticationOptionsTests.cs index c64404683..44b70b895 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Apple/AppleAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Apple/AppleAuthenticationOptionsTests.cs @@ -19,7 +19,7 @@ public static void Validate_Throws_If_ClientSecret_Is_Null_With_No_Secret_Genera }; // Act and Assert - Assert.Throws("ClientSecret", () => options.Validate()); + Assert.Throws("ClientSecret", options.Validate); } [Fact] @@ -34,7 +34,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Is_Null() }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Fact] @@ -49,7 +49,7 @@ public static void Validate_Throws_If_TokenEndpoint_Is_Null() }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Fact] @@ -64,7 +64,7 @@ public static void Validate_Throws_If_CallbackPath_Is_Null() }; // Act and Assert - Assert.Throws("CallbackPath", () => options.Validate()); + Assert.Throws("CallbackPath", options.Validate); } [Fact] @@ -79,7 +79,7 @@ public static void Validate_Throws_If_KeyId_Is_Null_With_Secret_Generation() }; // Act and Assert - Assert.Throws("KeyId", () => options.Validate()); + Assert.Throws("KeyId", options.Validate); } [Fact] @@ -95,7 +95,7 @@ public static void Validate_Throws_If_TeamId_Is_Null_With_Secret_Generation() }; // Act and Assert - Assert.Throws("TeamId", () => options.Validate()); + Assert.Throws("TeamId", options.Validate); } [Fact] @@ -112,7 +112,7 @@ public static void Validate_Throws_If_TokenAudience_Is_Null_With_Secret_Generati }; // Act and Assert - Assert.Throws("TokenAudience", () => options.Validate()); + Assert.Throws("TokenAudience", options.Validate); } [Fact] @@ -129,6 +129,6 @@ public static void Validate_Throws_If_ClientSecretExpiresAfter_Is_Zero_With_Secr }; // Act and Assert - Assert.Throws("ClientSecretExpiresAfter", () => options.Validate()); + Assert.Throws("ClientSecretExpiresAfter", options.Validate); } } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/JumpCloud/JumpCloudAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/JumpCloud/JumpCloudAuthenticationOptionsTests.cs index 0ca3b1693..724b03f9d 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/JumpCloud/JumpCloudAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/JumpCloud/JumpCloudAuthenticationOptionsTests.cs @@ -21,7 +21,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Fact] @@ -37,7 +37,7 @@ public static void Validate_Throws_If_TokenEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Fact] @@ -53,7 +53,7 @@ public static void Validate_Throws_If_UserInformationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("UserInformationEndpoint", () => options.Validate()); + Assert.Throws("UserInformationEndpoint", options.Validate); } [Fact] diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Keycloak/KeycloakAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Keycloak/KeycloakAuthenticationOptionsTests.cs index 7af492cf4..61e51ba95 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Keycloak/KeycloakAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Keycloak/KeycloakAuthenticationOptionsTests.cs @@ -8,11 +8,11 @@ namespace AspNet.Security.OAuth.Keycloak; public static class KeycloakAuthenticationOptionsTests { - public static IEnumerable AccessTypes => new object[][] + public static TheoryData AccessTypes => new() { - new object[] { KeycloakAuthenticationAccessType.BearerOnly }, - new object[] { KeycloakAuthenticationAccessType.Confidential }, - new object[] { KeycloakAuthenticationAccessType.Public }, + { KeycloakAuthenticationAccessType.BearerOnly }, + { KeycloakAuthenticationAccessType.Confidential }, + { KeycloakAuthenticationAccessType.Public }, }; [Theory] @@ -46,7 +46,7 @@ public static void Validate_Throws_If_ClientSecret_Is_Null(KeycloakAuthenticatio }; // Act and Assert - Assert.Throws("ClientSecret", () => options.Validate()); + Assert.Throws("ClientSecret", options.Validate); } [Theory] @@ -63,7 +63,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Is_Null(KeycloakAuth }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Theory] @@ -80,7 +80,7 @@ public static void Validate_Throws_If_TokenEndpoint_Is_Null(KeycloakAuthenticati }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Theory] @@ -97,6 +97,6 @@ public static void Validate_Throws_If_CallbackPath_Is_Null(KeycloakAuthenticatio }; // Act and Assert - Assert.Throws("CallbackPath", () => options.Validate()); + Assert.Throws("CallbackPath", options.Validate); } } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Moodle/MoodleAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Moodle/MoodleAuthenticationOptionsTests.cs index 2d8863ca6..63a0eef4c 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Moodle/MoodleAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Moodle/MoodleAuthenticationOptionsTests.cs @@ -21,7 +21,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Fact] @@ -37,7 +37,7 @@ public static void Validate_Throws_If_TokenEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Fact] @@ -53,7 +53,7 @@ public static void Validate_Throws_If_UserInformationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("UserInformationEndpoint", () => options.Validate()); + Assert.Throws("UserInformationEndpoint", options.Validate); } [Fact] diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Okta/OktaAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Okta/OktaAuthenticationOptionsTests.cs index 4254b3887..6bb9a30dd 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Okta/OktaAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Okta/OktaAuthenticationOptionsTests.cs @@ -21,7 +21,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Fact] @@ -37,7 +37,7 @@ public static void Validate_Throws_If_TokenEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Fact] @@ -53,7 +53,7 @@ public static void Validate_Throws_If_UserInformationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("UserInformationEndpoint", () => options.Validate()); + Assert.Throws("UserInformationEndpoint", options.Validate); } [Fact] diff --git a/test/AspNet.Security.OAuth.Providers.Tests/PackageMetadataTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/PackageMetadataTests.cs index 8024caf72..f80509464 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/PackageMetadataTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/PackageMetadataTests.cs @@ -17,8 +17,10 @@ public static class PackageMetadataTests .Select((p) => p.Value) .First(); - public static IEnumerable Projects() + public static TheoryData Projects() { + var testCases = new TheoryData(); + foreach (var directory in Directory.EnumerateDirectories(Path.Combine(_solutionRoot!, "src"))) { foreach (var project in Directory.EnumerateFiles(directory, "*.csproj")) @@ -27,10 +29,12 @@ public static IEnumerable Projects() foreach (var propertyName in new[] { "Authors", "Description", "PackageTags" }) { - yield return new object[] { projectName, propertyName }; + testCases.Add(projectName, propertyName); } } } + + return testCases; } [Theory] diff --git a/test/AspNet.Security.OAuth.Providers.Tests/PingOne/PingOneAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/PingOne/PingOneAuthenticationOptionsTests.cs index e22ac42a5..cc12d3f43 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/PingOne/PingOneAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/PingOne/PingOneAuthenticationOptionsTests.cs @@ -21,7 +21,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Fact] @@ -37,7 +37,7 @@ public static void Validate_Throws_If_TokenEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Fact] @@ -53,7 +53,7 @@ public static void Validate_Throws_If_UserInformationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("UserInformationEndpoint", () => options.Validate()); + Assert.Throws("UserInformationEndpoint", options.Validate); } [Fact] diff --git a/test/AspNet.Security.OAuth.Providers.Tests/StackExchange/StackExchangeAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/StackExchange/StackExchangeAuthenticationOptionsTests.cs index 50af1c525..25ac5968b 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/StackExchange/StackExchangeAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/StackExchange/StackExchangeAuthenticationOptionsTests.cs @@ -22,7 +22,7 @@ public static void Validate_Throws_If_RequestKey_Is_Not_Set(string? value) }; // Act and Assert - Assert.Throws("RequestKey", () => options.Validate()); + Assert.Throws("RequestKey", options.Validate); } [Theory] @@ -40,6 +40,6 @@ public static void Validate_Throws_If_Site_Is_Not_Set(string? value) }; // Act and Assert - Assert.Throws("Site", () => options.Validate()); + Assert.Throws("Site", options.Validate); } } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs index 938ae753f..a80f4551a 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs @@ -75,7 +75,7 @@ private static AssemblyName[] GetProviderAssemblyNames() private static Type[] GetPublicTypes(IEnumerable assemblyNames) { var types = assemblyNames - .Select((p) => AssemblyLoadContext.Default.LoadFromAssemblyName(p)) + .Select(AssemblyLoadContext.Default.LoadFromAssemblyName) .SelectMany((p) => p.GetTypes()) .Where((p) => p.IsPublic || p.IsNestedPublic) .ToArray(); diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Zendesk/ZendeskAuthenticationOptionsTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Zendesk/ZendeskAuthenticationOptionsTests.cs index 4cab84916..0f11c5ac1 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Zendesk/ZendeskAuthenticationOptionsTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Zendesk/ZendeskAuthenticationOptionsTests.cs @@ -21,7 +21,7 @@ public static void Validate_Throws_If_AuthorizationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("AuthorizationEndpoint", () => options.Validate()); + Assert.Throws("AuthorizationEndpoint", options.Validate); } [Fact] @@ -37,7 +37,7 @@ public static void Validate_Throws_If_TokenEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("TokenEndpoint", () => options.Validate()); + Assert.Throws("TokenEndpoint", options.Validate); } [Fact] @@ -53,7 +53,7 @@ public static void Validate_Throws_If_UserInformationEndpoint_Not_Set() }; // Act and Assert - Assert.Throws("UserInformationEndpoint", () => options.Validate()); + Assert.Throws("UserInformationEndpoint", options.Validate); } [Fact]