Source Code Generation Output

March 2, 2025 ยท View on GitHub



Register Services

using CircleDIAttributes;

[ServiceProvider]
[Transient<Service1, Service1>]
[Scoped<IService2, Service2>]
[Singleton<IService3, Service3>]
public sealed partial class MyProvider;

public interface IService1;
public class Service1(IService2 service2, IService3 service3) : IService1;
public interface IService2;
public class Service2(IService3 service3) : IService2;
public interface IService3;
public class Service3 : IService3;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 5<br />
/// - Singleton: 2<br />
/// - Scoped: 2<br />
/// - Transient: 1<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public sealed partial class MyProvider : global::IMyProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public MyProvider() {
        _service3 = new global::Service3();
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IMyProvider.IScope CreateScope() {
        return new global::MyProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IService3"/><br />
    /// Implementation type: <see cref="global::Service3"/>
    /// </summary>
    public global::IService3 Service3 => _service3;
    private readonly global::Service3 _service3;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyProvider"/><br />
    /// Implementation type: <see cref="global::MyProvider"/>
    /// </summary>
    public global::IMyProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IService3":
                if (serviceType == typeof(global::IService3))
                    return Service3;
                return null;
            case "IMyProvider":
                if (serviceType == typeof(global::IMyProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 5<br />
    /// - Singleton: 2<br />
    /// - Scoped: 2<br />
    /// - Transient: 1<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IMyProvider.IScope, IServiceProvider {
        private readonly global::MyProvider _myProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="myProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="MyProvider"/>.</param>
        public Scope(global::IMyProvider myProvider) {
            _myProvider = (global::MyProvider)myProvider;

            _service2 = new global::Service2(_myProvider._service3);
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IService2"/><br />
        /// Implementation type: <see cref="global::Service2"/>
        /// </summary>
        public global::IService2 Service2 => _service2;
        private readonly global::Service2 _service2;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IMyProvider.IScope"/><br />
        /// Implementation type: <see cref="global::MyProvider.Scope"/>
        /// </summary>
        public global::IMyProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IService3"/><br />
        /// Implementation type: <see cref="global::Service3"/>
        /// </summary>
        public global::IService3 Service3 => _myProvider.Service3;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyProvider"/><br />
        /// Implementation type: <see cref="global::MyProvider"/>
        /// </summary>
        public global::IMyProvider Self => _myProvider.Self;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
        /// Service type: <see cref="global::Service1"/><br />
        /// Implementation type: <see cref="global::Service1"/>
        /// </summary>
        public global::Service1 Service1 {
            get {
                global::Service1 service1_0 = new global::Service1(_service2, _myProvider._service3);
                return service1_0;
            }
        }


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IMyProvider.IScope))
                        return SelfScope;
                    return null;
                case "Service1":
                    if (serviceType == typeof(global::Service1))
                        return Service1;
                    return null;
                case "IService2":
                    if (serviceType == typeof(global::IService2))
                        return Service2;
                    return null;
                case "IService3":
                    if (serviceType == typeof(global::IService3))
                        return Service3;
                    return null;
                case "IMyProvider":
                    if (serviceType == typeof(global::IMyProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Register Circle Dependency (set-accessor)

using CircleDIAttributes;

[ServiceProvider]
[Singleton<IMyService1, MyService1>]
[Singleton<IMyService2, MyService2>]
public partial class CircleExampleProvider;


public interface IMyService1;
public class MyService1(IMyService2 myService2) : IMyService1;

public interface IMyService2;
public class MyService2 : IMyService2 {
    public required IMyService1 MyService1 { private get; set; }
}
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 4<br />
/// - Singleton: 3<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class CircleExampleProvider : global::ICircleExampleProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public CircleExampleProvider() {
        _myService2 = new global::MyService2() {
            MyService1 = default!
        };
        _myService1 = new global::MyService1(_myService2);

        _myService2.MyService1 = _myService1;
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::ICircleExampleProvider.IScope CreateScope() {
        return new global::CircleExampleProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService1"/><br />
    /// Implementation type: <see cref="global::MyService1"/>
    /// </summary>
    public global::IMyService1 MyService1 => _myService1;
    private readonly global::MyService1 _myService1;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService2"/><br />
    /// Implementation type: <see cref="global::MyService2"/>
    /// </summary>
    public global::IMyService2 MyService2 => _myService2;
    private readonly global::MyService2 _myService2;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::ICircleExampleProvider"/><br />
    /// Implementation type: <see cref="global::CircleExampleProvider"/>
    /// </summary>
    public global::ICircleExampleProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService1":
                if (serviceType == typeof(global::IMyService1))
                    return MyService1;
                return null;
            case "IMyService2":
                if (serviceType == typeof(global::IMyService2))
                    return MyService2;
                return null;
            case "ICircleExampleProvider":
                if (serviceType == typeof(global::ICircleExampleProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 4<br />
    /// - Singleton: 3<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::ICircleExampleProvider.IScope, IServiceProvider {
        private readonly global::CircleExampleProvider _circleExampleProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="circleExampleProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="CircleExampleProvider"/>.</param>
        public Scope(global::ICircleExampleProvider circleExampleProvider) {
            _circleExampleProvider = (global::CircleExampleProvider)circleExampleProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::ICircleExampleProvider.IScope"/><br />
        /// Implementation type: <see cref="global::CircleExampleProvider.Scope"/>
        /// </summary>
        public global::ICircleExampleProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService1"/><br />
        /// Implementation type: <see cref="global::MyService1"/>
        /// </summary>
        public global::IMyService1 MyService1 => _circleExampleProvider.MyService1;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService2"/><br />
        /// Implementation type: <see cref="global::MyService2"/>
        /// </summary>
        public global::IMyService2 MyService2 => _circleExampleProvider.MyService2;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::ICircleExampleProvider"/><br />
        /// Implementation type: <see cref="global::CircleExampleProvider"/>
        /// </summary>
        public global::ICircleExampleProvider Self => _circleExampleProvider.Self;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::ICircleExampleProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService1":
                    if (serviceType == typeof(global::IMyService1))
                        return MyService1;
                    return null;
                case "IMyService2":
                    if (serviceType == typeof(global::IMyService2))
                        return MyService2;
                    return null;
                case "ICircleExampleProvider":
                    if (serviceType == typeof(global::ICircleExampleProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Register Circle Dependency (init-accessor)

using CircleDIAttributes;

[ServiceProvider]
[Singleton<IMyService1, MyService1>]
[Singleton<IMyService2, MyService2>]
public partial class CircleExampleProvider;


public interface IMyService1;
public class MyService1(IMyService2 myService2) : IMyService1;

public interface IMyService2;
public class MyService2 : IMyService2 {
    public required IMyService1 MyService1 { private get; init; }
}
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 4<br />
/// - Singleton: 3<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class CircleExampleProvider : global::ICircleExampleProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public CircleExampleProvider() {
        _myService2 = new global::MyService2() {
            MyService1 = default!
        };
        _myService1 = new global::MyService1(_myService2);

        Set_MyService2_MyService1(_myService2, _myService1);
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::ICircleExampleProvider.IScope CreateScope() {
        return new global::CircleExampleProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService1"/><br />
    /// Implementation type: <see cref="global::MyService1"/>
    /// </summary>
    public global::IMyService1 MyService1 => _myService1;
    private readonly global::MyService1 _myService1;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService2"/><br />
    /// Implementation type: <see cref="global::MyService2"/>
    /// </summary>
    public global::IMyService2 MyService2 => _myService2;
    private readonly global::MyService2 _myService2;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::ICircleExampleProvider"/><br />
    /// Implementation type: <see cref="global::CircleExampleProvider"/>
    /// </summary>
    public global::ICircleExampleProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService1":
                if (serviceType == typeof(global::IMyService1))
                    return MyService1;
                return null;
            case "IMyService2":
                if (serviceType == typeof(global::IMyService2))
                    return MyService2;
                return null;
            case "ICircleExampleProvider":
                if (serviceType == typeof(global::ICircleExampleProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 4<br />
    /// - Singleton: 3<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::ICircleExampleProvider.IScope, IServiceProvider {
        private readonly global::CircleExampleProvider _circleExampleProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="circleExampleProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="CircleExampleProvider"/>.</param>
        public Scope(global::ICircleExampleProvider circleExampleProvider) {
            _circleExampleProvider = (global::CircleExampleProvider)circleExampleProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::ICircleExampleProvider.IScope"/><br />
        /// Implementation type: <see cref="global::CircleExampleProvider.Scope"/>
        /// </summary>
        public global::ICircleExampleProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService1"/><br />
        /// Implementation type: <see cref="global::MyService1"/>
        /// </summary>
        public global::IMyService1 MyService1 => _circleExampleProvider.MyService1;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService2"/><br />
        /// Implementation type: <see cref="global::MyService2"/>
        /// </summary>
        public global::IMyService2 MyService2 => _circleExampleProvider.MyService2;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::ICircleExampleProvider"/><br />
        /// Implementation type: <see cref="global::CircleExampleProvider"/>
        /// </summary>
        public global::ICircleExampleProvider Self => _circleExampleProvider.Self;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::ICircleExampleProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService1":
                    if (serviceType == typeof(global::IMyService1))
                        return MyService1;
                    return null;
                case "IMyService2":
                    if (serviceType == typeof(global::IMyService2))
                        return MyService2;
                    return null;
                case "ICircleExampleProvider":
                    if (serviceType == typeof(global::ICircleExampleProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }



    [System.Runtime.CompilerServices.UnsafeAccessor(System.Runtime.CompilerServices.UnsafeAccessorKind.Method, Name = "set_MyService1")]
    private extern static void Set_MyService2_MyService1(global::MyService2 instance, global::IMyService1 value);
}



Register Delegate Service

using CircleDIAttributes;

[ServiceProvider]
[Delegate<IntToString>(nameof(ConvertToString))]
public partial class DelegateProvider {
    private static string ConvertToString(int number) => number.ToString();
}


public delegate string IntToString(int number);
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 3<br />
/// - Singleton: 1<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 1
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class DelegateProvider : global::IDelegateProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public DelegateProvider() {
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IDelegateProvider.IScope CreateScope() {
        return new global::DelegateProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IDelegateProvider"/><br />
    /// Implementation type: <see cref="global::DelegateProvider"/>
    /// </summary>
    public global::IDelegateProvider Self => this;


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.DelegateAttribute{TService}">Delegate</see><br />
    /// Service type: <see cref="global::IntToString"/><br />
    /// Implementation type: <see cref="global::IntToString"/>
    /// </summary>
    public global::IntToString IntToString => ConvertToString;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IntToString":
                if (serviceType == typeof(global::IntToString))
                    return IntToString;
                return null;
            case "IDelegateProvider":
                if (serviceType == typeof(global::IDelegateProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 3<br />
    /// - Singleton: 1<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 1
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IDelegateProvider.IScope, IServiceProvider {
        private readonly global::DelegateProvider _delegateProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="delegateProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="DelegateProvider"/>.</param>
        public Scope(global::IDelegateProvider delegateProvider) {
            _delegateProvider = (global::DelegateProvider)delegateProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IDelegateProvider.IScope"/><br />
        /// Implementation type: <see cref="global::DelegateProvider.Scope"/>
        /// </summary>
        public global::IDelegateProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IDelegateProvider"/><br />
        /// Implementation type: <see cref="global::DelegateProvider"/>
        /// </summary>
        public global::IDelegateProvider Self => _delegateProvider.Self;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.DelegateAttribute{TService}">Delegate</see><br />
        /// Service type: <see cref="global::IntToString"/><br />
        /// Implementation type: <see cref="global::IntToString"/>
        /// </summary>
        public global::IntToString IntToString => ConvertToString;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IDelegateProvider.IScope))
                        return SelfScope;
                    return null;
                case "IntToString":
                    if (serviceType == typeof(global::IntToString))
                        return IntToString;
                    return null;
                case "IDelegateProvider":
                    if (serviceType == typeof(global::IDelegateProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Register Generic Service

using CircleDIAttributes;

[ServiceProvider]
[Singleton(typeof(IGenericService<>), typeof(GenericService<>))]
[Singleton<IMyService, MyService>]
public partial class GenericProvider;


public interface IGenericService<T>;
public class GenericService<T> : IGenericService<T>;

public interface IMyService;
public class MyService(IGenericService<int> intService, IGenericService<string> stringService) : IMyService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 5<br />
/// - Singleton: 4<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class GenericProvider : global::IGenericProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public GenericProvider() {
        _genericService_Int32 = new global::GenericService<global::System.Int32>();
        _genericService_String = new global::GenericService<global::System.String>();
        _myService = new global::MyService(_genericService_Int32, _genericService_String);
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IGenericProvider.IScope CreateScope() {
        return new global::GenericProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService MyService => _myService;
    private readonly global::MyService _myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IGenericProvider"/><br />
    /// Implementation type: <see cref="global::GenericProvider"/>
    /// </summary>
    public global::IGenericProvider Self => this;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IGenericService{global::System.Int32}"/><br />
    /// Implementation type: <see cref="global::GenericService{global::System.Int32}"/>
    /// </summary>
    public global::IGenericService<global::System.Int32> GenericService_Int32 => _genericService_Int32;
    private readonly global::GenericService<global::System.Int32> _genericService_Int32;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IGenericService{global::System.String}"/><br />
    /// Implementation type: <see cref="global::GenericService{global::System.String}"/>
    /// </summary>
    public global::IGenericService<global::System.String> GenericService_String => _genericService_String;
    private readonly global::GenericService<global::System.String> _genericService_String;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return MyService;
                return null;
            case "IGenericService`1":
                if (serviceType == typeof(global::IGenericService<global::System.Int32>))
                    return GenericService_Int32;
                if (serviceType == typeof(global::IGenericService<global::System.String>))
                    return GenericService_String;
                return null;
            case "IGenericProvider":
                if (serviceType == typeof(global::IGenericProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 5<br />
    /// - Singleton: 4<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IGenericProvider.IScope, IServiceProvider {
        private readonly global::GenericProvider _genericProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="genericProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="GenericProvider"/>.</param>
        public Scope(global::IGenericProvider genericProvider) {
            _genericProvider = (global::GenericProvider)genericProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IGenericProvider.IScope"/><br />
        /// Implementation type: <see cref="global::GenericProvider.Scope"/>
        /// </summary>
        public global::IGenericProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService"/><br />
        /// Implementation type: <see cref="global::MyService"/>
        /// </summary>
        public global::IMyService MyService => _genericProvider.MyService;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IGenericProvider"/><br />
        /// Implementation type: <see cref="global::GenericProvider"/>
        /// </summary>
        public global::IGenericProvider Self => _genericProvider.Self;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IGenericService{global::System.Int32}"/><br />
        /// Implementation type: <see cref="global::GenericService{global::System.Int32}"/>
        /// </summary>
        public global::IGenericService<global::System.Int32> GenericService_Int32 => _genericProvider.GenericService_Int32;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IGenericService{global::System.String}"/><br />
        /// Implementation type: <see cref="global::GenericService{global::System.String}"/>
        /// </summary>
        public global::IGenericService<global::System.String> GenericService_String => _genericProvider.GenericService_String;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IGenericProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService":
                    if (serviceType == typeof(global::IMyService))
                        return MyService;
                    return null;
                case "IGenericService`1":
                    if (serviceType == typeof(global::IGenericService<global::System.Int32>))
                        return GenericService_Int32;
                    if (serviceType == typeof(global::IGenericService<global::System.String>))
                        return GenericService_String;
                    return null;
                case "IGenericProvider":
                    if (serviceType == typeof(global::IGenericProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Import Services

using CircleDIAttributes;

namespace MyCode;

[ServiceProvider]
[Import<ITestModule>]
public sealed partial class TestProvider;

[Transient<ITestService, TestService>(Implementation = nameof(CreateService))]
public interface ITestModule {
    public static TestService CreateService => new();
}

public interface ITestService;
public sealed class TestService : ITestService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

namespace MyCode;

/// <summary>
/// <para>
/// Number of services registered: 3<br />
/// - Singleton: 1<br />
/// - Scoped: 1<br />
/// - Transient: 1<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public sealed partial class TestProvider : global::MyCode.ITestProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public TestProvider() {
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::MyCode.ITestProvider.IScope CreateScope() {
        return new global::MyCode.TestProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::MyCode.ITestProvider"/><br />
    /// Implementation type: <see cref="global::MyCode.TestProvider"/>
    /// </summary>
    public global::MyCode.ITestProvider Self => this;


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
    /// Service type: <see cref="global::MyCode.ITestService"/><br />
    /// Implementation type: <see cref="global::MyCode.TestService"/>
    /// </summary>
    public global::MyCode.ITestService TestService {
        get {
            global::MyCode.TestService testService_0 = global::MyCode.ITestModule.CreateService;
            return testService_0;
        }
    }


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "ITestService":
                if (serviceType == typeof(global::MyCode.ITestService))
                    return TestService;
                return null;
            case "ITestProvider":
                if (serviceType == typeof(global::MyCode.ITestProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 3<br />
    /// - Singleton: 1<br />
    /// - Scoped: 1<br />
    /// - Transient: 1<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::MyCode.ITestProvider.IScope, IServiceProvider {
        private readonly global::MyCode.TestProvider _testProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="testProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="TestProvider"/>.</param>
        public Scope(global::MyCode.ITestProvider testProvider) {
            _testProvider = (global::MyCode.TestProvider)testProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::MyCode.ITestProvider.IScope"/><br />
        /// Implementation type: <see cref="global::MyCode.TestProvider.Scope"/>
        /// </summary>
        public global::MyCode.ITestProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::MyCode.ITestProvider"/><br />
        /// Implementation type: <see cref="global::MyCode.TestProvider"/>
        /// </summary>
        public global::MyCode.ITestProvider Self => _testProvider.Self;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
        /// Service type: <see cref="global::MyCode.ITestService"/><br />
        /// Implementation type: <see cref="global::MyCode.TestService"/>
        /// </summary>
        public global::MyCode.ITestService TestService {
            get {
                global::MyCode.TestService testService_0 = global::MyCode.ITestModule.CreateService;
                return testService_0;
            }
        }


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::MyCode.ITestProvider.IScope))
                        return SelfScope;
                    return null;
                case "ITestService":
                    if (serviceType == typeof(global::MyCode.ITestService))
                        return TestService;
                    return null;
                case "ITestProvider":
                    if (serviceType == typeof(global::MyCode.ITestProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Implementation Field

using CircleDIAttributes;

[ServiceProvider]
[Singleton<IMyService, MyService>(Implementation = nameof(myService))]
public partial class FieldProvider {
    private readonly MyService myService;

    public FieldProvider(MyService myService) {
        this.myService = myService;
        InitServices();
    }
}


public interface IMyService;
public class MyService : IMyService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 3<br />
/// - Singleton: 2<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class FieldProvider : global::IFieldProvider, IServiceProvider {
    /// <summary>
    /// Constructs non-lazy singleton services. Should be called inside the constructor at the end.
    /// </summary>
    private void InitServices() {
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IFieldProvider.IScope CreateScope() {
        return new global::FieldProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService MyService => myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IFieldProvider"/><br />
    /// Implementation type: <see cref="global::FieldProvider"/>
    /// </summary>
    public global::IFieldProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return MyService;
                return null;
            case "IFieldProvider":
                if (serviceType == typeof(global::IFieldProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 3<br />
    /// - Singleton: 2<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IFieldProvider.IScope, IServiceProvider {
        private readonly global::FieldProvider _fieldProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="fieldProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="FieldProvider"/>.</param>
        public Scope(global::IFieldProvider fieldProvider) {
            _fieldProvider = (global::FieldProvider)fieldProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IFieldProvider.IScope"/><br />
        /// Implementation type: <see cref="global::FieldProvider.Scope"/>
        /// </summary>
        public global::IFieldProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService"/><br />
        /// Implementation type: <see cref="global::MyService"/>
        /// </summary>
        public global::IMyService MyService => _fieldProvider.MyService;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IFieldProvider"/><br />
        /// Implementation type: <see cref="global::FieldProvider"/>
        /// </summary>
        public global::IFieldProvider Self => _fieldProvider.Self;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IFieldProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService":
                    if (serviceType == typeof(global::IMyService))
                        return MyService;
                    return null;
                case "IFieldProvider":
                    if (serviceType == typeof(global::IFieldProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Implementation Property

using CircleDIAttributes;

[ServiceProvider]
[Singleton<IMyService, MyService>(Implementation = nameof(MyServiceImplementation)]
public partial class PropertyProvider {
    private MyService MyServiceImplementation => new MyService();
}


public interface IMyService;
public class MyService : IMyService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 3<br />
/// - Singleton: 2<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class PropertyProvider : global::IPropertyProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public PropertyProvider() {
        _myService = MyServiceImplementation;
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IPropertyProvider.IScope CreateScope() {
        return new global::PropertyProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService MyService => _myService;
    private readonly global::MyService _myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IPropertyProvider"/><br />
    /// Implementation type: <see cref="global::PropertyProvider"/>
    /// </summary>
    public global::IPropertyProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return MyService;
                return null;
            case "IPropertyProvider":
                if (serviceType == typeof(global::IPropertyProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 3<br />
    /// - Singleton: 2<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IPropertyProvider.IScope, IServiceProvider {
        private readonly global::PropertyProvider _propertyProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="propertyProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="PropertyProvider"/>.</param>
        public Scope(global::IPropertyProvider propertyProvider) {
            _propertyProvider = (global::PropertyProvider)propertyProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IPropertyProvider.IScope"/><br />
        /// Implementation type: <see cref="global::PropertyProvider.Scope"/>
        /// </summary>
        public global::IPropertyProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService"/><br />
        /// Implementation type: <see cref="global::MyService"/>
        /// </summary>
        public global::IMyService MyService => _propertyProvider.MyService;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IPropertyProvider"/><br />
        /// Implementation type: <see cref="global::PropertyProvider"/>
        /// </summary>
        public global::IPropertyProvider Self => _propertyProvider.Self;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IPropertyProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService":
                    if (serviceType == typeof(global::IMyService))
                        return MyService;
                    return null;
                case "IPropertyProvider":
                    if (serviceType == typeof(global::IPropertyProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Implementation Method

using CircleDIAttributes;

[ServiceProvider]
[Singleton<IMyService1, MyService1>]
[Singleton<IMyService2, MyService2>(Implementation = nameof(MyService2Implementation)]
public partial class MethodProvider {
    private MyService2 MyService2Implementation(IMyService1 myService1) => new MyService2(myService1);
}


public interface IMyService1;
public class MyService1 : IMyService1;

public interface IMyService2;
public class MyService2(IMyService1 myService1) : IMyService2;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 4<br />
/// - Singleton: 3<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class MethodProvider : global::IMethodProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public MethodProvider() {
        _myService1 = new global::MyService1();
        _myService2 = MyService2Implementation(_myService1);
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IMethodProvider.IScope CreateScope() {
        return new global::MethodProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService1"/><br />
    /// Implementation type: <see cref="global::MyService1"/>
    /// </summary>
    public global::IMyService1 MyService1 => _myService1;
    private readonly global::MyService1 _myService1;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService2"/><br />
    /// Implementation type: <see cref="global::MyService2"/>
    /// </summary>
    public global::IMyService2 MyService2 => _myService2;
    private readonly global::MyService2 _myService2;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMethodProvider"/><br />
    /// Implementation type: <see cref="global::MethodProvider"/>
    /// </summary>
    public global::IMethodProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService1":
                if (serviceType == typeof(global::IMyService1))
                    return MyService1;
                return null;
            case "IMyService2":
                if (serviceType == typeof(global::IMyService2))
                    return MyService2;
                return null;
            case "IMethodProvider":
                if (serviceType == typeof(global::IMethodProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 4<br />
    /// - Singleton: 3<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IMethodProvider.IScope, IServiceProvider {
        private readonly global::MethodProvider _methodProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="methodProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="MethodProvider"/>.</param>
        public Scope(global::IMethodProvider methodProvider) {
            _methodProvider = (global::MethodProvider)methodProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IMethodProvider.IScope"/><br />
        /// Implementation type: <see cref="global::MethodProvider.Scope"/>
        /// </summary>
        public global::IMethodProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService1"/><br />
        /// Implementation type: <see cref="global::MyService1"/>
        /// </summary>
        public global::IMyService1 MyService1 => _methodProvider.MyService1;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService2"/><br />
        /// Implementation type: <see cref="global::MyService2"/>
        /// </summary>
        public global::IMyService2 MyService2 => _methodProvider.MyService2;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMethodProvider"/><br />
        /// Implementation type: <see cref="global::MethodProvider"/>
        /// </summary>
        public global::IMethodProvider Self => _methodProvider.Self;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IMethodProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService1":
                    if (serviceType == typeof(global::IMyService1))
                        return MyService1;
                    return null;
                case "IMyService2":
                    if (serviceType == typeof(global::IMyService2))
                        return MyService2;
                    return null;
                case "IMethodProvider":
                    if (serviceType == typeof(global::IMethodProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Disposable Services

using CircleDIAttributes;
using System;
using System.Threading.Tasks;

[ServiceProvider]
[Singleton<IMyService1, MyService1>]
[Singleton<IMyService2, MyService2>]
[Transient<IMyService3, MyService3>]
[Transient<IMyService4, MyService4>]
public partial class DisposingProvider;


public interface IMyService1;
public class MyService1 : IMyService1, IDisposable {
    public void Dispose() { }
}

public interface IMyService2;
public class MyService2 : IMyService2, IAsyncDisposable {
    public ValueTask DisposeAsync() => default;
}

public interface IMyService3;
public class MyService3 : IMyService3, IDisposable {
    public void Dispose() { }
}

public interface IMyService4;
public class MyService4 : IMyService4, IAsyncDisposable {
    public ValueTask DisposeAsync() => default;
}
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 6<br />
/// - Singleton: 3<br />
/// - Scoped: 1<br />
/// - Transient: 2<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class DisposingProvider : global::IDisposingProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public DisposingProvider() {
        _myService1 = new global::MyService1();
        _myService2 = new global::MyService2();

        _disposeList = [];
        _asyncDisposeList = [];
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IDisposingProvider.IScope CreateScope() {
        return new global::DisposingProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService1"/><br />
    /// Implementation type: <see cref="global::MyService1"/>
    /// </summary>
    public global::IMyService1 MyService1 => _myService1;
    private readonly global::MyService1 _myService1;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService2"/><br />
    /// Implementation type: <see cref="global::MyService2"/>
    /// </summary>
    public global::IMyService2 MyService2 => _myService2;
    private readonly global::MyService2 _myService2;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IDisposingProvider"/><br />
    /// Implementation type: <see cref="global::DisposingProvider"/>
    /// </summary>
    public global::IDisposingProvider Self => this;


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
    /// Service type: <see cref="global::IMyService3"/><br />
    /// Implementation type: <see cref="global::MyService3"/>
    /// </summary>
    public global::IMyService3 MyService3 {
        get {
            global::MyService3 myService3_0 = new global::MyService3();
            lock (_disposeList_lock) {
                _disposeList.Add(myService3_0);
            }
            return myService3_0;
        }
    }

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
    /// Service type: <see cref="global::IMyService4"/><br />
    /// Implementation type: <see cref="global::MyService4"/>
    /// </summary>
    public global::IMyService4 MyService4 {
        get {
            global::MyService4 myService4_0 = new global::MyService4();
            lock (_asyncDisposeList_lock) {
                _asyncDisposeList.Add(myService4_0);
            }
            return myService4_0;
        }
    }


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService1":
                if (serviceType == typeof(global::IMyService1))
                    return MyService1;
                return null;
            case "IMyService2":
                if (serviceType == typeof(global::IMyService2))
                    return MyService2;
                return null;
            case "IMyService3":
                if (serviceType == typeof(global::IMyService3))
                    return MyService3;
                return null;
            case "IMyService4":
                if (serviceType == typeof(global::IMyService4))
                    return MyService4;
                return null;
            case "IDisposingProvider":
                if (serviceType == typeof(global::IDisposingProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    private readonly global::System.Collections.Generic.List<IDisposable> _disposeList;
    private readonly global::System.Threading.Lock _disposeList_lock = new();

    private readonly global::System.Collections.Generic.List<IAsyncDisposable> _asyncDisposeList;
    private readonly global::System.Threading.Lock _asyncDisposeList_lock = new();

    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
        ((IDisposable)_myService1).Dispose();
        _ = ((IAsyncDisposable)_myService2).DisposeAsync().Preserve();

        lock (_disposeList_lock)
            foreach (IDisposable disposable in _disposeList)
                disposable.Dispose();

        lock (_asyncDisposeList_lock)
            foreach (IAsyncDisposable asyncDisposable in _asyncDisposeList)
                if (asyncDisposable is IDisposable disposable)
                    disposable.Dispose();
                else
                    _ = asyncDisposable.DisposeAsync().Preserve();
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        ((IDisposable)_myService1).Dispose();

        lock (_disposeList_lock)
            foreach (IDisposable disposable in _disposeList)
                disposable.Dispose();

        Task[] disposeTasks = new Task[1 + _asyncDisposeList.Count];

        disposeTasks[0] = ((IAsyncDisposable)_myService2).DisposeAsync().AsTask();

        int index = 1;
        lock (_asyncDisposeList_lock)
            foreach (IAsyncDisposable asyncDisposable in _asyncDisposeList)
                disposeTasks[index++] = asyncDisposable.DisposeAsync().AsTask();

        return new ValueTask(Task.WhenAll(disposeTasks));
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 6<br />
    /// - Singleton: 3<br />
    /// - Scoped: 1<br />
    /// - Transient: 2<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IDisposingProvider.IScope, IServiceProvider {
        private readonly global::DisposingProvider _disposingProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="disposingProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="DisposingProvider"/>.</param>
        public Scope(global::IDisposingProvider disposingProvider) {
            _disposingProvider = (global::DisposingProvider)disposingProvider;

            _disposeList = [];
            _asyncDisposeList = [];
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IDisposingProvider.IScope"/><br />
        /// Implementation type: <see cref="global::DisposingProvider.Scope"/>
        /// </summary>
        public global::IDisposingProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService1"/><br />
        /// Implementation type: <see cref="global::MyService1"/>
        /// </summary>
        public global::IMyService1 MyService1 => _disposingProvider.MyService1;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService2"/><br />
        /// Implementation type: <see cref="global::MyService2"/>
        /// </summary>
        public global::IMyService2 MyService2 => _disposingProvider.MyService2;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IDisposingProvider"/><br />
        /// Implementation type: <see cref="global::DisposingProvider"/>
        /// </summary>
        public global::IDisposingProvider Self => _disposingProvider.Self;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
        /// Service type: <see cref="global::IMyService3"/><br />
        /// Implementation type: <see cref="global::MyService3"/>
        /// </summary>
        public global::IMyService3 MyService3 {
            get {
                global::MyService3 myService3_0 = new global::MyService3();
                lock (_disposeList_lock) {
                    _disposeList.Add(myService3_0);
                }
                return myService3_0;
            }
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
        /// Service type: <see cref="global::IMyService4"/><br />
        /// Implementation type: <see cref="global::MyService4"/>
        /// </summary>
        public global::IMyService4 MyService4 {
            get {
                global::MyService4 myService4_0 = new global::MyService4();
                lock (_asyncDisposeList_lock) {
                    _asyncDisposeList.Add(myService4_0);
                }
                return myService4_0;
            }
        }


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IDisposingProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService1":
                    if (serviceType == typeof(global::IMyService1))
                        return MyService1;
                    return null;
                case "IMyService2":
                    if (serviceType == typeof(global::IMyService2))
                        return MyService2;
                    return null;
                case "IMyService3":
                    if (serviceType == typeof(global::IMyService3))
                        return MyService3;
                    return null;
                case "IMyService4":
                    if (serviceType == typeof(global::IMyService4))
                        return MyService4;
                    return null;
                case "IDisposingProvider":
                    if (serviceType == typeof(global::IDisposingProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        private readonly global::System.Collections.Generic.List<IDisposable> _disposeList;
        private readonly global::System.Threading.Lock _disposeList_lock = new();

        private readonly global::System.Collections.Generic.List<IAsyncDisposable> _asyncDisposeList;
        private readonly global::System.Threading.Lock _asyncDisposeList_lock = new();

        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
            lock (_disposeList_lock)
                foreach (IDisposable disposable in _disposeList)
                    disposable.Dispose();

            lock (_asyncDisposeList_lock)
                foreach (IAsyncDisposable asyncDisposable in _asyncDisposeList)
                    if (asyncDisposable is IDisposable disposable)
                        disposable.Dispose();
                    else
                        _ = asyncDisposable.DisposeAsync().Preserve();
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            lock (_disposeList_lock)
                foreach (IDisposable disposable in _disposeList)
                    disposable.Dispose();

            Task[] disposeTasks = new Task[_asyncDisposeList.Count];

            int index = 0;
            lock (_asyncDisposeList_lock)
                foreach (IAsyncDisposable asyncDisposable in _asyncDisposeList)
                    disposeTasks[index++] = asyncDisposable.DisposeAsync().AsTask();

            return new ValueTask(Task.WhenAll(disposeTasks));
        }
    }
}



Lazy Service Instantiation

using CircleDIAttributes;

[ServiceProvider(CreationTime = CreationTiming.Lazy)]
[Singleton<IMyService, MyService>]
public partial class LazyProvider;


public interface IMyService;
public class MyService : IMyService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 3<br />
/// - Singleton: 2<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class LazyProvider : global::ILazyProvider, IServiceProvider {
    private readonly global::System.Threading.Lock _lock = new();

    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public LazyProvider() {
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::ILazyProvider.IScope CreateScope() {
        return new global::LazyProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService MyService {
        get {
            if (_myService is null)
                lock (_lock)
                    if (_myService is null) {
                        _myService = new global::MyService();
                    }
            return _myService;
        }
    }
    private global::MyService? _myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::ILazyProvider"/><br />
    /// Implementation type: <see cref="global::LazyProvider"/>
    /// </summary>
    public global::ILazyProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return MyService;
                return null;
            case "ILazyProvider":
                if (serviceType == typeof(global::ILazyProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 3<br />
    /// - Singleton: 2<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::ILazyProvider.IScope, IServiceProvider {
        private readonly global::LazyProvider _lazyProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="lazyProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="LazyProvider"/>.</param>
        public Scope(global::ILazyProvider lazyProvider) {
            _lazyProvider = (global::LazyProvider)lazyProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::ILazyProvider.IScope"/><br />
        /// Implementation type: <see cref="global::LazyProvider.Scope"/>
        /// </summary>
        public global::ILazyProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService"/><br />
        /// Implementation type: <see cref="global::MyService"/>
        /// </summary>
        public global::IMyService MyService => _lazyProvider.MyService;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::ILazyProvider"/><br />
        /// Implementation type: <see cref="global::LazyProvider"/>
        /// </summary>
        public global::ILazyProvider Self => _lazyProvider.Self;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::ILazyProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService":
                    if (serviceType == typeof(global::IMyService))
                        return MyService;
                    return null;
                case "ILazyProvider":
                    if (serviceType == typeof(global::ILazyProvider))
                        return Self;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Get Method Accessor

using CircleDIAttributes;

[ServiceProvider(GetAccessor = GetAccess.Method)]
[Singleton<IMyService, MyService>]
public partial class MethodProvider;


public interface IMyService;
public class MyService : IMyService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 3<br />
/// - Singleton: 2<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class MethodProvider : global::IMethodProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public MethodProvider() {
        _myService = new global::MyService();
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IMethodProvider.IScope CreateScope() {
        return new global::MethodProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService GetMyService() => _myService;
    private readonly global::MyService _myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMethodProvider"/><br />
    /// Implementation type: <see cref="global::MethodProvider"/>
    /// </summary>
    public global::IMethodProvider GetSelf() => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return GetMyService();
                return null;
            case "IMethodProvider":
                if (serviceType == typeof(global::IMethodProvider))
                    return GetSelf();
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 3<br />
    /// - Singleton: 2<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IMethodProvider.IScope, IServiceProvider {
        private readonly global::MethodProvider _methodProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="methodProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="MethodProvider"/>.</param>
        public Scope(global::IMethodProvider methodProvider) {
            _methodProvider = (global::MethodProvider)methodProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IMethodProvider.IScope"/><br />
        /// Implementation type: <see cref="global::MethodProvider.Scope"/>
        /// </summary>
        public global::IMethodProvider.IScope GetSelfScope() => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService"/><br />
        /// Implementation type: <see cref="global::MyService"/>
        /// </summary>
        public global::IMyService GetMyService() => _methodProvider.GetMyService();

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMethodProvider"/><br />
        /// Implementation type: <see cref="global::MethodProvider"/>
        /// </summary>
        public global::IMethodProvider GetSelf() => _methodProvider.GetSelf();


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IMethodProvider.IScope))
                        return GetSelfScope();
                    return null;
                case "IMyService":
                    if (serviceType == typeof(global::IMyService))
                        return GetMyService();
                    return null;
                case "IMethodProvider":
                    if (serviceType == typeof(global::IMethodProvider))
                        return GetSelf();
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            return default;
        }
    }
}



Disable Scope and disable Dispose Generation

using CircleDIAttributes;

[ServiceProvider(GenerateDisposeMethods = DisposeGeneration.NoDisposing)]
[ScopedProvider(Generate = false)]
[Singleton<IMyService, MyService>]
public partial class SkipGenerationProvider;


public interface IMyService;
public class MyService : IMyService;
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;

/// <summary>
/// <para>
/// Number of services registered: 2<br />
/// - Singleton: 2<br />
/// - Scoped: 0<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider has no scope,<br />
/// implements no Dispose methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class SkipGenerationProvider : global::ISkipGenerationProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public SkipGenerationProvider() {
        _myService = new global::MyService();
    }

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService MyService => _myService;
    private readonly global::MyService _myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::ISkipGenerationProvider"/><br />
    /// Implementation type: <see cref="global::SkipGenerationProvider"/>
    /// </summary>
    public global::ISkipGenerationProvider Self => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return MyService;
                return null;
            case "ISkipGenerationProvider":
                if (serviceType == typeof(global::ISkipGenerationProvider))
                    return Self;
                return null;
            default:
                return null;
        }
    }
}



ThreadSafe disabled

using CircleDIAttributes;
using System;

[ServiceProvider(ThreadSafe = false)]
[Singleton<IMyService, MyService>(CreationTime = CreationTiming.Lazy)]
[Transient<IDisposableService, DisposableService>]
public partial class FastProvider;


public interface IMyService;
public class MyService : IMyService;

public interface IDisposableService : IDisposable;
public class DisposableService : IDisposableService {
    public void Dispose() { }
}
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 4<br />
/// - Singleton: 2<br />
/// - Scoped: 1<br />
/// - Transient: 1<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is not thread safe.
/// </para>
/// </summary>
public partial class FastProvider : global::IFastProvider, IServiceProvider {
    /// <summary>
    /// Creates an instance of a ServiceProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> singleton services.
    /// </summary>
    public FastProvider() {
        _disposeList = [];
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IFastProvider.IScope CreateScope() {
        return new global::FastProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IMyService"/><br />
    /// Implementation type: <see cref="global::MyService"/>
    /// </summary>
    public global::IMyService MyService {
        get {
            if (_myService is null) {
                _myService = new global::MyService();
            }
            return _myService;
        }
    }
    private global::MyService? _myService;

    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IFastProvider"/><br />
    /// Implementation type: <see cref="global::FastProvider"/>
    /// </summary>
    public global::IFastProvider Self => this;


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
    /// Service type: <see cref="global::IDisposableService"/><br />
    /// Implementation type: <see cref="global::DisposableService"/>
    /// </summary>
    public global::IDisposableService DisposableService {
        get {
            global::DisposableService disposableService_0 = new global::DisposableService();
            _disposeList.Add(disposableService_0);
            return disposableService_0;
        }
    }


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IMyService":
                if (serviceType == typeof(global::IMyService))
                    return MyService;
                return null;
            case "IFastProvider":
                if (serviceType == typeof(global::IFastProvider))
                    return Self;
                return null;
            case "IDisposableService":
                if (serviceType == typeof(global::IDisposableService))
                    return DisposableService;
                return null;
            default:
                return null;
        }
    }


    private readonly global::System.Collections.Generic.List<IDisposable> _disposeList;

    /// <summary>
    /// Disposes all disposable services instantiated by this provider.
    /// </summary>
    public void Dispose() {
        foreach (IDisposable disposable in _disposeList)
            disposable.Dispose();
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously.
    /// </summary>
    public ValueTask DisposeAsync() {
        foreach (IDisposable disposable in _disposeList)
            disposable.Dispose();

        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 4<br />
    /// - Singleton: 2<br />
    /// - Scoped: 1<br />
    /// - Transient: 1<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is not thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IFastProvider.IScope, IServiceProvider {
        private readonly global::FastProvider _fastProvider;

        /// <summary>
        /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
        /// </summary>
        /// <param name="fastProvider">An instance of the service provider this provider is the scope of. It must be an instance of <see cref="FastProvider"/>.</param>
        public Scope(global::IFastProvider fastProvider) {
            _fastProvider = (global::FastProvider)fastProvider;

            _disposeList = [];
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IFastProvider.IScope"/><br />
        /// Implementation type: <see cref="global::FastProvider.Scope"/>
        /// </summary>
        public global::IFastProvider.IScope SelfScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IMyService"/><br />
        /// Implementation type: <see cref="global::MyService"/>
        /// </summary>
        public global::IMyService MyService => _fastProvider.MyService;

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IFastProvider"/><br />
        /// Implementation type: <see cref="global::FastProvider"/>
        /// </summary>
        public global::IFastProvider Self => _fastProvider.Self;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.TransientAttribute{TService}">Transient</see><br />
        /// Service type: <see cref="global::IDisposableService"/><br />
        /// Implementation type: <see cref="global::DisposableService"/>
        /// </summary>
        public global::IDisposableService DisposableService {
            get {
                global::DisposableService disposableService_0 = new global::DisposableService();
                _disposeList.Add(disposableService_0);
                return disposableService_0;
            }
        }


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IFastProvider.IScope))
                        return SelfScope;
                    return null;
                case "IMyService":
                    if (serviceType == typeof(global::IMyService))
                        return MyService;
                    return null;
                case "IFastProvider":
                    if (serviceType == typeof(global::IFastProvider))
                        return Self;
                    return null;
                case "IDisposableService":
                    if (serviceType == typeof(global::IDisposableService))
                        return DisposableService;
                    return null;
                default:
                    return null;
            }
        }


        private readonly global::System.Collections.Generic.List<IDisposable> _disposeList;

        /// <summary>
        /// Disposes all disposable services instantiated by this provider.
        /// </summary>
        public void Dispose() {
            foreach (IDisposable disposable in _disposeList)
                disposable.Dispose();
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously.
        /// </summary>
        public ValueTask DisposeAsync() {
            foreach (IDisposable disposable in _disposeList)
                disposable.Dispose();

            return default;
        }
    }
}



Overwriting defaults

using CircleDIAttributes;
using System.Threading.Tasks;

[ServiceProvider]
[Singleton<IOverwritingProvider, OverwritingProvider>(Name = "Me", Implementation = "this")]
[Scoped<IOverwritingProvider.IScope, OverwritingProvider.Scope>(Name = "MeScope", Implementation = "this")]
public partial class OverwritingProvider {
    public OverwritingProvider() {
        InitServices();
    }

    public void Dispose() {
        DisposeServices();
    }

    public ValueTask DisposeAsync() {
        return DisposeServicesAsync();
    }

    public sealed partial class Scope {
        public Scope([Dependency] IOverwritingProvider overwritingProvider) {
            InitServices(overwritingProvider);
        }

        public void Dispose() {
            DisposeServices();
        }

        public ValueTask DisposeAsync() {
            return DisposeServicesAsync();
        }
    }
}

public partial interface IOverwritingProvider {
    public partial interface IScope;
}
// <auto-generated/>
#pragma warning disable
#nullable enable annotations


using System;
using System.Threading.Tasks;

/// <summary>
/// <para>
/// Number of services registered: 2<br />
/// - Singleton: 1<br />
/// - Scoped: 1<br />
/// - Transient: 0<br />
/// - Delegate: 0
/// </para>
/// <para>
/// This provider can create a scope,<br />
/// implements both Dispose() and DisposeAsync() methods<br />
/// and is thread safe.
/// </para>
/// </summary>
public partial class OverwritingProvider : global::IOverwritingProvider, IServiceProvider {
    /// <summary>
    /// Constructs non-lazy singleton services. Should be called inside the constructor at the end.
    /// </summary>
    private void InitServices() {
    }

    /// <summary>
    /// Creates an instance of a ScopeProvider together with all <see cref="global::CircleDIAttributes.CreationTiming.Constructor">non-lazy</see> scoped services.
    /// </summary>
    public global::IOverwritingProvider.IScope CreateScope() {
        return new global::OverwritingProvider.Scope(this);
    }


    /// <summary>
    /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
    /// Service type: <see cref="global::IOverwritingProvider"/><br />
    /// Implementation type: <see cref="global::OverwritingProvider"/>
    /// </summary>
    public global::IOverwritingProvider Me => this;


    /// <summary>
    /// <para>Finds all registered services of the given type.</para>
    /// <para>
    /// The method returns<br />
    /// - null (when registered zero times)<br />
    /// - given type (when registered ones)<br />
    /// - Array of given type (when registered many times)
    /// </para>
    /// </summary>
    object? IServiceProvider.GetService(Type serviceType) {
        switch (serviceType.Name) {
            case "IOverwritingProvider":
                if (serviceType == typeof(global::IOverwritingProvider))
                    return Me;
                return null;
            default:
                return null;
        }
    }


    /// <summary>
    /// Disposes all disposable services instantiated by this provider. Should be called inside the Dispose() method.
    /// </summary>
    private void DisposeServices() {
    }

    /// <summary>
    /// Disposes all disposable services instantiated by this provider asynchronously. Should be called inside the DisposeAsync() method.
    /// </summary>
    private ValueTask DisposeServicesAsync() {
        return default;
    }



    /// <summary>
    /// <para>
    /// Number of services registered: 2<br />
    /// - Singleton: 1<br />
    /// - Scoped: 1<br />
    /// - Transient: 0<br />
    /// - Delegate: 0
    /// </para>
    /// <para>
    /// This provider can create a scope,<br />
    /// implements both Dispose() and DisposeAsync() methods<br />
    /// and is thread safe.
    /// </para>
    /// </summary>
    public sealed partial class Scope : global::IOverwritingProvider.IScope, IServiceProvider {
        private global::OverwritingProvider _overwritingProvider;

        /// <summary>
        /// Constructs non-lazy scoped services. Should be called inside the constructor at the end.
        /// </summary>
        /// <param name="overwritingProvider">
        /// The ServiceProvider this ScopedProvider is created from. It must be an instance of <see cref="OverwritingProvider"/>. Usually it is the object you get injected to your constructor parameter:<br />
        /// public Scope([Dependency] IOverwritingProvider overwritingProvider) { ...
        /// </param>
        [System.Diagnostics.CodeAnalysis.MemberNotNull(nameof(_overwritingProvider))]
        private void InitServices(global::IOverwritingProvider overwritingProvider) {
            _overwritingProvider = (global::OverwritingProvider)overwritingProvider;
        }

        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.ScopedAttribute{TService}">Scoped</see><br />
        /// Service type: <see cref="global::IOverwritingProvider.IScope"/><br />
        /// Implementation type: <see cref="global::OverwritingProvider.Scope"/>
        /// </summary>
        public global::IOverwritingProvider.IScope MeScope => this;


        /// <summary>
        /// Lifetime: <see cref="global::CircleDIAttributes.SingletonAttribute{TService}">Singleton</see><br />
        /// Service type: <see cref="global::IOverwritingProvider"/><br />
        /// Implementation type: <see cref="global::OverwritingProvider"/>
        /// </summary>
        public global::IOverwritingProvider Me => _overwritingProvider.Me;


        /// <summary>
        /// <para>Finds all registered services of the given type.</para>
        /// <para>
        /// The method returns<br />
        /// - null (when registered zero times)<br />
        /// - given type (when registered ones)<br />
        /// - Array of given type (when registered many times)
        /// </para>
        /// </summary>
        object? IServiceProvider.GetService(Type serviceType) {
            switch (serviceType.Name) {
                case "IScope":
                    if (serviceType == typeof(global::IOverwritingProvider.IScope))
                        return MeScope;
                    return null;
                case "IOverwritingProvider":
                    if (serviceType == typeof(global::IOverwritingProvider))
                        return Me;
                    return null;
                default:
                    return null;
            }
        }


        /// <summary>
        /// Disposes all disposable services instantiated by this provider. Should be called inside the Dispose() method.
        /// </summary>
        private void DisposeServices() {
        }

        /// <summary>
        /// Disposes all disposable services instantiated by this provider asynchronously. Should be called inside the DisposeAsync() method.
        /// </summary>
        private ValueTask DisposeServicesAsync() {
            return default;
        }
    }
}