github ppy/osu-framework 2021.818.0

latest releases: 2024.423.0, 2024.419.0, 2024.418.0...
2 years ago

Thanks for following along! This is a tagged release (2021.818.0).

Breaking changes

All custom implementations of IBindable must implement CreateInstance()

Bindables previously used Activator.CreateInstance() to implement the GetBoundCopy() call. In profiling this has turned out to be a bottleneck in some scenarios, so in order to reduce the associated runtime overhead to about half, all implementors of IBindable now must implement CreateInstance().

This also applies to all inheritors of framework-provided bindable types, who must instead override CreateInstance() from their base types.

For a given leaf bindable type in the inheritance hierarchy, the method should return a new constructed instance of the leaf type. The recommended pattern to use is as follows:

public class BaseBindable : IBindable
{
    IBindable IBindable.CreateInstance() => CreateInstance();
    protected virtual BaseBindable CreateInstance() => new BaseBindable();

    IBindable IBindable.GetBoundCopy() => GetBoundCopy();
    public BaseBindable GetBoundCopy()
        => IBindable.GetBoundCopyImplementation(this); // automatically calls CreateInstance()
}

public sealed class CustomBindable : BaseBindable
{
    protected override BaseBindable CreateInstance() => new CustomBindable();
}

Don't miss a new osu-framework release

NewReleases is sending notifications on new releases.