From 26b841411458fcf41be35b1b880a3b1e51baec98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 12 Oct 2021 20:50:02 +0200 Subject: [PATCH] Remove unnecessary usings --- samples/Mvc.Server/Controllers/AccountController.cs | 4 +--- samples/Mvc.Server/Controllers/AuthorizationController.cs | 5 ----- samples/Mvc.Server/Controllers/ManageController.cs | 5 +---- samples/Mvc.Server/Controllers/ResourceController.cs | 4 +--- samples/Mvc.Server/Controllers/UserinfoController.cs | 5 +---- samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs | 6 +----- samples/Mvc.Server/Helpers/FormValueRequiredAttribute.cs | 4 +--- samples/Mvc.Server/Program.cs | 5 +---- samples/Mvc.Server/Services/IEmailSender.cs | 4 +--- samples/Mvc.Server/Services/ISmsSender.cs | 4 +--- samples/Mvc.Server/Services/MessageServices.cs | 4 +--- samples/Mvc.Server/Startup.cs | 3 --- samples/Mvc.Server/ViewModels/Account/SendCodeViewModel.cs | 3 +-- .../ViewModels/Manage/ConfigureTwoFactorViewModel.cs | 3 +-- samples/Mvc.Server/ViewModels/Manage/IndexViewModel.cs | 3 +-- .../Mvc.Server/ViewModels/Manage/ManageLoginsViewModel.cs | 3 +-- samples/Mvc.Server/Worker.cs | 7 +------ .../OpenIddictServerHandlers.Protection.cs | 7 ++----- 18 files changed, 17 insertions(+), 62 deletions(-) diff --git a/samples/Mvc.Server/Controllers/AccountController.cs b/samples/Mvc.Server/Controllers/AccountController.cs index efc7c9e3..08cb0465 100644 --- a/samples/Mvc.Server/Controllers/AccountController.cs +++ b/samples/Mvc.Server/Controllers/AccountController.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; +using System.Security.Claims; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; diff --git a/samples/Mvc.Server/Controllers/AuthorizationController.cs b/samples/Mvc.Server/Controllers/AuthorizationController.cs index af506b4e..7556377e 100644 --- a/samples/Mvc.Server/Controllers/AuthorizationController.cs +++ b/samples/Mvc.Server/Controllers/AuthorizationController.cs @@ -4,15 +4,10 @@ * the license and the contributors participating to this project. */ -using System; -using System.Collections.Generic; -using System.Linq; using System.Security.Claims; -using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; diff --git a/samples/Mvc.Server/Controllers/ManageController.cs b/samples/Mvc.Server/Controllers/ManageController.cs index 90a17e77..00938b93 100644 --- a/samples/Mvc.Server/Controllers/ManageController.cs +++ b/samples/Mvc.Server/Controllers/ManageController.cs @@ -1,9 +1,6 @@ -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; using Mvc.Server.Models; using Mvc.Server.Services; using Mvc.Server.ViewModels.Manage; diff --git a/samples/Mvc.Server/Controllers/ResourceController.cs b/samples/Mvc.Server/Controllers/ResourceController.cs index 6238f924..d9acb0be 100644 --- a/samples/Mvc.Server/Controllers/ResourceController.cs +++ b/samples/Mvc.Server/Controllers/ResourceController.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; diff --git a/samples/Mvc.Server/Controllers/UserinfoController.cs b/samples/Mvc.Server/Controllers/UserinfoController.cs index 6c7a4fe6..cd499639 100644 --- a/samples/Mvc.Server/Controllers/UserinfoController.cs +++ b/samples/Mvc.Server/Controllers/UserinfoController.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; diff --git a/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs b/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs index 7d61bd67..1b2fb756 100644 --- a/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs +++ b/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Mvc.Server.Helpers; +namespace Mvc.Server.Helpers; public static class AsyncEnumerableExtensions { diff --git a/samples/Mvc.Server/Helpers/FormValueRequiredAttribute.cs b/samples/Mvc.Server/Helpers/FormValueRequiredAttribute.cs index 30e1a873..c7ef0599 100644 --- a/samples/Mvc.Server/Helpers/FormValueRequiredAttribute.cs +++ b/samples/Mvc.Server/Helpers/FormValueRequiredAttribute.cs @@ -1,7 +1,5 @@ -using System; -using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.ActionConstraints; -using Microsoft.AspNetCore.Routing; namespace Mvc.Server.Helpers; diff --git a/samples/Mvc.Server/Program.cs b/samples/Mvc.Server/Program.cs index 325ba036..8624d7c0 100644 --- a/samples/Mvc.Server/Program.cs +++ b/samples/Mvc.Server/Program.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Mvc.Server; +namespace Mvc.Server; public static class Program { diff --git a/samples/Mvc.Server/Services/IEmailSender.cs b/samples/Mvc.Server/Services/IEmailSender.cs index eee78a11..f589b295 100644 --- a/samples/Mvc.Server/Services/IEmailSender.cs +++ b/samples/Mvc.Server/Services/IEmailSender.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; - -namespace Mvc.Server.Services; +namespace Mvc.Server.Services; public interface IEmailSender { diff --git a/samples/Mvc.Server/Services/ISmsSender.cs b/samples/Mvc.Server/Services/ISmsSender.cs index 02da67e5..e9df4f3b 100644 --- a/samples/Mvc.Server/Services/ISmsSender.cs +++ b/samples/Mvc.Server/Services/ISmsSender.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; - -namespace Mvc.Server.Services; +namespace Mvc.Server.Services; public interface ISmsSender { diff --git a/samples/Mvc.Server/Services/MessageServices.cs b/samples/Mvc.Server/Services/MessageServices.cs index 58cd9623..2ec1c49f 100644 --- a/samples/Mvc.Server/Services/MessageServices.cs +++ b/samples/Mvc.Server/Services/MessageServices.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; - -namespace Mvc.Server.Services; +namespace Mvc.Server.Services; // This class is used by the application to send Email and SMS // when you turn on two-factor authentication in ASP.NET Identity. diff --git a/samples/Mvc.Server/Startup.cs b/samples/Mvc.Server/Startup.cs index 459d3fd7..2e3dad5f 100644 --- a/samples/Mvc.Server/Startup.cs +++ b/samples/Mvc.Server/Startup.cs @@ -1,8 +1,5 @@ -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Mvc.Server.Models; using Mvc.Server.Services; using Quartz; diff --git a/samples/Mvc.Server/ViewModels/Account/SendCodeViewModel.cs b/samples/Mvc.Server/ViewModels/Account/SendCodeViewModel.cs index 7525506c..c1c6a80f 100644 --- a/samples/Mvc.Server/ViewModels/Account/SendCodeViewModel.cs +++ b/samples/Mvc.Server/ViewModels/Account/SendCodeViewModel.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.Rendering; namespace Mvc.Server.ViewModels.Account; diff --git a/samples/Mvc.Server/ViewModels/Manage/ConfigureTwoFactorViewModel.cs b/samples/Mvc.Server/ViewModels/Manage/ConfigureTwoFactorViewModel.cs index c33a6375..85f3dc02 100644 --- a/samples/Mvc.Server/ViewModels/Manage/ConfigureTwoFactorViewModel.cs +++ b/samples/Mvc.Server/ViewModels/Manage/ConfigureTwoFactorViewModel.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.Rendering; namespace Mvc.Server.ViewModels.Manage; diff --git a/samples/Mvc.Server/ViewModels/Manage/IndexViewModel.cs b/samples/Mvc.Server/ViewModels/Manage/IndexViewModel.cs index 0af92151..86091e7f 100644 --- a/samples/Mvc.Server/ViewModels/Manage/IndexViewModel.cs +++ b/samples/Mvc.Server/ViewModels/Manage/IndexViewModel.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity; namespace Mvc.Server.ViewModels.Manage; diff --git a/samples/Mvc.Server/ViewModels/Manage/ManageLoginsViewModel.cs b/samples/Mvc.Server/ViewModels/Manage/ManageLoginsViewModel.cs index f49acc45..bbfcae9c 100644 --- a/samples/Mvc.Server/ViewModels/Manage/ManageLoginsViewModel.cs +++ b/samples/Mvc.Server/ViewModels/Manage/ManageLoginsViewModel.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Identity; namespace Mvc.Server.ViewModels.Manage; diff --git a/samples/Mvc.Server/Worker.cs b/samples/Mvc.Server/Worker.cs index 3b75a7b5..d400382b 100644 --- a/samples/Mvc.Server/Worker.cs +++ b/samples/Mvc.Server/Worker.cs @@ -1,9 +1,4 @@ -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; +using System.Globalization; using Mvc.Server.Models; using OpenIddict.Abstractions; using static OpenIddict.Abstractions.OpenIddictConstants; diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs index 3b0204df..0a2343c7 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs @@ -1175,7 +1175,7 @@ public static partial class OpenIddictServerHandlers return default; } - if (context.Principal is null or { Identity: not ClaimsIdentity }) + if (context.Principal is not { Identity: ClaimsIdentity }) { throw new InvalidOperationException(SR.GetResourceString(SR.ID0022)); } @@ -1193,10 +1193,7 @@ public static partial class OpenIddictServerHandlers _ => true }); - if (principal is null or { Identity: not ClaimsIdentity }) - { - throw new InvalidOperationException(SR.GetResourceString(SR.ID0020)); - } + Debug.Assert(principal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); var claims = new Dictionary(StringComparer.Ordinal);