diff --git a/src/OpenIddict.Core/OpenIddictBuilder.cs b/src/OpenIddict.Core/OpenIddictBuilder.cs index a1af2bc2..8b0f8dfe 100644 --- a/src/OpenIddict.Core/OpenIddictBuilder.cs +++ b/src/OpenIddict.Core/OpenIddictBuilder.cs @@ -62,7 +62,8 @@ namespace Microsoft.Extensions.DependencyInjection public IServiceCollection Services { get; } /// - /// Adds a custom application manager. + /// Adds a custom application manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -70,7 +71,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddApplicationManager(typeof(TManager)); /// - /// Adds a custom application manager. + /// Adds a custom application manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -84,7 +86,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(OpenIddictApplicationManager<>).MakeGenericType(ApplicationType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom managers must be derived from OpenIddictApplicationManager."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -93,7 +95,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom application store. + /// Adds a custom application store derived from + /// . /// /// The type of the custom store. /// The . @@ -101,7 +104,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddApplicationStore(typeof(TStore)); /// - /// Adds a custom application store. + /// Adds a custom application store derived from + /// . /// /// The type of the custom store. /// The . @@ -115,7 +119,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(IOpenIddictApplicationStore<>).MakeGenericType(ApplicationType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom stores must implement IOpenIddictApplicationStore."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -124,7 +128,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom authorization manager. + /// Adds a custom authorization manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -132,7 +137,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddAuthorizationManager(typeof(TManager)); /// - /// Adds a custom authorization manager. + /// Adds a custom authorization manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -146,7 +152,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(OpenIddictAuthorizationManager<>).MakeGenericType(AuthorizationType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom managers must be derived from OpenIddictAuthorizationManager."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -155,7 +161,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom authorization store. + /// Adds a custom authorization store derived from + /// . /// /// The type of the custom store. /// The . @@ -163,7 +170,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddAuthorizationStore(typeof(TStore)); /// - /// Adds a custom authorization store. + /// Adds a custom authorization store derived from + /// . /// /// The type of the custom store. /// The . @@ -177,7 +185,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(IOpenIddictAuthorizationStore<>).MakeGenericType(AuthorizationType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom stores must implement IOpenIddictAuthorizationStore."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -186,7 +194,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom scope manager. + /// Adds a custom scope manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -194,7 +203,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddScopeManager(typeof(TManager)); /// - /// Adds a custom scope manager. + /// Adds a custom scope manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -208,7 +218,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(OpenIddictScopeManager<>).MakeGenericType(ScopeType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom managers must be derived from OpenIddictScopeManager."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -217,7 +227,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom scope store. + /// Adds a custom scope store derived from + /// . /// /// The type of the custom store. /// The . @@ -225,7 +236,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddScopeStore(typeof(TStore)); /// - /// Adds a custom scope store. + /// Adds a custom scope store derived from + /// . /// /// The type of the custom store. /// The . @@ -239,7 +251,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(IOpenIddictScopeStore<>).MakeGenericType(ScopeType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom stores must implement IOpenIddictScopeStore."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -248,7 +260,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom token manager. + /// Adds a custom token manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -256,7 +269,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddTokenManager(typeof(TManager)); /// - /// Adds a custom token manager. + /// Adds a custom token manager derived from + /// . /// /// The type of the custom manager. /// The . @@ -270,7 +284,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(OpenIddictTokenManager<>).MakeGenericType(TokenType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom managers must be derived from OpenIddictTokenManager."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); @@ -279,7 +293,8 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds a custom token store. + /// Adds a custom token store derived from + /// . /// /// The type of the custom store. /// The . @@ -287,7 +302,8 @@ namespace Microsoft.Extensions.DependencyInjection => AddTokenStore(typeof(TStore)); /// - /// Adds a custom token store. + /// Adds a custom token store derived from + /// . /// /// The type of the custom store. /// The . @@ -301,7 +317,7 @@ namespace Microsoft.Extensions.DependencyInjection var contract = typeof(IOpenIddictTokenStore<>).MakeGenericType(TokenType); if (!contract.IsAssignableFrom(type)) { - throw new InvalidOperationException("Custom stores must implement IOpenIddictTokenStore."); + throw new InvalidOperationException("The specified type is invalid."); } Services.AddScoped(contract, type); diff --git a/test/OpenIddict.Core.Tests/OpenIddictBuilderTests.cs b/test/OpenIddict.Core.Tests/OpenIddictBuilderTests.cs index 6ef5830b..c547ad8e 100644 --- a/test/OpenIddict.Core.Tests/OpenIddictBuilderTests.cs +++ b/test/OpenIddict.Core.Tests/OpenIddictBuilderTests.cs @@ -27,7 +27,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddApplicationManager(typeof(object))); - Assert.Equal("Custom managers must be derived from OpenIddictApplicationManager.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -67,7 +67,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddApplicationStore(typeof(object))); - Assert.Equal("Custom stores must implement IOpenIddictApplicationStore.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -105,7 +105,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddAuthorizationManager(typeof(object))); - Assert.Equal("Custom managers must be derived from OpenIddictAuthorizationManager.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -145,7 +145,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddAuthorizationStore(typeof(object))); - Assert.Equal("Custom stores must implement IOpenIddictAuthorizationStore.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -183,7 +183,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddScopeManager(typeof(object))); - Assert.Equal("Custom managers must be derived from OpenIddictScopeManager.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -223,7 +223,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddScopeStore(typeof(object))); - Assert.Equal("Custom stores must implement IOpenIddictScopeStore.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -261,7 +261,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddTokenManager(typeof(object))); - Assert.Equal("Custom managers must be derived from OpenIddictTokenManager.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact] @@ -301,7 +301,7 @@ namespace OpenIddict.Core.Tests // Act and assert var exception = Assert.Throws(() => builder.AddTokenStore(typeof(object))); - Assert.Equal("Custom stores must implement IOpenIddictTokenStore.", exception.Message); + Assert.Equal("The specified type is invalid.", exception.Message); } [Fact]