Arlodotexe / strix-music

Combine any music sources into a single library. It's your music. Play it your way.
http://www.strixmusic.com
139 stars 4 forks source link

[breaking] Removed IAsyncDisposable from all strix standard models except ICore and IStrixDataRoot #228

Closed Arlodotexe closed 2 years ago

Arlodotexe commented 2 years ago

Overview

Closes #223

Checklist

This PR meets the following requirements:

Migration path

Core implementors

Each core model is required to have a SourceCore property, meant to be the core which ultimately spawned the model you're currently in.

All core models must have this. ICore contains methods for InitAsnyc and DisposeAsync - this should be enough to set up / tear down any unmanaged resources needed by your core, such as opening and closing a websocket.

If that is set up, you can place your service on your ICore and use the SourceCore property to interact with your service.

Since your service is stored on your core, you can share the instance across models, and it'll keep functioning even when a model is garbage collected and fully disposed.

The GC will clean up any model that isn't being referenced.

For cleanup, just stick to ICore.DisposeAsync.

Plugin authors

If you were overriding these to help dispose resources, then remove that and make your plugin IAsyncDisposable instead.

If you were overriding these to manipulate the lifetime of a model, then don't. The GC in .NET is smart enough to take care of it for you, as long as everyone cleans up their references to the model.

SDK consumers

Remove any calls you have to DisposeAsync on these models. Instead, just make sure you clean up your references to the model if you aren't actively using it.

If the data structure is disposed, events and even method calls may stop working as the cores and sdk release resources. Call DisposeAsync on your IStrixDataRoot when you're done using it.