'Injecting in Net 6 - 'IManager<IStrategy<Options>>' is a type, which is not valid in the given context

With Net 6 and C# 10 I have:

public class Options { }

public interface IStrategy<out T> where T: Options {
  T Options { get; }
}

public abstract class Strategy<T> : IStrategy<T> where T : Options {
  public abstract T Options { get; }
}

public interface IManager<T> where T: IStrategy<Options> {
  T? Strategy { get; set; }
}

public class Manager<T> : IManager<T> where T : IStrategy<Options> {
  public T? Strategy { get; set; }
}

I need to inject IManager in a Net 6 application:

services.AddTransient<IManager<IStrategy<Options>>, Manager<IStrategy<Options>>();

But I get the error:

'IManager<IStrategy<Options>>' is a type, which is not valid in the given context

How to solve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source