DevTeam / Pure.DI

Pure DI for .NET
MIT License
410 stars 21 forks source link

Incorrect source generated #55

Closed ekalchev closed 2 months ago

ekalchev commented 2 months ago

I have this registration code

namespace MobiSystems.ServiceHost
{
    internal partial class Composition
    {
        // IMPORTANT!!! This class should not contain any other methods, properties, fields and etc. other than Setup method

        private void Setup() => DI.Setup(nameof(Composition))
            .Root<ServiceApplication>("Root")
            .Bind<IEnumerable<TT>>().To(ctx =>
            {
                ctx.Inject(out IReadOnlyCollection<TT> items);
                return items;
            })
            .Bind<IProcessRegistry>().As(Singleton).To(ctx => new ProcessRegistry(ProcessRegistryCommonNameProvider.GetName(ServiceApplication.GetProductFamilyName()), (int)ProductType.ManagementService))
            .Bind<Func<bool, ServiceHostEnvironment>>().To<Func<bool, ServiceHostEnvironment>>(ctx => (bool registerForRestart) =>
            {
                ctx.Inject(out Func<ILogger2> loggerFactory);
                ctx.Inject(out Func<IServiceHost> serviceHostFactory);
                return new ServiceHostEnvironment(loggerFactory, serviceHostFactory, registerForRestart);
            })
            .Bind<Microsoft.Extensions.Configuration.IConfiguration>().As(Singleton).To(ctx => 
            {
                AppConfiguration configuration = new AppConfiguration();
                configuration.Init("MobiSystemsPackaged\\Configuration", "MobiSystems.ServiceHost.appsettings.json");
                return configuration;
            })
            .Bind<ITelemetry>().As(Singleton).To(ctx => 
            {
                //SentryIOTelemetry requires TelemetryRuntime to be initialized first
                ctx.Inject(out TelemetryRuntime telemetryRuntime);
                return new SentryIOTelemetry();
            })
            .Bind().As(Singleton).To<TelemetryRuntime>(ctx => 
            {
                ctx.Inject(out IDeploymentContext deploymentContext);
                ctx.Inject(out Microsoft.Extensions.Configuration.IConfiguration configuration);

                TelemetryRuntimeParameters parameters = new TelemetryRuntimeParameters(
                    "MobiSystems.ServiceHost",
                    configuration["TelemetryHost"],
                    configuration["BuildType"],
                    deploymentContext.DeploymentType.GetDeploymentTypeName(),
                    (_) => true);

                return new TelemetryRuntime(parameters);
            })
            .Bind<IDeploymentContext>().As(Singleton).To<DeploymentContext>()
            .Bind<IService>(1).To<PackageUpdaterService>()
            .Bind<ILogger2>().As(Singleton).To(ctx =>
            {
                Logging.Sinks.File fileSink = new("c:\\Temp\\service-host.txt", new DefaultLogsCleaner());

                return new LoggerConfiguration()
                    .WriteTo(fileSink)
                    .CreateLogger();
            })
            .Bind().As(Singleton).To<Services.ServiceHost>()
            ;
    }
}

I am getting null reference exception at

                TelemetryRuntimeParameters localParametersM05D20di9= new TelemetryRuntimeParameters(
                    "MobiSystems.ServiceHost",
localConfigurationM05D20di8["TelemetryHost"],
localConfigurationM05D20di8["BuildType"],
localDeploymentContextM05D20di7.DeploymentType.GetDeploymentTypeName(),
                    (_) => true);

It says localConfigurationM05D20di8 is null.

Seems to me that generated code is incorrect. If you look at line 179 EnsureExistenceOf_singletonSentryIOTelemetryM05D20di36(); there is nothing to instantiate AppConfiguration instance localConfigurationM05D20di8.


// <auto-generated/>
// by Pure.DI 2.1.19+792162136ec813fa5eadf6acf1b4563282a7abe6

using Microsoft.Extensions.Configuration;
using MobiSystems.Logging;
using MobiSystems.Logging.Sinks;
using MobiSystems.Packages;
using MobiSystems.ServiceHost;
using MobiSystems.Services;
using MobiSystems.Telemetry.SentryIO;
using MobiSystems.Windows;
using MobiSystems.Windows.Threading;
using OfficeSuite;
using Pure.DI;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

namespace MobiSystems.ServiceHost
{
    /// <summary>
    /// <para>
    /// <b>Composition roots</b><br/>
    /// <list type="table">
    /// <listheader>
    /// <term>Root</term>
    /// <description>Description</description>
    /// </listheader>
    /// <item>
    /// <term>
    /// <see cref="MobiSystems.ServiceHost.ServiceApplication"/> <see cref="Root"/><br/>or using <see cref="Resolve{T}()"/> method: <c>Resolve&lt;MobiSystems.ServiceHost.ServiceApplication&gt;()</c>
    /// </term>
    /// <description>
    /// Provides a composition root of type <see cref="MobiSystems.ServiceHost.ServiceApplication"/>.
    /// </description>
    /// </item>
    /// </list>
    /// </para>
    /// </summary>
    /// <example>
    /// This shows how to get an instance of type <see cref="MobiSystems.ServiceHost.ServiceApplication"/> using the composition root <see cref="Root"/>:
    /// <code>
    /// using var composition = new Composition();
    /// var instance = composition.Root;
    /// </code>
    /// </example>
    /// This class was created by <a href="https://github.com/DevTeam/Pure.DI">Pure.DI</a> source code generator.
    /// <seealso cref="Pure.DI.DI.Setup"/>
    /// <seealso cref="Pure.DI.IConfiguration.Bind(object[])"/>
    /// <seealso cref="Pure.DI.IConfiguration.Bind{T}(object[])"/>
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
    partial class Composition: global::System.IDisposable
    {
        private readonly Composition _rootM05D20di;
        private readonly object _lockM05D20di;
        private object[] _disposablesM05D20di;
        private int _disposeIndexM05D20di;

        private MobiSystems.Services.ServiceHost _singletonServiceHostM05D20di41;
        private MobiSystems.Telemetry.SentryIO.SentryIOTelemetry _singletonSentryIOTelemetryM05D20di36;
        private MobiSystems.Windows.Threading.ProcessRegistry _singletonProcessRegistryM05D20di33;
        private MobiSystems.Logging.Logger2 _singletonLogger2M05D20di40;
        private MobiSystems.Packages.AppConfiguration _singletonAppConfigurationM05D20di35;
        private MobiSystems.Telemetry.SentryIO.TelemetryRuntime _singletonTelemetryRuntimeM05D20di37;
        private MobiSystems.Windows.DeploymentContext _singletonDeploymentContextM05D20di38;

        /// <summary>
        /// This constructor creates a new instance of <see cref="Composition"/>.
        /// </summary>
        public Composition()
        {
            _rootM05D20di = this;
            _lockM05D20di = new object();
            _disposablesM05D20di = new object[3];
        }

        /// <summary>
        /// This constructor creates a new instance of <see cref="Composition"/> scope based on <paramref name="parentScope"/>. This allows the <see cref="Lifetime.Scoped"/> life time to be applied.
        /// </summary>
        /// <param name="parentScope">Scope parent.</param>
        internal Composition(Composition parentScope)
        {
            _rootM05D20di = (parentScope ?? throw new global::System.ArgumentNullException(nameof(parentScope)))._rootM05D20di;
            _lockM05D20di = _rootM05D20di._lockM05D20di;
            _disposablesM05D20di = parentScope._disposablesM05D20di;
        }

        #region Composition Roots
        /// <summary>
        /// Provides a composition root of type <see cref="MobiSystems.ServiceHost.ServiceApplication"/>.
        /// </summary>
        /// <example>
        /// This shows how to get an instance of type <see cref="MobiSystems.ServiceHost.ServiceApplication"/>:
        /// <code>
        /// using var composition = new Composition();
        /// var instance = composition.Root;
        /// </code>
        /// </example>
        public MobiSystems.ServiceHost.ServiceApplication Root
        {
            #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET
            [global::System.Diagnostics.Contracts.Pure]
            #endif
            [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
            get
            {
                var perResolveFuncM05D20di47 = default(System.Func<MobiSystems.Logging.ILogger2>);
                var perResolveFuncM05D20di48 = default(System.Func<MobiSystems.Services.IServiceHost>);
                var perResolveFuncM05D20di49 = default(System.Func<System.Collections.Generic.IEnumerable<MobiSystems.Services.IService>>);
                System.Func<bool, MobiSystems.Services.ServiceHostEnvironment> transientFuncM05D20di1 = [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] (bool registerForRestart) =>
                            {

                    if (perResolveFuncM05D20di47 == null)
                    {
                        lock (_lockM05D20di)
                        {
                            if (perResolveFuncM05D20di47 == null)
                            {
                                perResolveFuncM05D20di47 = new global::System.Func<MobiSystems.Logging.ILogger2>([global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] () =>
                                                    {

                                    EnsureExistenceOf_singletonLogger2M05D20di40();
                                    var localValueM05D20di2 = _rootM05D20di._singletonLogger2M05D20di40;
                                                        return localValueM05D20di2;
                                                    });
                            }
                        }
                    }

                    var localLoggerFactoryM05D20di0 = perResolveFuncM05D20di47;

                    if (perResolveFuncM05D20di48 == null)
                    {
                        lock (_lockM05D20di)
                        {
                            if (perResolveFuncM05D20di48 == null)
                            {
                                perResolveFuncM05D20di48 = new global::System.Func<MobiSystems.Services.IServiceHost>([global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] () =>
                                                    {

                                    if (_rootM05D20di._singletonServiceHostM05D20di41 == null)
                                    {
                                        lock (_lockM05D20di)
                                        {
                                            if (_rootM05D20di._singletonServiceHostM05D20di41 == null)
                                            {
                                                EnsureExistenceOf_singletonLogger2M05D20di40();
                                                if (_rootM05D20di._singletonProcessRegistryM05D20di33 == null)
                                                {
                                                    _rootM05D20di._singletonProcessRegistryM05D20di33 = new ProcessRegistry(ProcessRegistryCommonNameProvider.GetName(ServiceApplication.GetProductFamilyName()), (int)ProductType.ManagementService);
                                                    _rootM05D20di._disposablesM05D20di[_rootM05D20di._disposeIndexM05D20di++] = _rootM05D20di._singletonProcessRegistryM05D20di33;
                                                }

                                                if (perResolveFuncM05D20di49 == null)
                                                {
                                                    perResolveFuncM05D20di49 = new global::System.Func<System.Collections.Generic.IEnumerable<MobiSystems.Services.IService>>([global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] () =>
                                                                        {

                                                        EnsureExistenceOf_singletonAppConfigurationM05D20di35();
                                                        EnsureExistenceOf_singletonLogger2M05D20di40();
                                                        EnsureExistenceOf_singletonSentryIOTelemetryM05D20di36();
                                                        MobiSystems.Services.IService[] transientM05D20di3;
                                                        {
                                                            var localArrM05D20di11 = new MobiSystems.Services.IService[1] { new MobiSystems.PackageUpdater.Service.PackageUpdaterService(_rootM05D20di._singletonSentryIOTelemetryM05D20di36, _rootM05D20di._singletonLogger2M05D20di40, _rootM05D20di._singletonAppConfigurationM05D20di35) };
                                                         transientM05D20di3 = localArrM05D20di11;}
                                                        System.Collections.Generic.IReadOnlyCollection<MobiSystems.Services.IService> transientIReadOnlyCollectionM05D20di2;
                                                        {
                                                            var localItemsM05D20di12 = transientM05D20di3;
                                                         transientIReadOnlyCollectionM05D20di2 = localItemsM05D20di12;}
                                                        var localValueM05D20di5 = transientIReadOnlyCollectionM05D20di2;
                                                                            return localValueM05D20di5;
                                                                        });
                                                }

                                                EnsureExistenceOf_singletonSentryIOTelemetryM05D20di36();
                                                _rootM05D20di._singletonServiceHostM05D20di41 = new MobiSystems.Services.ServiceHost(_rootM05D20di._singletonSentryIOTelemetryM05D20di36, perResolveFuncM05D20di49, _rootM05D20di._singletonProcessRegistryM05D20di33, _rootM05D20di._singletonLogger2M05D20di40);
                                            }
                                        }
                                    }

                                    var localValueM05D20di4 = _rootM05D20di._singletonServiceHostM05D20di41;
                                                        return localValueM05D20di4;
                                                    });
                            }
                        }
                    }

                    var localServiceHostFactoryM05D20di1 = perResolveFuncM05D20di48;
                                return new ServiceHostEnvironment(localLoggerFactoryM05D20di0, localServiceHostFactoryM05D20di1, registerForRestart);
                            };
                return new MobiSystems.ServiceHost.ServiceApplication(transientFuncM05D20di1);
                [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
                void EnsureExistenceOf_singletonLogger2M05D20di40()
                {
                    if (_rootM05D20di._singletonLogger2M05D20di40 == null)
                    {
                        lock (_lockM05D20di)
                        {
                            if (_rootM05D20di._singletonLogger2M05D20di40 == null)
                            {
                                {                Logging.Sinks.File localFileSinkM05D20di3= new("c:\\Temp\\service-host.txt", new DefaultLogsCleaner());
                                 _rootM05D20di._singletonLogger2M05D20di40 = new LoggerConfiguration()
                                                    .WriteTo(localFileSinkM05D20di3)
                                                    .CreateLogger();}
                                _rootM05D20di._disposablesM05D20di[_rootM05D20di._disposeIndexM05D20di++] = _rootM05D20di._singletonLogger2M05D20di40;
                            }
                        }
                    }

                }
                [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
                void EnsureExistenceOf_singletonAppConfigurationM05D20di35()
                {
                    if (_rootM05D20di._singletonAppConfigurationM05D20di35 == null)
                    {
                        lock (_lockM05D20di)
                        {
                            if (_rootM05D20di._singletonAppConfigurationM05D20di35 == null)
                            {
                                {                AppConfiguration localConfigurationM05D20di6= new AppConfiguration();
                                localConfigurationM05D20di6.Init("MobiSystemsPackaged\\Configuration", "MobiSystems.ServiceHost.appsettings.json");
                                 _rootM05D20di._singletonAppConfigurationM05D20di35 = localConfigurationM05D20di6;}
                            }
                        }
                    }

                }
                [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
                void EnsureExistenceOf_singletonTelemetryRuntimeM05D20di37()
                {
                    if (_rootM05D20di._singletonTelemetryRuntimeM05D20di37 == null)
                    {
                        if (_rootM05D20di._singletonDeploymentContextM05D20di38 == null)
                        {
                            _rootM05D20di._singletonDeploymentContextM05D20di38 = new MobiSystems.Windows.DeploymentContext();
                        }

                        {
                            var localDeploymentContextM05D20di7 = _rootM05D20di._singletonDeploymentContextM05D20di38;

                            var localConfigurationM05D20di8 = _rootM05D20di._singletonAppConfigurationM05D20di35;

                                        TelemetryRuntimeParameters localParametersM05D20di9= new TelemetryRuntimeParameters(
                                            "MobiSystems.ServiceHost",
                        localConfigurationM05D20di8["TelemetryHost"],
                        localConfigurationM05D20di8["BuildType"],
                        localDeploymentContextM05D20di7.DeploymentType.GetDeploymentTypeName(),
                                            (_) => true);
                         _rootM05D20di._singletonTelemetryRuntimeM05D20di37 = new TelemetryRuntime(localParametersM05D20di9);}
                        _rootM05D20di._disposablesM05D20di[_rootM05D20di._disposeIndexM05D20di++] = _rootM05D20di._singletonTelemetryRuntimeM05D20di37;
                    }

                }
                [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
                void EnsureExistenceOf_singletonSentryIOTelemetryM05D20di36()
                {
                    if (_rootM05D20di._singletonSentryIOTelemetryM05D20di36 == null)
                    {
                        lock (_lockM05D20di)
                        {
                            if (_rootM05D20di._singletonSentryIOTelemetryM05D20di36 == null)
                            {
                                EnsureExistenceOf_singletonTelemetryRuntimeM05D20di37();
                                {
                                    var localTelemetryRuntimeM05D20di10 = _rootM05D20di._singletonTelemetryRuntimeM05D20di37;
                                 _rootM05D20di._singletonSentryIOTelemetryM05D20di36 = new SentryIOTelemetry();}
                            }
                        }
                    }

                }
            }
        }
        #endregion

        #region API
        /// <summary>
        /// Resolves the composition root.
        /// </summary>
        /// <typeparam name="T">The type of the composition root.</typeparam>
        /// <returns>A composition root.</returns>
        #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET
        [global::System.Diagnostics.Contracts.Pure]
        #endif
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public T Resolve<T>()
        {
            return ResolverM05D20di<T>.Value.Resolve(this);
        }

        /// <summary>
        /// Resolves the composition root by tag.
        /// </summary>
        /// <typeparam name="T">The type of the composition root.</typeparam>
        /// <param name="tag">The tag of a composition root.</param>
        /// <returns>A composition root.</returns>
        #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET
        [global::System.Diagnostics.Contracts.Pure]
        #endif
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public T Resolve<T>(object tag)
        {
            return ResolverM05D20di<T>.Value.ResolveByTag(this, tag);
        }

        /// <summary>
        /// Resolves the composition root.
        /// </summary>
        /// <param name="type">The type of the composition root.</param>
        /// <returns>A composition root.</returns>
        #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET
        [global::System.Diagnostics.Contracts.Pure]
        #endif
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public object Resolve(global::System.Type type)
        {
            var index = (int)(_bucketSizeM05D20di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
            ref var pair = ref _bucketsM05D20di[index];
            return pair.Key == type ? pair.Value.Resolve(this) : ResolveM05D20di(type, index);
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
        private object ResolveM05D20di(global::System.Type type, int index)
        {
            var finish = index + _bucketSizeM05D20di;
            while (++index < finish)
            {
                ref var pair = ref _bucketsM05D20di[index];
                if (pair.Key == type)
                {
                    return pair.Value.Resolve(this);
                }
            }

            throw new global::System.InvalidOperationException($"{CannotResolveMessageM05D20di} {OfTypeMessageM05D20di} {type}.");
        }

        /// <summary>
        /// Resolves the composition root by tag.
        /// </summary>
        /// <param name="type">The type of the composition root.</param>
        /// <param name="tag">The tag of a composition root.</param>
        /// <returns>A composition root.</returns>
        #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET
        [global::System.Diagnostics.Contracts.Pure]
        #endif
        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
        public object Resolve(global::System.Type type, object tag)
        {
            var index = (int)(_bucketSizeM05D20di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
            ref var pair = ref _bucketsM05D20di[index];
            return pair.Key == type ? pair.Value.ResolveByTag(this, tag) : ResolveM05D20di(type, tag, index);
        }

        [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
        private object ResolveM05D20di(global::System.Type type, object tag, int index)
        {
            var finish = index + _bucketSizeM05D20di;
            while (++index < finish)
            {
                ref var pair = ref _bucketsM05D20di[index];
                if (pair.Key == type)
                {
                    return pair.Value.ResolveByTag(this, tag);
                }
            }

            throw new global::System.InvalidOperationException($"{CannotResolveMessageM05D20di} \"{tag}\" {OfTypeMessageM05D20di} {type}.");
        }
        #endregion

        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void Dispose()
        {
            int disposeIndex;
            object[] disposables;
            lock (_lockM05D20di)
            {
                disposeIndex = _disposeIndexM05D20di;
                _disposeIndexM05D20di = 0;
                disposables = _disposablesM05D20di;
                _disposablesM05D20di = new object[3];
                _singletonServiceHostM05D20di41 = null;
                _singletonSentryIOTelemetryM05D20di36 = null;
                _singletonProcessRegistryM05D20di33 = null;
                _singletonLogger2M05D20di40 = null;
                _singletonAppConfigurationM05D20di35 = null;
                _singletonTelemetryRuntimeM05D20di37 = null;
                _singletonDeploymentContextM05D20di38 = null;
            }

            while (disposeIndex-- > 0)
            {
                switch (disposables[disposeIndex])
                {
                    case global::System.IDisposable disposableInstance:
                        try
                        {
                            disposableInstance.Dispose();
                        }
                        catch (Exception exception)
                        {
                            OnDisposeException(disposableInstance, exception);
                        }
                        break;
                }
            }
        }

        /// <summary>
        /// Implement this partial method to handle the exception on disposing.
        /// <summary>
        /// <param name="disposableInstance">The disposable instance.</param>
        /// <param name="exception">Exception occurring during disposal.</param>
        /// <typeparam name="T">The actual type of instance being disposed of.</typeparam>
        partial void OnDisposeException<T>(T disposableInstance, Exception exception) where T : global::System.IDisposable;

        private readonly static int _bucketSizeM05D20di;
        private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Composition, object>>[] _bucketsM05D20di;

        static Composition()
        {
            var valResolverM05D20di_0000 = new ResolverM05D20di_0000();
            ResolverM05D20di<MobiSystems.ServiceHost.ServiceApplication>.Value = valResolverM05D20di_0000;
            _bucketsM05D20di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Composition, object>>.Create(
                1,
                out _bucketSizeM05D20di,
                new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Composition, object>>[1]
                {
                     new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Composition, object>>(typeof(MobiSystems.ServiceHost.ServiceApplication), valResolverM05D20di_0000)
                });
        }

        #region Resolvers
        private const string CannotResolveMessageM05D20di = "Cannot resolve composition root ";
        private const string OfTypeMessageM05D20di = "of type ";

        private class ResolverM05D20di<T>: global::Pure.DI.IResolver<Composition, T>
        {
            public static global::Pure.DI.IResolver<Composition, T> Value = new ResolverM05D20di<T>();

            public virtual T Resolve(Composition composite)
            {
                throw new global::System.InvalidOperationException($"{CannotResolveMessageM05D20di}{OfTypeMessageM05D20di}{typeof(T)}.");
            }

            public virtual T ResolveByTag(Composition composite, object tag)
            {
                throw new global::System.InvalidOperationException($"{CannotResolveMessageM05D20di}\"{tag}\" {OfTypeMessageM05D20di}{typeof(T)}.");
            }
        }

        private sealed class ResolverM05D20di_0000: ResolverM05D20di<MobiSystems.ServiceHost.ServiceApplication>
        {
            public override MobiSystems.ServiceHost.ServiceApplication Resolve(Composition composition)
            {
                return composition.Root;
            }

            public override MobiSystems.ServiceHost.ServiceApplication ResolveByTag(Composition composition, object tag)
            {
                switch (tag)
                {
                    case null:
                        return composition.Root;

                    default:
                        return base.ResolveByTag(composition, tag);
                }
            }
        }
        #endregion

    }
}
ekalchev commented 2 months ago

Basically this part of the registration

.Bind().As(Singleton).To<TelemetryRuntime>(ctx => 
            {
                ctx.Inject(out IDeploymentContext deploymentContext);
                ctx.Inject(out Microsoft.Extensions.Configuration.IConfiguration configuration);

                TelemetryRuntimeParameters parameters = new TelemetryRuntimeParameters(
                    "MobiSystems.ServiceHost",
                    configuration["TelemetryHost"],
                    configuration["BuildType"],
                    deploymentContext.DeploymentType.GetDeploymentTypeName(),
                    (_) => true);

                return new TelemetryRuntime(parameters);
            })

this line

ctx.Inject(out Microsoft.Extensions.Configuration.IConfiguration configuration);

should generate source code that calls

EnsureExistenceOf_singletonAppConfigurationM05D20di35

But it doesn't

NikolayPianikov commented 2 months ago

Fixed in 2.1.20