From 1a20061d58c2c19fb75403a02e04dea36f1a2b95 Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 8 Aug 2023 16:37:12 +0100 Subject: [PATCH] Update to ASP.NET Core 8 preview 7 - Update to preview 7 of ASP.NET Core 8. - Suppress `CA1863` warnings to use `CompositeFormat`. - Use `JsonDocument.ParseAsync()` where relevant. --- Directory.Packages.props | 6 +++--- eng/Versions.props | 2 +- global.json | 4 ++-- .../AlipayAuthenticationHandler.cs | 4 ++-- .../AmoCrmAuthenticationOptions.cs | 2 ++ .../DigitalOceanAuthenticationHandler.cs | 2 +- .../OktaAuthenticationDefaults.cs | 2 ++ src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs | 6 +++--- .../ShopifyAuthenticationHandler.cs | 2 ++ .../SuperOfficeAuthenticationHandler.cs | 2 ++ .../SuperOfficeAuthenticationOptions.cs | 2 ++ .../AspNet.Security.OAuth.Providers.Tests.csproj | 2 +- .../StaticAnalysisTests.cs | 6 +++--- 13 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index a0c305f66..7eae81beb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,9 +4,9 @@ - - - + + + diff --git a/eng/Versions.props b/eng/Versions.props index fc416ed3e..f0f2a22aa 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -10,7 +10,7 @@ --> 7.0.0 preview - 6 + 7 Preview $(PreReleaseVersionIteration) false release diff --git a/global.json b/global.json index 8daf0c9fc..97da5baae 100644 --- a/global.json +++ b/global.json @@ -1,12 +1,12 @@ { "sdk": { - "version": "8.0.100-preview.6.23330.14", + "version": "8.0.100-preview.7.23376.3", "allowPrerelease": true, "rollForward": "major" }, "tools": { - "dotnet": "8.0.100-preview.6.23330.14" + "dotnet": "8.0.100-preview.7.23376.3" }, "msbuild-sdks": { diff --git a/src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationHandler.cs index ce135029d..513bb3bf5 100644 --- a/src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationHandler.cs @@ -78,7 +78,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA } using var stream = await response.Content.ReadAsStreamAsync(Context.RequestAborted); - using var document = JsonDocument.Parse(stream); + using var document = await JsonDocument.ParseAsync(stream); var mainElement = document.RootElement.GetProperty("alipay_system_oauth_token_response"); if (!ValidateReturnCode(mainElement, out var code)) @@ -120,7 +120,7 @@ protected override async Task CreateTicketAsync( } using var stream = await response.Content.ReadAsStreamAsync(Context.RequestAborted); - using var document = JsonDocument.Parse(stream); + using var document = await JsonDocument.ParseAsync(stream); var rootElement = document.RootElement; if (!rootElement.TryGetProperty("alipay_user_info_share_response", out JsonElement mainElement)) diff --git a/src/AspNet.Security.OAuth.AmoCrm/AmoCrmAuthenticationOptions.cs b/src/AspNet.Security.OAuth.AmoCrm/AmoCrmAuthenticationOptions.cs index 275e15125..07a52ffd4 100644 --- a/src/AspNet.Security.OAuth.AmoCrm/AmoCrmAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.AmoCrm/AmoCrmAuthenticationOptions.cs @@ -32,6 +32,7 @@ public AmoCrmAuthenticationOptions() ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); } +#pragma warning disable CA1863 /// /// Gets or sets the amoCRM account name. /// @@ -48,4 +49,5 @@ public string Account UserInformationEndpoint = string.Format(CultureInfo.InvariantCulture, AmoCrmAuthenticationDefaults.UserInformationEndpointFormat, value); } } +#pragma warning restore CA1863 } diff --git a/src/AspNet.Security.OAuth.DigitalOcean/DigitalOceanAuthenticationHandler.cs b/src/AspNet.Security.OAuth.DigitalOcean/DigitalOceanAuthenticationHandler.cs index 90ba39a58..bdd4488fc 100644 --- a/src/AspNet.Security.OAuth.DigitalOcean/DigitalOceanAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.DigitalOcean/DigitalOceanAuthenticationHandler.cs @@ -56,7 +56,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA } using var stream = await response.Content.ReadAsStreamAsync(Context.RequestAborted); - var payload = JsonDocument.Parse(stream); + var payload = await JsonDocument.ParseAsync(stream); return OAuthTokenResponse.Success(payload); } diff --git a/src/AspNet.Security.OAuth.Okta/OktaAuthenticationDefaults.cs b/src/AspNet.Security.OAuth.Okta/OktaAuthenticationDefaults.cs index 9ddbdbc56..bb922a1e3 100644 --- a/src/AspNet.Security.OAuth.Okta/OktaAuthenticationDefaults.cs +++ b/src/AspNet.Security.OAuth.Okta/OktaAuthenticationDefaults.cs @@ -53,6 +53,7 @@ public static class OktaAuthenticationDefaults /// public static readonly string UserInformationEndpointPathFormat = "/oauth2/{0}/v1/userinfo"; +#pragma warning disable CA1863 /// /// Default path to use for . /// @@ -67,4 +68,5 @@ public static class OktaAuthenticationDefaults /// Default path to use for . /// public static readonly string UserInformationEndpointPath = string.Format(CultureInfo.InvariantCulture, UserInformationEndpointPathFormat, DefaultAuthorizationServer); +#pragma warning disable CA1863 } diff --git a/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs b/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs index e2f820c64..d5c629d97 100644 --- a/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( } using var stream = await response.Content.ReadAsStreamAsync(Context.RequestAborted); - using var payload = JsonDocument.Parse(stream); + using var payload = await JsonDocument.ParseAsync(stream); var status = payload.RootElement.GetProperty("ret").GetInt32(); @@ -109,7 +109,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA } using var stream = await response.Content.ReadAsStreamAsync(Context.RequestAborted); - var payload = JsonDocument.Parse(stream); + var payload = await JsonDocument.ParseAsync(stream); return OAuthTokenResponse.Success(payload); } @@ -139,7 +139,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA } using var stream = await response.Content.ReadAsStreamAsync(Context.RequestAborted); - using JsonDocument payload = JsonDocument.Parse(stream); + using var payload = await JsonDocument.ParseAsync(stream); var payloadRoot = payload.RootElement; diff --git a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs index f294f12bd..9ed22158f 100644 --- a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs @@ -34,10 +34,12 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { +#pragma warning disable CA1863 var uri = string.Format( CultureInfo.InvariantCulture, ShopifyAuthenticationDefaults.UserInformationEndpointFormat, properties.Items[ShopifyAuthenticationDefaults.ShopNameAuthenticationProperty]); +#pragma warning restore CA1863 using var request = new HttpRequestMessage(HttpMethod.Get, uri); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); diff --git a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs index c91e8a4ed..f067e82d7 100644 --- a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs @@ -50,7 +50,9 @@ protected override async Task CreateTicketAsync( // UserInfo endpoint must support multiple subdomains, i.e. sod, sod1, online, online1, online2, ... // - subdomain only becomes known from id token // Example WebApi Url https://sod.superoffice.com/Cust12345/api/ +#pragma warning disable CA1863 var userInfoEndpoint = string.Format(CultureInfo.InvariantCulture, SuperOfficeAuthenticationConstants.FormatStrings.UserInfoEndpoint, webApiUrl); +#pragma warning restore CA1863 // Get the SuperOffice user principal. using var request = new HttpRequestMessage(HttpMethod.Get, userInfoEndpoint); diff --git a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationOptions.cs b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationOptions.cs index 12ef6fa94..a3f7160de 100644 --- a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationOptions.cs @@ -148,6 +148,7 @@ private void UpdateEndpoints() { string env = GetEnvironment(); +#pragma warning disable CA1863 AuthorizationEndpoint = string.Format(CultureInfo.InvariantCulture, FormatStrings.AuthorizeEndpoint, env); @@ -167,5 +168,6 @@ private void UpdateEndpoints() Authority = string.Format(CultureInfo.InvariantCulture, FormatStrings.Authority, env); +#pragma warning restore CA1863 } } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj b/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj index 8feac6fd1..8f5c34ba0 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj +++ b/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj @@ -5,7 +5,7 @@ $(DefaultNetCoreTargetFramework) false true - $(NoWarn);CA1054;CA1055;CA1707;CA1861;CA2227;CA5404 + $(NoWarn);CA1054;CA1055;CA1707;CA1861;CA1863;CA2227;CA5404 diff --git a/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs index 536944014..1b5956be4 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/StaticAnalysisTests.cs @@ -58,7 +58,7 @@ public static void Publicly_Visible_Parameters_Have_Null_Annotations() testedMethods.ShouldBeGreaterThan(0); } - private static IList GetProviderAssemblyNames() + private static AssemblyName[] GetProviderAssemblyNames() { var thisType = typeof(StaticAnalysisTests); @@ -72,7 +72,7 @@ private static IList GetProviderAssemblyNames() return assemblies; } - private static IList GetPublicTypes(IEnumerable assemblyNames) + private static Type[] GetPublicTypes(IEnumerable assemblyNames) { var types = assemblyNames .Select((p) => AssemblyLoadContext.Default.LoadFromAssemblyName(p)) @@ -85,7 +85,7 @@ private static IList GetPublicTypes(IEnumerable assemblyName return types; } - private static IList GetPublicOrProtectedConstructorsOrMethods(Type type) + private static MethodBase[] GetPublicOrProtectedConstructorsOrMethods(Type type) { var constructors = type .GetConstructors(BindingFlags.Public | BindingFlags.NonPublic)