mayuki / Cocona

Micro-framework for .NET console application. Cocona makes it easy and fast to build console applications on .NET.
MIT License
3.29k stars 86 forks source link

Missing dependency : Program does not run (and freezes) #121

Open maxime-paquatte opened 10 months ago

maxime-paquatte commented 10 months ago

Here's an example of code where a dependency is missing. The program displays no error and freezes.

using Cocona;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

var builder = CoconaApp.CreateBuilder();
builder.Services.AddSingleton<Class1>();
builder.Logging.AddConsole()
    .AddFilter(f => f >= LogLevel.Debug);

var app = builder.Build();
app.AddCommands<MyCommands>();
app.Run();

public class MyCommands
{
    public MyCommands(Class1 c1){}

    public void DoStuff()
    {
        Console.WriteLine("Hello, World!");
    }
}

public class Class1
{
    public Class1(Class2 c2){}
}

public class Class2{}

the output is as follows, nothing else happens:

dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
      Hosting starting
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
      Hosting started
jtsai-osa commented 9 months ago

I also experienced this. Took me a while to realize it was caused by missing dependencies.

gregmeess commented 9 months ago

Experiencing the same issue; any advice on how to capture dependency resolution errors?

BranigansLaw commented 9 months ago

I'm also experiencing this.

BranigansLaw commented 1 month ago

Any update on this?