Skip to content

Use standard IDisposible implementation #1056

@AristurtleDev

Description

@AristurtleDev

Description

As I'm going through the code base and updating it to close out issues, I'm coming across classes that don't implement IDisposable in the standard pattern when the class or interfaces are meant to be inherited. The standard implementation should be

public class Foo : IDisposable
{
    public bool IsDisposed { get; private set; }

    ~Foo() => Dispose(false);

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    protected void Dispose(bool disposing)
    {
        if (IsDisposed)
        {
            return;
        }

        if (disposing)
        {
            // Disposed managed resources
        }

        // dispose unmanaged resources

        IsDisposed = true;
    }
}

As making this change for several classes would be considered a breaking change, I'm using this issue to keep track and as a reminder so they can be included with the next major SemVer release.

Implementations To Fix

  • SimpleDrawableComponent
  • World
  • UpdateSystem

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeRequires user code changes: API removals, behavioral breaks, or pipeline workflow changesenhancementImprovement to an existing feature: better defaults, expanded support, or quality-of-lifescope: apiPublic API surface: types, signatures, properties, interfaces, or serialization contracts

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions