I have a decorator pattern with DI container registration:
public interface IFoo
{
string Print();
}
public class Foo : IFoo
{
public string Print() => "Foo";
}
public class Decorator(IFoo decorated) : IFoo
{
public string Print()
{
return "=" + decorated.Print() + "=";
}
}
IServiceCollection service;
services.AddTransient<IFoo, Foo>()
.Decorate<Foo, Decorator>();
The issue is that in real application after I remove the last usage of the method/class, I cannot recognize that code is in reality unused.
I don't want to count the call in decorator as a reference usage so I can see that the method is unused (only decorated but unused).
Is there any attribute or other solution to achieve that in C#?