I have an endpoint implemented as follows:
public sealed record RequestPasswordResetRequest(string EmailAddress);
public static class RequestPasswordResetEndpoint
{
[WolverinePut($"{Routes.Users}/request-password-reset")]
public static async Task RequestPasswordReset(
RequestPasswordResetRequest request,
IMessageBus bus,
IUserService userService)
{
var userId = await userService.GetUserIdByEmailAddress(request.EmailAddress);
if (!userId.HasValue)
return;
var cmd = new RequestPasswordReset(userId.Value, request.EmailAddress);
await bus.InvokeAsync(cmd);
}
}
public sealed record RequestPasswordReset(Guid UserId, string EmailAddress);
public static class RequestPasswordResetAggregateHandler
{
public static IEnumerable<object> Handle(RequestPasswordReset _, User user)
{
user.RequestPasswordReset();
return user.Changes;
}
}
IUserService is registered as a scoped service. The concrete implementation takes a dependency on Marten's IQuerySession and nothing else.
When I hit the endpoint at runtime, the following error message is returned:
System.InvalidOperationException: Compilation failures!
CS1503: Argument 1: cannot convert from 'Wolverine.IMessageContext' to 'Wolverine.Runtime.MessageContext'
Code:
// <auto-generated/>
#pragma warning disable
using Microsoft.AspNetCore.Routing;
using System;
using System.Linq;
using Wolverine.Http;
using Wolverine.Marten.Publishing;
using Wolverine.Runtime;
namespace Internal.Generated.WolverineHandlers
{
// START: PUTapi_users_request_password_reset
public class PUTapi_users_request_password_reset : Wolverine.Http.HttpHandler
{
private readonly Wolverine.Http.WolverineHttpOptions _options;
private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime;
private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory;
public PUTapi_users_request_password_reset(Wolverine.Http.WolverineHttpOptions options, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(options)
{
_options = options;
_wolverineRuntime = wolverineRuntime;
_outboxedSessionFactory = outboxedSessionFactory;
}
public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext)
{
var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime);
await using var querySession = _outboxedSessionFactory.QuerySession(((Wolverine.IMessageContext)messageContext));
var userService = new Namespace.Here.Users.Services.UserService(querySession);
try
{
Wolverine.Http.Runtime.RequestIdMiddleware.Apply(httpContext, ((Wolverine.IMessageContext)messageContext));
var (request, jsonContinue) = await ReadJsonAsync<Namespace.Here.Users.Features.RequestPasswordResetRequest>(httpContext);
if (jsonContinue == Wolverine.HandlerContinuation.Stop) return;
await Namespace.Here.Users.Features.RequestPasswordResetEndpoint.RequestPasswordReset(request, ((Wolverine.IMessageBus)messageContext), userService).ConfigureAwait(false);
// Wolverine automatically sets the status code to 204 for empty responses
httpContext.Response.StatusCode = 204;
}
catch(System.Exception ex) when (Namespace.Here.HttpExceptionPolicy.CanHandleException(ex))
{
await Namespace.Here.HttpExceptionPolicy.HandleException(ex, httpContext);
return;
}
}
}
// END: PUTapi_users_request_password_reset
}
at JasperFx.RuntimeCompiler.AssemblyGenerator.Generate(String code)
at JasperFx.RuntimeCompiler.AssemblyGenerator.Compile(GeneratedAssembly generatedAssembly, IServiceVariableSource services)
at JasperFx.RuntimeCompiler.CodeFileExtensions.InitializeSynchronously(ICodeFile file, GenerationRules rules, ICodeFileCollection parent, IServiceProvider services)
at Wolverine.Http.HttpChain.<>c__DisplayClass66_0.<BuildEndpoint>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Wolverine.Http.HttpChain.<>c__DisplayClass66_0.<BuildEndpoint>b__1(HttpContext c)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
--- End of stack trace from previous location ---
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
I have an endpoint implemented as follows:
IUserServiceis registered as a scoped service. The concrete implementation takes a dependency on Marten'sIQuerySessionand nothing else.When I hit the endpoint at runtime, the following error message is returned: