-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
Enhancement 🔨Improvement of existing featuresImprovement of existing features
Description
ILifetimeContainer interface
Lifetime container holds references to disposable instances the container created or registered. It is responsible for properly disposing of these objects once the container goes out of scope. The ILifetimeContainer interface is a facade allowing adding and removing of instances to the container. The interface is declared as the following:
public interface ILifetimeContainer : IEnumerable<object>, IDisposable
{
IUnityContainer Container { get; }
int Count { get; }
void Add(object item);
void Remove(object item);
bool Contains(object item);
}Problem
ILifetimeContaineroperates on objects instead ofIDisposable.It is possible to add an object that is notIDisposable- The interface is derived from
IDisposable. It allowed disposing of the entire container scope from within the user's code. - This interface references the owner container and could be used to resolve dependencies inside the
GetValue/SetValuehandlers.
Solution
To remedy existing vulnerabilities, the interface will be changed as follows:
public interface ILifetimeContainer : IEnumerable<IDisposable>
{
int Count { get; }
void Add(IDisposable item);
void Remove(IDisposable item);
bool Contains(IDisposable item);
}Metadata
Metadata
Assignees
Labels
Enhancement 🔨Improvement of existing featuresImprovement of existing features