Error DIE003
The DI.Setup(nameof(CompositionRoot))
.Bind<ILoggerFactory>().As(Lifetime.Singleton).To((ctx) =>
{
ctx.Inject(out ILogger logger);
return new LoggerFactory()
.AddSerilog(logger);
}) is not supported.
After a bit of playing around, it seems that the problem is actually the parenthesis (ctx) => { } in the registration, as they interfere with the source generation and removing them allows the source generator to continue correctly.
Admittedly they're completely superfluous, but I honestly didn't even notice they were there in the sea of red squiggles in Visual Studio.
Environment information:
.net 8.0.101
C# LangVersion default (11)
Pure.DI version 2.0.45 (latest as of this report)
Thanks for reporting this bug and for finding a workaround. Fixed in version 2.0.46. In case of problems with version update, please pay attention to the Version update part.
Hi there,
I just spent a good half an hour trying to figure out what I was doing wrong registering a factory method
This code does not compile with the error
After a bit of playing around, it seems that the problem is actually the parenthesis
(
ctx)
=> { } in the registration, as they interfere with the source generation and removing them allows the source generator to continue correctly.Admittedly they're completely superfluous, but I honestly didn't even notice they were there in the sea of red squiggles in Visual Studio.
Environment information: .net 8.0.101 C# LangVersion default (11) Pure.DI version 2.0.45 (latest as of this report)