-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Description
Here is a small reproduce code.
using ConsoleAppFramework;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
[assembly: ConsoleAppFrameworkGeneratorOptions(DisableNamingConversion = true)]
var builder = Host.CreateApplicationBuilder(args);
var services = builder.Services;
services.AddSingleton<ITest, Test>();
services.AddKeyedSingleton<ITest, KeyedTest>("Key");
var app = builder.ToConsoleAppBuilder();
app.Run(args);
interface ITest {
int Value { get; set; }
}
class Test : ITest {
public int Value { get; set; } = 1;
}
class KeyedTest : ITest {
public int Value { get; set; } = 2;
}
[RegisterCommands(nameof(TestCommand))]
class TestCommand([FromKeyedServices("Key")] ITest test) {
public void Run() {
// This value should be 2 but 1 displayed
Console.WriteLine(test.Value);
}
}
This is a ILSpy screenshot and there is not considered keyed services.
I think the behavior is unintentional, could you fix it?
Thank you for always making things so convenient.
Metadata
Metadata
Assignees
Labels
No labels