Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILifetimeContainer interface changes #206

Open
ENikS opened this issue Jun 28, 2020 · 0 comments
Open

ILifetimeContainer interface changes #206

ENikS opened this issue Jun 28, 2020 · 0 comments
Labels
Enhancement 🔨 Improvement of existing features

Comments

@ENikS
Copy link
Contributor

ENikS commented Jun 28, 2020

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

  • ILifetimeContainer operates on objects instead of IDisposable. It is possible to add an object that is not IDisposable
  • 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/SetValue handlers.

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);
}
@ENikS ENikS transferred this issue from unitycontainer/abstractions Sep 26, 2020
@ENikS ENikS added Discussion 💬 Inviting opinions on the subject Question ❔ Issue is a question labels Mar 12, 2023
@ENikS ENikS changed the title ILifetimeContainer interface is deprecated ILifetimeContainer interface changes Mar 12, 2023
@ENikS ENikS added Enhancement 🔨 Improvement of existing features and removed Discussion 💬 Inviting opinions on the subject Question ❔ Issue is a question labels Mar 12, 2023
@ENikS ENikS transferred this issue from unitycontainer/container Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 🔨 Improvement of existing features
Projects
None yet
Development

No branches or pull requests

1 participant