-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate _logger
field in generated handler code
#226
Comments
using IntegrationTests;
using JasperFx.CodeGeneration;
using JasperFx.CodeGeneration.Frames;
using Lamar;
using Marten;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Wolverine;
using Wolverine.Configuration;
using Wolverine.Marten;
using Wolverine.Runtime.Handlers;
using Wolverine.Tracking;
using Xunit;
namespace PersistenceTests.Marten.Bugs;
public class middleware_deps : PostgresqlContext
{
[Fact]
public async Task should_find_handler()
{
using var host = await Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
services.AddLogging();
services.AddScoped<IDependencyRequiringLogger, DependencyRequiringLogger>();
services.AddMarten(connectionString: Servers.PostgresConnectionString)
.IntegrateWithWolverine();
})
.UseWolverine(opts =>
{
opts.Policies.Add<RequiringLoggerPolicy>();
})
.StartAsync();
var id = Guid.NewGuid();
await host.InvokeMessageAndWaitAsync(new StoreSomething(Id: id));
}
public interface IDependencyRequiringLogger
{
}
public class DependencyRequiringLogger : IDependencyRequiringLogger
{
public DependencyRequiringLogger(ILogger<DependencyRequiringLogger> logger)
{
}
}
public class RequiringLoggerPolicy : IHandlerPolicy
{
public void Apply(IReadOnlyList<HandlerChain> chains, GenerationRules rules, IContainer container)
{
foreach (var chain in chains)
{
var method = GetType().GetMethod(nameof(SamplePolicy))!;
var methodCall = new MethodCall(GetType(), method);
chain.Middleware.Add(methodCall);
}
}
public static Task SamplePolicy(ILogger logger, IDependencyRequiringLogger dep)
=> Task.CompletedTask;
}
}
public record StoreSomething(Guid Id);
public class StoreSomethingHandler
{
public static void Handle(StoreSomething command)
{
}
} |
That one's an easy fix (I think). I'll get that turned around soon. Thanks for all the feedback @agross ! |
The same happens if you return two instances of (var myDomainType, var eventStream, var eventStream) = await SomeHandler.LoadAsync(...) Another thing you cannot return is a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a case where generated code tries to compile a class with 2 fields named
_logger
. It's related to using a custom policy whereInfrastructure.Authorization.AuthorizationPolicy.EnforcePolicy
has anILogger
parameter and the upgrade of Wolverine:This is the generated code:
The text was updated successfully, but these errors were encountered: