Closed Megasware128 closed 6 years ago
@Megasware128 Is this still an issue? I think this was fixed when @jeremydmiller changed this to use the Scope.TryAddDisposable()
method.
@CodingGorilla Still an issue in 1.1.2
I'm on this one next.
@Megasware128 @CodingGorilla I added some additional tests this morning to try to reproduce the issue and cannot. I think this was addressed in 1.1.2 and you might not have had the latest applied. See the tests for Bug_84_concrete_type_is_disposable_service_type_is_not
@jeremydmiller @CodingGorilla Somehow still an issue on the latest version. Maybe you have some use for the exception log?
System.InvalidOperationException
HResult=0x80131509
Message=Compilation failures!
CS1503: Argument 1: cannot convert from 'Bencom.Bellen.Calculator.Base.IProductsFactory' to 'System.IDisposable'
CS1503: Argument 1: cannot convert from 'Bencom.Bellen.Calculator.Base.IProductsFactory' to 'System.IDisposable'
CS1503: Argument 1: cannot convert from 'Bencom.Bellen.Calculator.Base.IProductsFactory' to 'System.IDisposable'
CS1503: Argument 1: cannot convert from 'Microsoft.Extensions.Hosting.IHostedService' to 'System.IDisposable'
CS1503: Argument 1: cannot convert from 'Microsoft.Extensions.Hosting.IHostedService' to 'System.IDisposable'
Code:
using Bencom.Bellen.Calculator.Import;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Threading.Tasks;
namespace Jasper.Generated
{
// START: System_Collections_Generic_IEnumerable_Microsoft_Extensions_Hosting_IHostedService__hostedServiceList
public class System_Collections_Generic_IEnumerable_Microsoft_Extensions_Hosting_IHostedService__hostedServiceList : Lamar.IoC.Resolvers.TransientResolver<System.Collections.Generic.IEnumerable<Microsoft.Extensions.Hosting.IHostedService>>
{
private readonly object _logger_of_SpiderResultsRepository;
private readonly Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration> _options_of_Configuration;
private readonly System.Func<object, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration>, Bencom.Bellen.Calculator.Repositories.IDealMatchesRepository> _func_of_object_IOptions_Bencom_Bellen_Calculator_Configuration__IDealMatchesRepository;
private readonly Microsoft.Extensions.Caching.Memory.IMemoryCache _memoryCache;
private readonly object _logger_of_DealMatcherService;
private readonly System.Func<Bencom.Bellen.Calculator.Repositories.IDealMatchesRepository, Microsoft.Extensions.Caching.Memory.IMemoryCache, object, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration>, Microsoft.Extensions.Hosting.IHostedService> _func_of_IDealMatchesRepository_IMemoryCache_object_IOptions_Bencom_Bellen_Calculator_Configuration__IHostedService;
private readonly Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration> _optionsMonitor_of_Configuration;
private readonly System.Func<Bencom.Bellen.Calculator.Repositories.IProductsRepository, Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration>, Microsoft.Extensions.Hosting.IHostedService> _func_of_IProductsRepository_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__IHostedService;
private readonly Bencom.Bellen.Calculator.Import.Importer _importer;
private readonly System.Func<System.IServiceProvider, Bencom.Bellen.Calculator.Base.IProductsFactory> _func_of_IServiceProvider_IProductsFactory;
private readonly object _logger_of_ProductsPrecalculator;
private readonly System.Func<Bencom.Bellen.Calculator.Import.Importer, Bencom.Bellen.Calculator.Base.IProductsFactory, Microsoft.Extensions.Caching.Memory.IMemoryCache, Microsoft.Extensions.Options.IOptionsSnapshot<Bencom.Bellen.Calculator.Configuration>, object, object> _func_of_Importer_IProductsFactory_IMemoryCache_IOptionsSnapshot_Bencom_Bellen_Calculator_Configuration__object_object;
private readonly System.Func<Bencom.Bellen.Calculator.Base.Calculators.IPrecalculator, Bencom.Bellen.Calculator.Base.IProductsFactory, object, Bencom.Bellen.Calculator.Import.ProductsPipeline.IProductsPrecalculator> _func_of_IPrecalculator_IProductsFactory_object_IProductsPrecalculator;
private readonly System.Func<Bencom.Bellen.Calculator.Base.Calculators.IPrecalculator, Bencom.Bellen.Calculator.Base.IProductsFactory, Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration>, object> _func_of_IPrecalculator_IProductsFactory_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object;
private readonly System.Func<Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration>, object> _func_of_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object;
private readonly System.Func<Bencom.Bellen.Calculator.Import.ProductsPipeline.IBundleCompositionCalculator> _func_of_IBundleCompositionCalculator;
private readonly object _logger_of_ImportPipeline;
private readonly System.Func<object, Bencom.Bellen.Calculator.Import.ProductsPipeline.IProductsPrecalculator, object, object, Bencom.Bellen.Calculator.Import.ProductsPipeline.IBundleCompositionCalculator, object, Bencom.Bellen.Calculator.Import.IImportPipeline> _func_of_object_IProductsPrecalculator_object_object_IBundleCompositionCalculator_object_IImportPipeline;
private readonly Microsoft.Extensions.Hosting.IApplicationLifetime _applicationLifetime;
private readonly object _options_of_ConsoleConfiguration;
private readonly object _logger_of_CalculatorService;
private readonly Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Base.Calculators.Calculator> _logger_of_Calculator;
private readonly Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.UsageCalculatorService> _logger_of_UsageCalculatorService;
private readonly System.Func<Bencom.Bellen.Calculator.Repositories.IProductsRepository, Bencom.Bellen.Calculator.Import.IImportPipeline, Bencom.Bellen.Calculator.Import.Importer, Microsoft.Extensions.Hosting.IApplicationLifetime, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration>, object, object, Bencom.Bellen.Calculator.IUsageCalculatorService, Microsoft.Extensions.Hosting.IHostedService> _func_of_IProductsRepository_IImportPipeline_Importer_IApplicationLifetime_IOptions_Bencom_Bellen_Calculator_Configuration__object_object_IUsageCalculatorService_IHostedService;
public System_Collections_Generic_IEnumerable_Microsoft_Extensions_Hosting_IHostedService__hostedServiceList([Lamar.Named("logger", "Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Repositories.SpiderResultsRepository>")] object logger_of_SpiderResultsRepository, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration> options_of_Configuration, System.Func<object, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration>, Bencom.Bellen.Calculator.Repositories.IDealMatchesRepository> func_of_object_IOptions_Bencom_Bellen_Calculator_Configuration__IDealMatchesRepository, Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache, [Lamar.Named("logger", "Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Base.DealMatcherService>")] object logger_of_DealMatcherService, System.Func<Bencom.Bellen.Calculator.Repositories.IDealMatchesRepository, Microsoft.Extensions.Caching.Memory.IMemoryCache, object, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration>, Microsoft.Extensions.Hosting.IHostedService> func_of_IDealMatchesRepository_IMemoryCache_object_IOptions_Bencom_Bellen_Calculator_Configuration__IHostedService, Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration> optionsMonitor_of_Configuration, System.Func<Bencom.Bellen.Calculator.Repositories.IProductsRepository, Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration>, Microsoft.Extensions.Hosting.IHostedService> func_of_IProductsRepository_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__IHostedService, Bencom.Bellen.Calculator.Import.Importer importer, System.Func<System.IServiceProvider, Bencom.Bellen.Calculator.Base.IProductsFactory> func_of_IServiceProvider_IProductsFactory, [Lamar.Named("logger", "Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Import.ProductsPipeline.ProductsPrecalculator>")] object logger_of_ProductsPrecalculator, System.Func<Bencom.Bellen.Calculator.Import.Importer, Bencom.Bellen.Calculator.Base.IProductsFactory, Microsoft.Extensions.Caching.Memory.IMemoryCache, Microsoft.Extensions.Options.IOptionsSnapshot<Bencom.Bellen.Calculator.Configuration>, object, object> func_of_Importer_IProductsFactory_IMemoryCache_IOptionsSnapshot_Bencom_Bellen_Calculator_Configuration__object_object, System.Func<Bencom.Bellen.Calculator.Base.Calculators.IPrecalculator, Bencom.Bellen.Calculator.Base.IProductsFactory, object, Bencom.Bellen.Calculator.Import.ProductsPipeline.IProductsPrecalculator> func_of_IPrecalculator_IProductsFactory_object_IProductsPrecalculator, System.Func<Bencom.Bellen.Calculator.Base.Calculators.IPrecalculator, Bencom.Bellen.Calculator.Base.IProductsFactory, Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration>, object> func_of_IPrecalculator_IProductsFactory_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object, System.Func<Microsoft.Extensions.Options.IOptionsMonitor<Bencom.Bellen.Calculator.Configuration>, object> func_of_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object, System.Func<Bencom.Bellen.Calculator.Import.ProductsPipeline.IBundleCompositionCalculator> func_of_IBundleCompositionCalculator, [Lamar.Named("logger", "Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Import.ImportPipeline>")] object logger_of_ImportPipeline, System.Func<object, Bencom.Bellen.Calculator.Import.ProductsPipeline.IProductsPrecalculator, object, object, Bencom.Bellen.Calculator.Import.ProductsPipeline.IBundleCompositionCalculator, object, Bencom.Bellen.Calculator.Import.IImportPipeline> func_of_object_IProductsPrecalculator_object_object_IBundleCompositionCalculator_object_IImportPipeline, Microsoft.Extensions.Hosting.IApplicationLifetime applicationLifetime, [Lamar.Named("optionsManager", "Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Console.ConsoleConfiguration>")] object options_of_ConsoleConfiguration, [Lamar.Named("logger", "Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Console.CalculatorService>")] object logger_of_CalculatorService, Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.Base.Calculators.Calculator> logger_of_Calculator, Microsoft.Extensions.Logging.ILogger<Bencom.Bellen.Calculator.UsageCalculatorService> logger_of_UsageCalculatorService, System.Func<Bencom.Bellen.Calculator.Repositories.IProductsRepository, Bencom.Bellen.Calculator.Import.IImportPipeline, Bencom.Bellen.Calculator.Import.Importer, Microsoft.Extensions.Hosting.IApplicationLifetime, Microsoft.Extensions.Options.IOptions<Bencom.Bellen.Calculator.Configuration>, object, object, Bencom.Bellen.Calculator.IUsageCalculatorService, Microsoft.Extensions.Hosting.IHostedService> func_of_IProductsRepository_IImportPipeline_Importer_IApplicationLifetime_IOptions_Bencom_Bellen_Calculator_Configuration__object_object_IUsageCalculatorService_IHostedService)
{
_logger_of_SpiderResultsRepository = logger_of_SpiderResultsRepository;
_options_of_Configuration = options_of_Configuration;
_func_of_object_IOptions_Bencom_Bellen_Calculator_Configuration__IDealMatchesRepository = func_of_object_IOptions_Bencom_Bellen_Calculator_Configuration__IDealMatchesRepository;
_memoryCache = memoryCache;
_logger_of_DealMatcherService = logger_of_DealMatcherService;
_func_of_IDealMatchesRepository_IMemoryCache_object_IOptions_Bencom_Bellen_Calculator_Configuration__IHostedService = func_of_IDealMatchesRepository_IMemoryCache_object_IOptions_Bencom_Bellen_Calculator_Configuration__IHostedService;
_optionsMonitor_of_Configuration = optionsMonitor_of_Configuration;
_func_of_IProductsRepository_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__IHostedService = func_of_IProductsRepository_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__IHostedService;
_importer = importer;
_func_of_IServiceProvider_IProductsFactory = func_of_IServiceProvider_IProductsFactory;
_logger_of_ProductsPrecalculator = logger_of_ProductsPrecalculator;
_func_of_Importer_IProductsFactory_IMemoryCache_IOptionsSnapshot_Bencom_Bellen_Calculator_Configuration__object_object = func_of_Importer_IProductsFactory_IMemoryCache_IOptionsSnapshot_Bencom_Bellen_Calculator_Configuration__object_object;
_func_of_IPrecalculator_IProductsFactory_object_IProductsPrecalculator = func_of_IPrecalculator_IProductsFactory_object_IProductsPrecalculator;
_func_of_IPrecalculator_IProductsFactory_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object = func_of_IPrecalculator_IProductsFactory_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object;
_func_of_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object = func_of_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object;
_func_of_IBundleCompositionCalculator = func_of_IBundleCompositionCalculator;
_logger_of_ImportPipeline = logger_of_ImportPipeline;
_func_of_object_IProductsPrecalculator_object_object_IBundleCompositionCalculator_object_IImportPipeline = func_of_object_IProductsPrecalculator_object_object_IBundleCompositionCalculator_object_IImportPipeline;
_applicationLifetime = applicationLifetime;
_options_of_ConsoleConfiguration = options_of_ConsoleConfiguration;
_logger_of_CalculatorService = logger_of_CalculatorService;
_logger_of_Calculator = logger_of_Calculator;
_logger_of_UsageCalculatorService = logger_of_UsageCalculatorService;
_func_of_IProductsRepository_IImportPipeline_Importer_IApplicationLifetime_IOptions_Bencom_Bellen_Calculator_Configuration__object_object_IUsageCalculatorService_IHostedService = func_of_IProductsRepository_IImportPipeline_Importer_IApplicationLifetime_IOptions_Bencom_Bellen_Calculator_Configuration__object_object_IUsageCalculatorService_IHostedService;
}
public System.Func<System.IServiceProvider, object> func_IProductsRepository {get; set;}
public override System.Collections.Generic.IEnumerable<Microsoft.Extensions.Hosting.IHostedService> Build(Lamar.IoC.Scope scope)
{
var IProductsRepository2 = (Bencom.Bellen.Calculator.Repositories.IProductsRepository)func_IProductsRepository((System.IServiceProvider)scope);
scope.TryAddDisposable(IProductsRepository2);
var serviceProvider1 = (System.IServiceProvider) scope;
var productsFactory1 = _func_of_IServiceProvider_IProductsFactory(serviceProvider1);
scope.Disposables.Add(productsFactory1);
var optionsManager = scope.GetInstance<Microsoft.Extensions.Options.IOptionsSnapshot<Bencom.Bellen.Calculator.Configuration>>("optionsManager");
var productsGenerator = _func_of_Importer_IProductsFactory_IMemoryCache_IOptionsSnapshot_Bencom_Bellen_Calculator_Configuration__object_object(_importer, productsFactory1, _memoryCache, optionsManager, _logger_of_ProductsPrecalculator);
var discountCalculator1 = new Bencom.Bellen.Calculator.Base.Calculators.DiscountCalculator(_memoryCache, optionsManager);
var precalculator1 = new Bencom.Bellen.Calculator.Base.Calculators.Precalculator(discountCalculator1);
var serviceProvider2 = (System.IServiceProvider) scope;
var productsFactory2 = _func_of_IServiceProvider_IProductsFactory(serviceProvider2);
scope.Disposables.Add(productsFactory2);
var productsPrecalculator = _func_of_IPrecalculator_IProductsFactory_object_IProductsPrecalculator(precalculator1, productsFactory2, _logger_of_ProductsPrecalculator);
var discountCalculator2 = new Bencom.Bellen.Calculator.Base.Calculators.DiscountCalculator(_memoryCache, optionsManager);
var precalculator2 = new Bencom.Bellen.Calculator.Base.Calculators.Precalculator(discountCalculator2);
var serviceProvider3 = (System.IServiceProvider) scope;
var productsFactory3 = _func_of_IServiceProvider_IProductsFactory(serviceProvider3);
scope.Disposables.Add(productsFactory3);
var productsPrevalidator = _func_of_IPrecalculator_IProductsFactory_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object(precalculator2, productsFactory3, _optionsMonitor_of_Configuration);
var clickUrlResolver = _func_of_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__object(_optionsMonitor_of_Configuration);
var bundleCompositionCalculator = _func_of_IBundleCompositionCalculator();
var importPipeline = _func_of_object_IProductsPrecalculator_object_object_IBundleCompositionCalculator_object_IImportPipeline(productsGenerator, productsPrecalculator, productsPrevalidator, clickUrlResolver, bundleCompositionCalculator, _logger_of_ImportPipeline);
var discountCalculator3 = new Bencom.Bellen.Calculator.Base.Calculators.DiscountCalculator(_memoryCache, optionsManager);
var precalculator3 = new Bencom.Bellen.Calculator.Base.Calculators.Precalculator(discountCalculator3);
var calculator = new Bencom.Bellen.Calculator.Base.Calculators.Calculator(precalculator3, _logger_of_Calculator);
var serviceProvider4 = (System.IServiceProvider) scope;
var usageCalculatorService = new Bencom.Bellen.Calculator.UsageCalculatorService(calculator, _logger_of_UsageCalculatorService, optionsManager, serviceProvider4);
var calculatorService = _func_of_IProductsRepository_IImportPipeline_Importer_IApplicationLifetime_IOptions_Bencom_Bellen_Calculator_Configuration__object_object_IUsageCalculatorService_IHostedService(IProductsRepository2, importPipeline, _importer, _applicationLifetime, _options_of_Configuration, _options_of_ConsoleConfiguration, _logger_of_CalculatorService, usageCalculatorService);
scope.Disposables.Add(calculatorService);
var IProductsRepository1 = (Bencom.Bellen.Calculator.Repositories.IProductsRepository)func_IProductsRepository((System.IServiceProvider)scope);
scope.TryAddDisposable(IProductsRepository1);
var productsCacheService = _func_of_IProductsRepository_IOptionsMonitor_Bencom_Bellen_Calculator_Configuration__IHostedService(IProductsRepository1, _optionsMonitor_of_Configuration);
scope.Disposables.Add(productsCacheService);
var spiderResultsRepository = _func_of_object_IOptions_Bencom_Bellen_Calculator_Configuration__IDealMatchesRepository(_logger_of_SpiderResultsRepository, _options_of_Configuration);
var dealMatcherService = _func_of_IDealMatchesRepository_IMemoryCache_object_IOptions_Bencom_Bellen_Calculator_Configuration__IHostedService(spiderResultsRepository, _memoryCache, _logger_of_DealMatcherService, _options_of_Configuration);
return new System.Collections.Generic.List<Microsoft.Extensions.Hosting.IHostedService>{dealMatcherService, productsCacheService, calculatorService};
}
}
// END: System_Collections_Generic_IEnumerable_Microsoft_Extensions_Hosting_IHostedService__hostedServiceList
}
Source=Lamar
StackTrace:
at Lamar.Compilation.AssemblyGenerator.Generate(String code) in D:\Repos\lamar\src\Lamar\Compilation\AssemblyGenerator.cs:line 163
at Lamar.Compilation.GeneratedAssembly.CompileAll(ServiceGraph services) in D:\Repos\lamar\src\Lamar\Compilation\GeneratedAssembly.cs:line 47
at Lamar.IoC.Instances.GeneratedInstance.buildResolver(Scope scope) in D:\Repos\lamar\src\Lamar\IoC\Instances\GeneratedInstance.cs:line 163
at Lamar.IoC.Instances.GeneratedInstance.ToResolver(Scope topScope) in D:\Repos\lamar\src\Lamar\IoC\Instances\GeneratedInstance.cs:line 113
at Lamar.ServiceGraph.FindResolver(Type serviceType) in D:\Repos\lamar\src\Lamar\ServiceGraph.cs:line 345
at Lamar.IoC.Scope.TryGetInstance(Type serviceType) in D:\Repos\lamar\src\Lamar\IoC\Scope.cs:line 176
at Lamar.IoC.Scope.GetService(Type serviceType) in D:\Repos\lamar\src\Lamar\IoC\Scope.cs:line 124
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) in /_/src/DI.Abstractions/ServiceProviderServiceExtensions.cs:line 28
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__9.MoveNext() in /_/src/Microsoft.Extensions.Hosting/Internal/Host.cs:line 41
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in E:\A\_work\36\s\src\mscorlib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 132
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in E:\A\_work\36\s\src\mscorlib\src\System\Runtime\CompilerServices\TaskAwaiter.cs:line 155
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() in /_/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostExtensions.cs:line 61
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in E:\A\_work\36\s\src\mscorlib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 132
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in E:\A\_work\36\s\src\mscorlib\src\System\Runtime\CompilerServices\TaskAwaiter.cs:line 155
at Bencom.Bellen.Calculator.Console.Program.<Main>d__0.MoveNext() in D:\Repos\Bencom.Bellen.Api vNext\Bencom.Bellen.Calculator.Console\Program.cs:line 15
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in E:\A\_work\36\s\src\mscorlib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 132
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in E:\A\_work\36\s\src\mscorlib\src\System\Runtime\CompilerServices\TaskAwaiter.cs:line 155
at Bencom.Bellen.Calculator.Console.Program.<Main>(String[] args)
@jeremydmiller @CodingGorilla Note how sometimes TryAddDisposable is used and sometimes just Disposables.Add
@jeremydmiller @CodingGorilla Do these lines need to be changed to writer.WriteLine($"{_scope.Usage}.{nameof(Scope.TryAddDisposable)}({Variable.Usage});");
?
Meh, yes it does, and I see what the particular permutation of stuff is now. I didn't test for building an internal type where it's forced to go to a Func.
Hi @jeremydmiller, I'm sorry to react on this issue again but the problem is still appearing in version 2.0.1 because of this line still not using TryAddDisposable
I would like to open a PR for this but I'm unsure how the tests should be written for this
Dude, all you need to do is write any kind of test that fails that demonstrates the problem. I needed the combinations of registrations that brought this about. I'm opening a separate issue for this one because it's actually a different problem. The thing I was missing was that it was coming from an internal type as opposed to a public type. Lamar has to use different mechanisms for internals, and that's what I missed.
Also happens whenever you do
AddTransient<TService, TImplementation>
where TService doesn't implement IDisposable and TImplementation does.Workaround I tried was changing this line in CallFuncBuilderFrame.cs and ConstructorFrame.cs:
writer.Write($"{_scope.Usage}.{nameof(Scope.Disposables)}.Add({Variable.Usage});");
to this:writer.Write($"{_scope.Usage}.{nameof(Scope.Disposables)}.Add((IDisposable){Variable.Usage});");
which fixes this issue. Should this be implemented?