babelshift / SteamWebAPI2

🎮 C# / .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes.
MIT License
263 stars 43 forks source link

Update nuget packages to fix conflicting version bug #112

Closed Hona closed 3 years ago

Hona commented 3 years ago

Specifically to address a bug with conflicting versions of AutoMapper

Hona commented 3 years ago

If possible can this get pushed to nuget once approved?

babelshift commented 3 years ago

What exactly is this fixing? I know the PR title says something about AutoMapper conflict. The unit tests as part of the CI/CD process are not showing any issues related to that. Can you help me with steps to reproduce?

Also, is there any reason why you chose to use Microsoft.Extensions.DependencyInjection 5.0.1 but Microsoft.Extensions.Options 5.0.0?

Hona commented 3 years ago

The packages are all the latest as far as my IDE can tell.

The bug is when your own project is using the latest version of AutoMapper as well, causing this bug;

System.MissingMethodException: Method not found: '!!1 AutoMapper.IMapper.Map(!!0)'.
   at SteamWebAPI2.Interfaces.SteamUser.GetPlayerSummaryAsync(UInt64 steamId)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at SteamWebAPI2.Interfaces.SteamUser.GetPlayerSummaryAsync(UInt64 steamId)
   at Momentum.Auth.Api.Services.SteamService.BuildUserFromProfile(String steamId) in /src/API/src/Modules/Auth/Momentum.Auth.Api/Services/SteamService.cs:line 127
   at Momentum.Auth.Api.Controllers.SteamController.<SignInAsync>b__4_0() in /src/API/src/Modules/Auth/Momentum.Auth.Api/Controllers/SteamController.cs:line 48
   at Momentum.Users.Application.Commands.GetOrCreateNewUserCommandHandler.Handle(GetOrCreateNewUserCommand request, CancellationToken cancellationToken) in /src/API/src/Modules/Users/Momentum.Users.Application/Commands/GetOrCreateNewUserCommand.cs:line 70
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at Momentum.Auth.Api.Controllers.SteamController.SignInAsync() in /src/API/src/Modules/Auth/Momentum.Auth.Api/Controllers/SteamController.cs:line 45
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

The solution is just to update according to https://stackoverflow.com/questions/63519439/automapper-issue-with-identityserver4-missingmethodexception-method-not-found

Hona commented 3 years ago

https://www.nuget.org/packages/Microsoft.Extensions.Options/

The package is not at 5.0.1

Mats391 commented 3 years ago

Would be great if this got accepted. Just broke production by updating AutoMapper for another component :D

Hona commented 3 years ago

A temporary workaround is to downgrade your own AutoMapper to v9 - or building my fix branch

babelshift commented 3 years ago

@Hona thanks for your contribution. I'll build the NuGet package and push it out today.

babelshift commented 3 years ago

4.3.0 has been pushed to the NuGet feed.