[x] Tested and contains NO breaking changes or known regressions.
[x] Tested with the upstream branch merged in.
[x] Tests have been added for bug fixes / features (or this option is not applicable)
[x] All new code has been documented (or this option is not applicable)
[x] Headers have been added to all new source files (or this option is not applicable)
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.
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 yourIStrixDataRoot
when you're done using it.