This creates a unit test which demonstrates that when a lambda function is used to generate an instance with a transient lifetime, that instance is created in a dependent class' constructor function but never registered for disposal in the containing scope.
My proposed solution is to add some generated code that attempts to cast the constructed instance to IDisposable and if it casts, then add it to the scope's Disposables collection during construction of the depending instance.
This creates a unit test which demonstrates that when a lambda function is used to generate an instance with a transient lifetime, that instance is created in a dependent class' constructor function but never registered for disposal in the containing scope.
My proposed solution is to add some generated code that attempts to cast the constructed instance to
IDisposable
and if it casts, then add it to the scope'sDisposables
collection during construction of the depending instance.