From 36b2de9681243315c6c8d0fdc46bfa1da4fa90aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 5 Sep 2023 16:36:48 +0200 Subject: [PATCH] Remove the obsolete members --- ...OpenIddictClientWebIntegrationGenerator.cs | 220 --------- ...OpenIddictClientAspNetCoreConfiguration.cs | 4 - .../OpenIddictClientOwinConfiguration.cs | 4 - .../OpenIddictClientSystemNetHttpHandlers.cs | 46 +- .../OpenIddictClientSystemNetHttpOptions.cs | 14 - ...IddictClientWebIntegrationConfiguration.cs | 28 -- ...penIddictClientWebIntegrationProviders.xml | 10 - .../OpenIddictClientEvents.Exchange.cs | 6 - .../OpenIddictClientRegistration.cs | 10 - .../OpenIddictClientService.cs | 422 ------------------ ...enIddictValidationSystemNetHttpHandlers.cs | 46 +- 11 files changed, 2 insertions(+), 808 deletions(-) diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs index 69abb53b..8264ef9d 100644 --- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs +++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs @@ -39,10 +39,6 @@ namespace OpenIddict.Client.WebIntegration.Generators "OpenIddictClientWebIntegrationHelpers.generated.cs", SourceText.From(GenerateHelpers(document), Encoding.UTF8)); - context.AddSource( - "OpenIddictClientWebIntegrationOptions.generated.cs", - SourceText.From(GenerateOptions(document), Encoding.UTF8)); - context.AddSource( "OpenIddictClientWebIntegrationSettings.generated.cs", SourceText.From(GenerateSettings(document), Encoding.UTF8)); @@ -101,43 +97,6 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder return this; } - - /// - /// Enables the {{ provider.display_name }} integration and registers the associated services in the DI container. - {{~ if provider.documentation ~}} - /// For more information, read the documentation. - {{~ end ~}} - /// - /// This extension can be safely called multiple times. - /// The instance. - [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete($""This method was replaced by {nameof(Add{{ provider.name }})} and will be removed in a future version."")] - public OpenIddictClientWebIntegrationBuilder.{{ provider.name }} Use{{ provider.name }}() - { - var registration = new OpenIddictClientRegistration - { - ProviderSettings = new OpenIddictClientWebIntegrationSettings.{{ provider.name }}(), - ProviderType = ProviderTypes.{{ provider.name }} - }; - - Services.Configure(options => options.Registrations.Add(registration)); - - return new OpenIddictClientWebIntegrationBuilder.{{ provider.name }}(registration); - } - - /// - /// Enables the {{ provider.display_name }} integration and registers the associated services in the DI container. - {{~ if provider.documentation ~}} - /// For more information, read the documentation. - {{~ end ~}} - /// - /// This extension can be safely called multiple times. - /// The delegate used to configure the OpenIddict/{{ provider.display_name }} options. - /// The instance. - [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete($""This method was replaced by {nameof(Add{{ provider.name }})} and will be removed in a future version."")] - public OpenIddictClientWebIntegrationBuilder Use{{ provider.name }}(Action configuration) - => Add{{ provider.name }}(configuration); {{~ end ~}} {{~ for provider in providers ~}} @@ -146,14 +105,6 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder /// public sealed partial class {{ provider.name }} { - /// - /// Initializes a new instance of . - /// - /// The services collection. - [Obsolete(""This constructor is no longer supported and will be removed in a future version."", error: true)] - public {{ provider.name }}(IServiceCollection services) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - /// /// Initializes a new instance of . /// @@ -167,22 +118,6 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder [EditorBrowsable(EditorBrowsableState.Never)] public OpenIddictClientRegistration Registration { get; } - /// - /// Gets the services collection. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public IServiceCollection Services => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - - /// - /// Amends the default OpenIddict client {{ provider.display_name }} configuration. - /// - /// The delegate used to configure the OpenIddict options. - /// This extension can be safely called multiple times. - /// The instance. - [Obsolete(""This method is no longer supported and will be removed in a future version."", error: true)] - public {{ provider.name }} Configure(Action configuration) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - /// /// Sets the provider name. /// @@ -868,34 +803,6 @@ namespace OpenIddict.Client.WebIntegration; public sealed partial class OpenIddictClientWebIntegrationConfiguration { - {{~ for provider in providers ~}} - /// - /// Contains the methods required to register the {{ provider.display_name }} integration in the OpenIddict client options. - /// - [Obsolete(""This class is no longer supported and will be removed in a future version."", error: true)] - public sealed class {{ provider.name }} : IConfigureOptions, - IPostConfigureOptions - { - /// - /// Creates a new instance of the class. - /// - /// The service provider. - [Obsolete(""This constructor is no longer supported and will be removed in a future version."", error: true)] - public {{ provider.name }}(IServiceProvider provider) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - - /// - [Obsolete(""This method is no longer supported and will be removed in a future version."", error: true)] - public void PostConfigure(string? name, OpenIddictClientWebIntegrationOptions.{{ provider.name }} options) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - - /// - [Obsolete(""This method is no longer supported and will be removed in a future version."", error: true)] - public void Configure(OpenIddictClientOptions options) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - } - {{~ end ~}} - static partial void ConfigureProvider(OpenIddictClientRegistration registration) { {{~ for provider in providers ~}} @@ -1237,16 +1144,6 @@ namespace OpenIddict.Client.WebIntegration; public static partial class OpenIddictClientWebIntegrationHelpers { {{~ for provider in providers ~}} - /// - /// Resolves the {{ provider.display_name }} provider options from the specified registration. - /// - /// The client registration. - /// The {{ provider.display_name }} provider options. - /// The provider options cannot be resolved. - [Obsolete($""This extension was replaced by {nameof(Get{{ provider.name }}Settings)} and will be removed in a future version."", error: true)] - public static OpenIddictClientWebIntegrationOptions.{{ provider.name }} Get{{ provider.name }}Options(this OpenIddictClientRegistration registration) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - /// /// Resolves the {{ provider.display_name }} provider settings from the specified registration. /// @@ -1272,123 +1169,6 @@ public static partial class OpenIddictClientWebIntegrationHelpers }); } - static string GenerateOptions(XDocument document) - { - var template = Template.Parse(@"#nullable enable - -using System.Security.Cryptography.X509Certificates; -using Microsoft.IdentityModel.Tokens; - -namespace OpenIddict.Client.WebIntegration; - -public sealed partial class OpenIddictClientWebIntegrationOptions -{ - {{~ for provider in providers ~}} - /// - /// Provides various options needed to configure the {{ provider.display_name }} integration. - /// - [Obsolete(""This class is no longer supported and will be removed in a future version."")] - public sealed class {{ provider.name }} - { - /// - /// Gets or sets the client identifier. - /// - public string? ClientId { get; set; } - - /// - /// Gets or sets the client secret, if applicable. - /// - public string? ClientSecret { get; set; } - - /// - /// Gets or sets the post-logout redirect URI. - /// - /// - /// Note: this value is automatically added to - /// . - /// - public Uri? PostLogoutRedirectUri { get; set; } - - /// - /// Gets or sets the redirect URI. - /// - /// - /// Note: this value is automatically added to - /// . - /// - public Uri? RedirectUri { get; set; } - - /// - /// Gets the scopes requested to the authorization server. - /// - public HashSet Scopes { get; } = new(StringComparer.Ordinal); - - /// - /// Gets or sets the environment that determines the endpoints to use (by default, ""Production""). - /// - public string? Environment { get; set; } = OpenIddictClientWebIntegrationConstants.{{ provider.name }}.Environments.Production; - - {{~ for setting in provider.settings ~}} - /// - /// Gets or sets {{ setting.description }}. - /// - {{~ if setting.obsolete ~}} - [Obsolete(""This option is no longer supported and will be removed in a future version."")] - {{~ end ~}} - {{~ if setting.collection ~}} - public HashSet<{{ setting.clr_type }}> {{ setting.property_name }} { get; } = new(); - {{~ else ~}} - public {{ setting.clr_type }}? {{ setting.property_name }} { get; set; } - {{~ end ~}} - - {{~ end ~}} - } - {{~ end ~}} -} -"); - return template.Render(new - { - Providers = document.Root.Elements("Provider") - .Select(provider => new - { - Name = (string) provider.Attribute("Name"), - DisplayName = (string?) provider.Attribute("DisplayName") ?? (string) provider.Attribute("Name"), - - Settings = provider.Elements("Setting").Select(setting => new - { - PropertyName = (string) setting.Attribute("PropertyName"), - - Collection = (bool?) setting.Attribute("Collection") ?? false, - Obsolete = (bool?) setting.Attribute("Obsolete") ?? false, - - Description = (string) setting.Attribute("Description") is string description ? - char.ToLower(description[0], CultureInfo.GetCultureInfo("en-US")) + description[1..] : null, - ClrType = (string) setting.Attribute("Type") switch - { - "EncryptionKey" when (string) setting.Element("EncryptionAlgorithm").Attribute("Value") - is "RS256" or "RS384" or "RS512" => "RsaSecurityKey", - - "SigningKey" when (string) setting.Element("SigningAlgorithm").Attribute("Value") - is "ES256" or "ES384" or "ES512" => "ECDsaSecurityKey", - - "SigningKey" when (string) setting.Element("SigningAlgorithm").Attribute("Value") - is "PS256" or "PS384" or "PS512" or - "RS256" or "RS384" or "RS512" => "RsaSecurityKey", - - "Certificate" => "X509Certificate2", - "String" => "string", - "StringHashSet" => "HashSet", - "Uri" => "Uri", - - string value => value - } - }) - .ToList() - }) - .ToList() - }); - } - static string GenerateSettings(XDocument document) { var template = Template.Parse(@"#nullable enable diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs index ea58dbee..5ea75824 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs @@ -21,10 +21,6 @@ public sealed class OpenIddictClientAspNetCoreConfiguration : IConfigureOptions< { private readonly IServiceProvider _provider; - /// - [Obsolete("This constructor is no longer supported and will be removed in a future version.", error: true)] - public OpenIddictClientAspNetCoreConfiguration() => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - /// /// Creates a new instance of the class. /// diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs index 2c40f8fa..f052c8b8 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs @@ -19,10 +19,6 @@ public sealed class OpenIddictClientOwinConfiguration : IConfigureOptions - [Obsolete("This constructor is no longer supported and will be removed in a future version.", error: true)] - public OpenIddictClientOwinConfiguration() => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - /// /// Creates a new instance of the class. /// diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs index 281e15d7..a85e9ac5 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs @@ -327,9 +327,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers = OpenIddictClientHandlerDescriptor.CreateBuilder() .AddFilter() .UseSingletonHandler>() -#pragma warning disable CS0618 - .SetOrder(AttachQueryStringParameters.Descriptor.Order - 1_000) -#pragma warning restore CS0618 + .SetOrder(int.MaxValue - 100_000) .SetType(OpenIddictClientHandlerType.BuiltIn) .Build(); @@ -377,48 +375,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers } } - /// - /// Contains the logic responsible for attaching the query string parameters to the HTTP request. - /// - [Obsolete("This class is obsolete and will be removed in a future version.")] - public sealed class AttachQueryStringParameters : IOpenIddictClientHandler where TContext : BaseExternalContext - { - /// - /// Gets the default descriptor definition assigned to this handler. - /// - public static OpenIddictClientHandlerDescriptor Descriptor { get; } - = OpenIddictClientHandlerDescriptor.CreateBuilder() - .AddFilter() - .UseSingletonHandler>() - .SetOrder(AttachFormParameters.Descriptor.Order - 1_000) - .SetType(OpenIddictClientHandlerType.BuiltIn) - .Build(); - - /// - public ValueTask HandleAsync(TContext context) => default; - } - - /// - /// Contains the logic responsible for attaching the form parameters to the HTTP request. - /// - [Obsolete("This class is obsolete and will be removed in a future version.")] - public sealed class AttachFormParameters : IOpenIddictClientHandler where TContext : BaseExternalContext - { - /// - /// Gets the default descriptor definition assigned to this handler. - /// - public static OpenIddictClientHandlerDescriptor Descriptor { get; } - = OpenIddictClientHandlerDescriptor.CreateBuilder() - .AddFilter() - .UseSingletonHandler>() - .SetOrder(int.MaxValue - 100_000) - .SetType(OpenIddictClientHandlerType.BuiltIn) - .Build(); - - /// - public ValueTask HandleAsync(TContext context) => default; - } - /// /// Contains the logic responsible for sending the HTTP request to the remote server. /// diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs index b1a229af..9651722c 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs @@ -49,18 +49,4 @@ public sealed class OpenIddictClientSystemNetHttpOptions /// instances created by the OpenIddict client/System.Net.Http integration. /// public List> UnfilteredHttpClientHandlerActions { get; } = new(); - - /// - /// Gets the user-defined actions used to amend the - /// instances created by the OpenIddict client/System.Net.Http integration. - /// - [Obsolete($"This property was replaced by {nameof(UnfilteredHttpClientActions)} and will be removed in a future version.")] - public Dictionary>> HttpClientActions { get; } = new(); - - /// - /// Gets the user-defined actions used to amend the - /// instances created by the OpenIddict client/System.Net.Http integration. - /// - [Obsolete($"This property was replaced by {nameof(UnfilteredHttpClientActions)} and will be removed in a future version.")] - public Dictionary>> HttpClientHandlerActions { get; } = new(); } diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationConfiguration.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationConfiguration.cs index 98073b11..1b54f0d5 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationConfiguration.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationConfiguration.cs @@ -6,7 +6,6 @@ using System.ComponentModel; using System.Net.Http; -using Microsoft.Extensions.Http; using Microsoft.Extensions.Options; using OpenIddict.Client.SystemNetHttp; using static OpenIddict.Client.WebIntegration.OpenIddictClientWebIntegrationConstants; @@ -19,25 +18,8 @@ namespace OpenIddict.Client.WebIntegration; [EditorBrowsable(EditorBrowsableState.Advanced)] public sealed partial class OpenIddictClientWebIntegrationConfiguration : IConfigureOptions, IConfigureOptions, - IConfigureNamedOptions, IPostConfigureOptions { - /// - /// Creates a new instance of the class. - /// - public OpenIddictClientWebIntegrationConfiguration() - { - } - - /// - /// Creates a new instance of the class. - /// - /// The service provider. - [Obsolete("This constructor is no longer supported and will be removed in a future version.")] - public OpenIddictClientWebIntegrationConfiguration(IServiceProvider provider) - { - } - /// public void Configure(OpenIddictClientOptions options) { @@ -80,16 +62,6 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration : IConfi }); } - /// - [Obsolete("This method is no longer supported and will be removed in a future version.", error: true)] - public void Configure(HttpClientFactoryOptions options) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - - /// - [Obsolete("This method is no longer supported and will be removed in a future version.", error: true)] - public void Configure(string? name, HttpClientFactoryOptions options) - => throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); - /// public void PostConfigure(string? name, OpenIddictClientOptions options) { diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index 977ee1f1..1e452560 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -589,16 +589,6 @@ - - - - - - - - -