Try to restart the build. The next error that you may encounter is: “System.TypeInitializationException: The type initializer for 'IdentityServer4.EntityFramework.Mappers.ClientMappers' threw an exception“
To resolve this error, update the ‘CorsPolicyServiceTests.cs‘ source file with the following patch. This is a temporary patch just to fix and run the test suite. A better fix could be to update ‘IdentityServer4.EntityFramework.Mappers.ClientMappers’ mapper configuration according to AutoMapper 12.0.0 version. The patch uses the IdentityServer4.EntityFramework.Entities.Client class instead of Models.Client.
Error Message:
System.TypeInitializationException : The type initializer for 'IdentityServer4.EntityFramework.Mappers.ClientMappers' threw an exception.
---- System.ArgumentException : Invalid generic arguments
Stack Trace:
at IdentityServer4.EntityFramework.IntegrationTests.Services.CorsPolicyServiceTests.IsOriginAllowedAsync_WhenOriginIsAllowed_ExpectTrue(DbContextOptions`1 options) in /root/alhad/dotnet-support/IdentityServer4/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/Services/CorsPolicyServiceTests.cs:line 39
at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
----- Inner Stack Trace -----
at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
at AutoMapper.TypeDetails.<>c__DisplayClass30_1.<BuildPublicNoArgExtensionMethods>b__10(MethodInfo extensionMethod)
at System.Linq.Enumerable.WhereSelectArrayIterator`2[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Linq.Enumerable.ConcatIterator`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__231`3[[<>f__AnonymousType11`2[[<>f__AnonymousType10`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Type[], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Collections.Generic.IEnumerable`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[<>f__AnonymousType12`2[[<>f__AnonymousType11`2[[<>f__AnonymousType10`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Type[], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Collections.Generic.IEnumerable`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2[[<>f__AnonymousType12`2[[<>f__AnonymousType11`2[[<>f__AnonymousType10`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Type[], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Collections.Generic.IEnumerable`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Collections.Generic.HashSet`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].UnionWith(IEnumerable`1 other)
at System.Linq.Enumerable.UnionIterator`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].FillSet()
at System.Linq.Enumerable.UnionIterator`1[[System.Reflection.MethodInfo, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ToArray()
at System.Linq.Enumerable.ToArray[MethodInfo](IEnumerable`1 source)
at AutoMapper.TypeDetails.BuildPublicNoArgExtensionMethods(IEnumerable`1 sourceExtensionMethodSearch)
at AutoMapper.TypeDetails..ctor(Type type, ProfileMap config)
at AutoMapper.ProfileMap.TypeDetailsFactory(Type type)
at AutoMapper.Internal.LockingConcurrentDictionary`2.<>c__DisplayClass2_1[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoMapper.TypeDetails, AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].<.ctor>b__1()
at System.Lazy`1[[AutoMapper.TypeDetails, AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1[[AutoMapper.TypeDetails, AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1[[AutoMapper.TypeDetails, AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].CreateValue()
at System.Lazy`1[[AutoMapper.TypeDetails, AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].get_Value()
at AutoMapper.Internal.LockingConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoMapper.TypeDetails, AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]].GetOrAdd(Type key)
at AutoMapper.ProfileMap.CreateTypeDetails(Type type)
at AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options, Boolean isReverseMap)
at AutoMapper.ProfileMap.BuildTypeMap(IConfigurationProvider configurationProvider, ITypeMapConfiguration config)
at AutoMapper.ProfileMap.Register(IConfigurationProvider configurationProvider)
at AutoMapper.MapperConfiguration.Seal()
at AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression)
at AutoMapper.MapperConfiguration..ctor(Action`1 configure)
at IdentityServer4.EntityFramework.Mappers.ClientMappers..cctor()
diff --git a/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/Services/CorsPolicyServiceTests.cs b/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/Services/CorsPolicyServiceTests.cs
index 12efc531..e0ad4092 100644
--- a/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/Services/CorsPolicyServiceTests.cs
+++ b/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/Services/CorsPolicyServiceTests.cs
@@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using IdentityServer4.EntityFramework.Interfaces;
using IdentityServer4.EntityFramework.Services;
+using IdentityServer4.EntityFramework.Entities;
namespace IdentityServer4.EntityFramework.IntegrationTests.Services
{
@@ -36,18 +37,18 @@ namespace IdentityServer4.EntityFramework.IntegrationTests.Services
using (var context = new ConfigurationDbContext(options, StoreOptions))
{
- context.Clients.Add(new Client
+ context.Clients.Add(new IdentityServer4.EntityFramework.Entities.Client
{
ClientId = Guid.NewGuid().ToString(),
ClientName = Guid.NewGuid().ToString(),
- AllowedCorsOrigins = new List<string> { "https://www.identityserver.com" }
- }.ToEntity());
- context.Clients.Add(new Client
+ AllowedCorsOrigins = new List<ClientCorsOrigin> { new ClientCorsOrigin() { Origin = "https://www.identityserver.com" } }
+ });
+ context.Clients.Add(new IdentityServer4.EntityFramework.Entities.Client
{
ClientId = "2",
ClientName = "2",
- AllowedCorsOrigins = new List<string> { "https://www.identityserver.com", testCorsOrigin }
- }.ToEntity());
+ AllowedCorsOrigins = new List<ClientCorsOrigin> { new ClientCorsOrigin() { Origin = "https://www.identityserver.com" }, new ClientCorsOrigin() { Origin = testCorsOrigin } }
+ });
context.SaveChanges();
}
@@ -73,12 +74,12 @@ namespace IdentityServer4.EntityFramework.IntegrationTests.Services
{
using (var context = new ConfigurationDbContext(options, StoreOptions))
{
- context.Clients.Add(new Client
+ context.Clients.Add(new IdentityServer4.EntityFramework.Entities.Client
{
ClientId = Guid.NewGuid().ToString(),
ClientName = Guid.NewGuid().ToString(),
- AllowedCorsOrigins = new List<string> { "https://www.identityserver.com" }
- }.ToEntity());
+ AllowedCorsOrigins = new List<ClientCorsOrigin> { new ClientCorsOrigin() { Origin = "https://www.identityserver.com" } }
+ });
context.SaveChanges();
}
@@ -99,4 +100,4 @@ namespace IdentityServer4.EntityFramework.IntegrationTests.Services
Assert.False(result);
}
}
-}
\ No newline at end of file
+}