Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Allow AutoMapper 10 #4611

Merged
merged 1 commit into from
Jul 21, 2020
Merged

Conversation

trejjam
Copy link

@trejjam trejjam commented Jul 3, 2020

What issue does this PR address?
AutoMapper v10 was released but is excluded from EF.Storage

Does this PR introduce a breaking change?
No

Please check if the PR fulfills these requirements

  • The commit follows our guidelines
  • Unit Tests for the changes have been added (for bug fixes / features)

@brockallen
Copy link
Member

Have you tested v10? We have this guard in place because updates far too often are not backwards compat.

@leastprivilege
Copy link
Member

Is there any feature in Automapper 10 that we need?

@brockallen
Copy link
Member

The feature we need in v9 is stability.

@trejjam
Copy link
Author

trejjam commented Jul 3, 2020

@brockallen Project is compilable. There are breaking changes, of course. I was not able to run tests (EF.Storage projects have many broken links to projects in Rider). I put trust in CI pipeline.

@leastprivilege This project not, but it holds our dependency locked as well.

@buvinghausen
Copy link

Brock & Dom,

I was able to download the repository lock the version into AutoMapper 10.0.0 and run the build.ps1 script which invokes your tests.

Here is the output in ASCII format

EntityFramework.Storage: build: Succeeded. (12 s)
EntityFramework.Storage: test: Starting...
EntityFramework.Storage: dotnet test -c Release --no-build
Test run for C:\Users\Administrator\Downloads\IdentityServer4-main\src\EntityFramework.Storage\test\IntegrationTests\bin\Release\netcoreapp3.1\IdentityServer4.EntityFramework.IntegrationTests.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.6.0
Copyright (c) Microsoft Corporation. All rights reserved.

Test run for C:\Users\Administrator\Downloads\IdentityServer4-main\src\EntityFramework.Storage\test\UnitTests\bin\Release\netcoreapp3.1\IdentityServer4.EntityFramework.UnitTests.dll(.NETCoreApp,Version=v3.1)
Starting test execution, please wait...

A total of 1 test files matched the specified pattern.
Microsoft (R) Test Execution Command Line Tool Version 16.6.0
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.

Test Run Successful.
Total tests: 16
Passed: 16
Total time: 3.1119 Seconds

Test Run Successful.
Total tests: 40
Passed: 40
Total time: 5.8024 Seconds
EntityFramework.Storage: test: Succeeded. (7.25 s)

Here is the output from my console for the EF storage project test run

image

Let me know if you need anything else but as an end user who uses both Identity Server and Auto Mapper I try to stay up to date as much as I can and would greatly appreciate this PR getting into the 4.0.3 release :)

Cheers

@Quraian
Copy link
Contributor

Quraian commented Jul 11, 2020

I just wanted to point out that my project depends on IdentityServer4.AspNetIdentity 3.1.4. After upgrading to AutoMapper 10 I got this error:

IdentityServer4.Hosting.IdentityServerMiddleware[0]
      Unhandled exception: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
System.MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
   at IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant model)
   at IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant token)
   at IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key, T item, String clientId, String subjectId, DateTime created, Nullable`1 expiration)
   at IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item, String clientId, String subjectId, DateTime created, Int32 lifetime)
   at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest request)
   at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest request)   at IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, ConsentResponse consent)
   at IdentityServer4.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext context)
   at IdentityServer4.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext context)
   at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)

@serge-wq
Copy link

I got exactly the same exception as @Quraian.

@buvinghausen
Copy link

Method not found is because you have 10 installed but the CLR is looking for < 10. This PR would address this problem.

@brockallen brockallen merged commit e0e8dcf into IdentityServer:main Jul 21, 2020
@brockallen brockallen added this to the 4.0.3 milestone Jul 21, 2020
@marzoukali
Copy link

marzoukali commented Jul 22, 2020

I've tried Autofac v10.0 for this new release and the issue still exists. I ended up downgraded Autofac to v9.0 and it works fine.

Below is a record from my logging system contains the detailed exception:

{"Timestamp":"2020-07-22T05:25:28.5128967+02:00","Level":"Error","MessageTemplate":"API!!! Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'. -- {ErrorId}.","Exception":"System.MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.\r\n at IdentityServer4.EntityFramework.Mappers.ClientMappers.ToModel(Client entity)\r\n at IdentityServer4.EntityFramework.Stores.ClientStore.FindClientByIdAsync(String clientId)\r\n at IdentityServer4.Stores.ValidatingClientStore`1.FindClientByIdAsync(String clientId)\r\n at IdentityServer4.Stores.IClientStoreExtensions.FindEnabledClientByIdAsync(IClientStore store, String clientId)\r\n at IdentityServer4.Validation.ClientSecretValidator.ValidateAsync(HttpContext context)\r\n at IdentityServer4.Endpoints.TokenEndpoint.ProcessTokenRequestAsync(HttpContext context)\r\n at IdentityServer4.Endpoints.TokenEndpoint.ProcessAsync(HttpContext context)\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)\r\n at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)\r\n at Mda.Infrastructure.Middleware.ExceptionMiddleware.ExceptionMiddleware.Invoke(HttpContext context) in C:\Users\10\Desktop\stormra\mda\code\Mda.Auth\src\Infrastructure\Mda.Infrastructure\Middleware\ExceptionMiddleware\ExceptionMiddleware.cs:line 29","Properties":{"ErrorId":"66167054-4a56-4d56-9941-4680d27e2828","SourceContext":"Mda.Infrastructure.Middleware.ExceptionMiddleware.ExceptionMiddleware","RequestId":"0HM1DTRDIGR9K:00000007","RequestPath":"/connect/token","SpanId":"|9bebd43c-46e12d1acc9c01eb.","TraceId":"9bebd43c-46e12d1acc9c01eb","ParentId":"","ConnectionId":"0HM1DTRDIGR9K"}}

@devantler
Copy link

I've tried Autofac v10.0 for this new release and the issue still exists. I ended up downgraded Autofac to v9.0 and it works fine.

Below is a record from my logging system contains the detailed exception:

{"Timestamp":"2020-07-22T05:25:28.5128967+02:00","Level":"Error","MessageTemplate":"API!!! Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'. -- {ErrorId}.","Exception":"System.MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.\r\n at IdentityServer4.EntityFramework.Mappers.ClientMappers.ToModel(Client entity)\r\n at IdentityServer4.EntityFramework.Stores.ClientStore.FindClientByIdAsync(String clientId)\r\n at IdentityServer4.Stores.ValidatingClientStore`1.FindClientByIdAsync(String clientId)\r\n at IdentityServer4.Stores.IClientStoreExtensions.FindEnabledClientByIdAsync(IClientStore store, String clientId)\r\n at IdentityServer4.Validation.ClientSecretValidator.ValidateAsync(HttpContext context)\r\n at IdentityServer4.Endpoints.TokenEndpoint.ProcessTokenRequestAsync(HttpContext context)\r\n at IdentityServer4.Endpoints.TokenEndpoint.ProcessAsync(HttpContext context)\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)\r\n at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)\r\n at Mda.Infrastructure.Middleware.ExceptionMiddleware.ExceptionMiddleware.Invoke(HttpContext context) in C:\Users\10\Desktop\stormra\mda\code\Mda.Auth\src\Infrastructure\Mda.Infrastructure\Middleware\ExceptionMiddleware\ExceptionMiddleware.cs:line 29","Properties":{"ErrorId":"66167054-4a56-4d56-9941-4680d27e2828","SourceContext":"Mda.Infrastructure.Middleware.ExceptionMiddleware.ExceptionMiddleware","RequestId":"0HM1DTRDIGR9K:00000007","RequestPath":"/connect/token","SpanId":"|9bebd43c-46e12d1acc9c01eb.","TraceId":"9bebd43c-46e12d1acc9c01eb","ParentId":"","ConnectionId":"0HM1DTRDIGR9K"}}

I think you meant to say Automapper v10 and not Autofac. Anyhow i can confirm that it does not work with:

 <PackageReference Include="AutoMapper" Version="10.0.0" />
 <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />

@leastprivilege
Copy link
Member

@jbogard

@jbogard
Copy link
Contributor

jbogard commented Jul 22, 2020

https://www.youtube.com/watch?v=qi1LMIUOOAI

@leastprivilege
Copy link
Member

Once you are a foundation board member, you can fix it all :p

@marzoukali
Copy link

I opened an issue here: #4673

@brockallen
Copy link
Member

When I tested I bumped the version to 10 and it worked. Given that we didn't force our build to use 10 (and we left it at 9) I think is the issue. We should have changed the lower bound to 10.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants